我已经实现了OSMDroid并添加了一个自定义标记,如下所示:
mResourceProxy = new DefaultResourceProxyImpl(getApplicationContext());
mapView.setTileSource(TileSourceFactory.MAPNIK);
mapView.setBuiltInZoomControls(true);
mapView.setMultiTouchControls(true);
mapController = this.mapView.getController();
mapController.setZoom(25);
GeoPoint center = new GeoPoint(DataManager.glat, DataManager.glon);
mapController.setCenter(center);
OverlayItem newItem = new OverlayItem("Here", "SampleDescription", center);
Drawable newMarker = this.getResources().getDrawable(R.drawable.marker);
newItem.setMarker(newMarker);
Run Code Online (Sandbox Code Playgroud)
该标记应位于用户的位置,默认情况下,地图应居中。只要我不缩放,效果就很好:

但是当我缩小时,标记会移动:

距离随缩放级别增加:

知道这是由什么引起的吗?自定义标记是否有任何限制/准则?
注意:使用默认标记时不会发生这种情况。
Found the problem: Hotspot
Seems like the default Hotspot is Bottom Center, in my case, Center would be the right one. The bottom center of my marker WAS at the right place, it just didnt look like it.
newItem.setMarkerHotspot(HotspotPlace.CENTER); fixed it
This is basically my marker:
___________
| _ |
| ( ) |
| V |
| |
|___________|
Run Code Online (Sandbox Code Playgroud)