Implemented the Uusuario Localization activity every 15 seconds.
Variables are global class:
LatitudeUsers UserLength marker
Within the onLocationChanged
method I set the two location variables, and call the addMarqueries.
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 "Userss12"
because it is a static location is only with a Bookmark, so that's fine.
But "Minhaaa"
is repeating the bookmark every time it updates!
leaving a lot of marker on the map ....