3

I am trying to show the current location to the user. Now I am using icon to denote the location. But the problem is icon is not placed in the exact location. It showing little bit top from the location.map image

Please refer the screenshot. I want to place the icon in exact blue dot.

I am using following code to show the icon in the map.

    latLng = new LatLng(location.getLatitude(), location.getLongitude());
    MarkerOptions markerOptions = new MarkerOptions();
    markerOptions.position(latLng);
    markerOptions.title("Current Position");
    markerOptions.icon(BitmapDescriptorFactory.fromResource(R.drawable.navigation_arrow));
    currLocationMarker = mMap.addMarker(markerOptions);

I don't want to remove the blue dot(GoogleMap.setMyLocationEnabled). I want to place the icon on that blue dot.

Vijay
  • 3,152
  • 3
  • 24
  • 33

2 Answers2

12

You need to set the anchor point of your Marker using the anchor method from the MarkerOptions.

By default the anchor point of the Marker's icon is set on the middle bottom.

For example, to set the anchor point on the center of the icon you need to do:

markerOptions.anchor(0.5f, 0.5f);
antonio
  • 18,044
  • 4
  • 45
  • 61
0

Make sure you have correct location coordinates. And also make sure about the drawable you are using. you can recreate the drawable using this link.

Sagar Patil
  • 1,400
  • 15
  • 29