Reputation: 146
I already implement Google map to find location and my current position..Position and my current location shows well.But my current location indicates by blue dot(default),I want to customize.I know it will done by marker but not working it... here is my code..
private void initilizeMap() {
if (googleMap == null) {
googleMap = ((MapFragment) getFragmentManager().findFragmentById(
R.id.map)).getMap();
googleMap.getUiSettings().setCompassEnabled(false);
googleMap.getUiSettings().setRotateGesturesEnabled(true);
googleMap.setMyLocationEnabled(true);
googleMap.getUiSettings().setMyLocationButtonEnabled(true);
MarkerOptions marker = new MarkerOptions().position(new LatLng(latitude, longitude)).title("Target Location + "+ latitude+" +"+longitude);
marker.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_YELLOW));
// adding marker
googleMap.addMarker(marker);
Location myLocation = googleMap.getMyLocation();
if(myLocation!=null)
{
double dLatitude = myLocation.getLatitude();
double dLongitude = myLocation.getLongitude();
Log.i("APPLICATION"," : "+dLatitude);
Log.i("APPLICATION"," : "+dLongitude);
googleMap.addMarker(new MarkerOptions().position(
new LatLng(dLatitude, dLongitude)).title("My Location").icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE)));
// mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(dLatitude, dLongitude), 8));*/
}
else
{
Toast.makeText(this, "Unable to fetch the current location", Toast.LENGTH_SHORT);
}
}
Upvotes: 1
Views: 461
Reputation: 3386
You set your new marker's position when you initialize your map. But location provider will update your location for finding your real location. So you should track your location and change marker location on every update.
Upvotes: 1