Android 当用户进入googlemaps中的特定区域时,如何祝酒

Android 当用户进入googlemaps中的特定区域时,如何祝酒,android,android-mapview,android-maps-v2,android-maps,Android,Android Mapview,Android Maps V2,Android Maps,固定位置的纬度和经度为(13.060422000000000000,80.249583000000030000)。如果我的设备在该位置20米的范围内,它必须在该区域显示与您类似的信息。如果你出去,它应该表明你不合适。现在,我已经创建了一个地图,并获得了用户的位置和显示。但我不知道怎么做。请帮我做这个。我的代码是 MainActivity.java public class MainActivity extends Activity implements LocationListener{

固定位置的纬度和经度为(13.060422000000000000,80.249583000000030000)。如果我的设备在该位置20米的范围内,它必须在该区域显示与您类似的信息。如果你出去,它应该表明你不合适。现在,我已经创建了一个地图,并获得了用户的位置和显示。但我不知道怎么做。请帮我做这个。我的代码是 MainActivity.java

public class MainActivity extends Activity implements LocationListener{
    // static final LatLng TutorialsPoint = new LatLng(13.060422000000000000,
    // 80.249583000000030000);
    private GoogleMap googleMap;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        try {
            if (googleMap == null) {
                googleMap = ((MapFragment) getFragmentManager()
                        .findFragmentById(R.id.map)).getMap();
            }
            //googleMap.setMyLocationEnabled(true);
            googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);

            LocationManager service = (LocationManager) getSystemService(LOCATION_SERVICE);
            Criteria criteria = new Criteria();
            String provider = service.getBestProvider(criteria, false);

            Location location = service.getLastKnownLocation(provider);
            LatLng userLocation = new LatLng(location.getLatitude(),
                    location.getLongitude());
            googleMap.addMarker(new MarkerOptions().position(userLocation)
                    .title("Adaptavant Technologies"));

            googleMap.moveCamera(CameraUpdateFactory.newLatLng(userLocation));

            googleMap.animateCamera(CameraUpdateFactory.zoomTo(15));
            CircleOptions options=new CircleOptions().center(userLocation).radius(20).fillColor(0x400099FF).strokeColor(Color.TRANSPARENT).strokeWidth(2);
            googleMap.addCircle(options);

        } catch (Exception e) {
            Log.e("simon", "Error : " + e.getMessage());
            e.printStackTrace();
        }
    }

    @Override
    public void onLocationChanged(Location arg0) {
        Toast.makeText(getApplicationContext(), "You are moving", Toast.LENGTH_SHORT).show();

    }
}
和activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="${relativePackage}.${activityClass}" >

    <fragment
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.MapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</RelativeLayout>

Manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.simon.learning.googlemaptesting"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="11"
        android:targetSdkVersion="21" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" />
        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />

        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>


那么请告诉我怎么做???提前感谢

您可以在OnLocationChanged Listener()上计算当前位置到指定位置的距离,然后可以显示土司。

您可以使用函数在OnLocationChangedListener()上计算两个位置的距离-

Location locationA = new Location("point A");     
locationA.setLatitude(latA); 
locationA.setLongitude(lngA);
Location locationB = new Location("point B");
locationB.setLatitude(latB); 
LocationB.setLongitude(lngB);
distance = locationA.distanceTo(locationB) ;

谢谢你的否决票,但请给我一些想法,谷歌“地理围栏”这个词。