问题
I added markers on my map :
ClusterLayer markersClusterLayer = new ClusterLayer();
Collection<MapMarker> markers = new ArrayList<>();
for (GeoCoordinate geoCoordinate : list.get(0).getRoute().getWaypoints()) {
MapMarker marker = new MapMarker();
marker.setCoordinate(geoCoordinate);
markers.add(marker);
}
markersClusterLayer.addMarkers(markers);
map.addClusterLayer(markersClusterLayer);
When I rotate my map using my fingers on the device, the marker position changes slightly, going from one side of a road to another for example.
How can I fix it?
Thanks
Edit: video showing the problem: youtu.be/mhObjaq72GQ
回答1:
I found the issue, it was related to the altitude of the point.
I was using
PositioningManager.getInstance().getLastKnownPosition()
which returned a position with altitude. As a result the marker was "flying" above the map. Setting altitude to 0 fixed the issue.
回答2:
It's not evident from your code, but is it possible that you are using a custom icon for your MapMarkers? If so, remember that the anchor is set to the center of the image by default. This isn't always the correct position.
For example, if your marker image is an arrow, you want to set the anchor to the tip of the arrow. Otherwise it might appear to point to different locations when the map is rotated (event though its center will always be in the same spot). Setting an incorrect anchor can also lead to similar behavior.
You can change the anchor by using the setAnchorPoint
method.
来源:https://stackoverflow.com/questions/37572251/the-markers-on-the-map-change-position-when-map-is-rotated