2
I implemented the Uusuario Location App every 15 seconds.
Variables are global class:
latitudeUsuario longitudeUsuario Marker
Within the method onLocationChanged
i select the two location variables, and call the add .
private void adicionarMarcadores() {
if(marker != null){
marker.remove();
}
marker = mMap.addMarker(new MarkerOptions().position(new LatLng(latitudeUsuario, longitudeUsuario)).title("Minhaaa"));
marker = mMap.addMarker(new MarkerOptions().position(new LatLng(-23.618439,-46.605477)).title("Userss12"));
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(latitudeUsuario, longitudeUsuario), 18.0f));
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
return;
}
mMap.setMyLocationEnabled(true);
}
The problem is that the "Userss12"
for being a static location is only with a Marker, so far so good.
But the "Minhaaa"
is repeating the Bookmark every time it updates!
leaving a lot of marker on the map....
try using mmap.clear() will clear everything on the map
– Alessandro Barreto