How To Move Circle As My Location Changed In Google Map In Android
I am developing an android application in this i draw a circle on map I want that as my location changed circle also moves as my location changed if any one know please help me th
Solution 1:
Try this..
@OverridepublicvoidonLocationChanged(Location location)
{
drawMarker(location);
}
privatevoiddrawMarker(Location location)
{
googleMap.clear();
LatLngcurrentPosition=newLatLng(location.getLatitude(),location.getLongitude());
googleMap.addMarker(newMarkerOptions()
.position(currentPosition)
.snippet("Lat:" + location.getLatitude() + " Lng:"+ location.getLongitude())
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE))
.title("ME"));
doublelatitude= location.getLatitude();
doublelongitude= location.getLongitude();
CameraPositioncameraPosition=newCameraPosition.Builder().target(newLatLng(latitude,longitude)).zoom(15f).build();
googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
}
Solution 2:
To move the marker, you may store the marker in a variable when you add to map. And when you want to move it, call the api marker.setPosition(position_where_you_want_to_move). This will not require the map to be cleared everytime location is retrieved
Post a Comment for "How To Move Circle As My Location Changed In Google Map In Android"