Skip to content Skip to sidebar Skip to footer

Drawable Icons On Route Not Pinned At Base

I am using drawable images for marker icons on a route. The base of the image does not appear at the point but rather more in the middle. Can this be addressed? Double latitude

Solution 1:

You either need to add padding to the bottom of the marker icon png or a better option would be using MarkerViewOptions() instead. They give more options then the GL markers your currently using including anchor. By default the anchoring is center bottom. So one of you markers would look like this:

mapboxMap.addMarker(new MarkerViewOptions()
            .position(destinationLatLng)
            .title("Destination")
            .snippet("destination: (" + destination.getLatitude() + ", " + destination.getLongitude() + ")")
            .icon(redPinIcon));

To answer your other question, why position takes in longitude, latitude in that order, many of the Mapbox APIs consume coordinates in that order. The bigger question is why does the Position object exist when LatLng is found already in the Map SDK? This is because the objects would conflict since they are found in separate SDKs yet are typically used together. It is something we look forward to changing in the near future.

EDIT: first you need to remove the mapbox-android-directions, this is an old, non supported, SDK we have deprecated. Mapbox Android Services (MAS) is it's replacement and uses Mapbox Directions V5. Use this example which shows how to properly make a directions call using MAS and add the markers to the map. Using the coordinates found in your question, the result looks like this:

enter image description here

Post a Comment for "Drawable Icons On Route Not Pinned At Base"