Android 为什么谷歌地图v2显示了这么多标记?

Android 为什么谷歌地图v2显示了这么多标记?,android,google-maps,Android,Google Maps,嗨,我有这个问题谷歌地图v2显示了这么多的标记,我只想与我的确切位置的标记。我怎样才能删除它?我猜它不能确定我的确切位置?这是我的密码 @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // show error dialog if GoolglePlayServices not available if (!isGoo

嗨,我有这个问题谷歌地图v2显示了这么多的标记,我只想与我的确切位置的标记。我怎样才能删除它?我猜它不能确定我的确切位置?这是我的密码

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);



    // show error dialog if GoolglePlayServices not available
    if (!isGooglePlayServicesAvailable()) {
        finish();
    }
    setContentView(R.layout.main);
    SupportMapFragment supportMapFragment = (SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.googleMap);
    googleMap = supportMapFragment.getMap();
    googleMap.setMyLocationEnabled(true);
    LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
    Criteria criteria = new Criteria();
    String bestProvider = locationManager.getBestProvider(criteria, true);
    Location location = locationManager.getLastKnownLocation(bestProvider);

    if (location != null) {
        onLocationChanged(location);
    }
    locationManager.requestLocationUpdates(bestProvider, 20000, 0, this);



}

@Override
public void onLocationChanged(Location location) {


    Button btnOurLocation = (Button) findViewById(R.id.latlongLocation);
    // TextView locationTv = (TextView) findViewById(R.id.latlongLocation);
    double latitude = location.getLatitude();
    double longitude = location.getLongitude();
    LatLng latLng = new LatLng(latitude, longitude);
    googleMap.addMarker(new MarkerOptions().position(latLng));
    googleMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
    googleMap.animateCamera(CameraUpdateFactory.zoomTo(15));
    // locationTv.setText("Latitude:" + latitude + ", Longitude:" +
    // longitude);

    try {
        geocoder = new Geocoder(StopItActivity.this, Locale.ENGLISH);
        addresses = geocoder.getFromLocation(latitude, longitude, 1);
        StringBuilder str = new StringBuilder();

        // Address returnAddress = addresses.get(0);

        address = addresses.get(0).getAddressLine(0);
        // String localityString = returnAddress.getLocality();
        // String city = returnAddress.getCountryName();
        // String region_code = returnAddress.getCountryCode();
        // String zipcode = returnAddress.getPostalCode();

        // str.append(address + "");
        // str.append(localityString + "");
        // str.append(city + "" + region_code + "");
        // str.append(zipcode + "");

    } catch (IOException e) {
        // TODO Auto-generated catch block

        Log.e("tag", e.getMessage());
    }

    btnOurLocation.setOnClickListener(new View.OnClickListener() {

        public void onClick(View arg0) {

            Toast.makeText(getApplicationContext(), address,
                    Toast.LENGTH_SHORT).show();

        }

    });

}

然后是输出

我认为您应该在添加新标记之前删除旧标记。在OnLocationChanged(Location-Location)回调中添加标记之前,添加下面的代码行

 googleMap.clear()