0
我有一個使用OSMDroid的項目。 有一個繪製標記的循環,之後結束,我必須將中心映射在某個標記處。我的代碼:OSMDroid:以標記爲中心
//I have on open Cursor c
Marker switchTo = null;
do {
Marker mr = new Marker(mapView);
GeoPoint gp = new GeoPoint(c.getDouble(iLat), c.getDouble(iLng));
mr.setPosition(gp);
//some actions: set anchor, drawable etc
int id = c.getInt(iId);
if (MainActivity.switchToId != -1 && id == MainActivity.switchToId) {
switchTo = mr; //if I have to switch to exactly this marker
MainActivity.switchToId = -1; //cleanup
}
mPoiMarkers.add(mr); //add to cluster
} while (c.moveToNext()); //next marker
mapView.getOverlays().add(mPoiMarkers); //add cluster to map
Log.d(TAG, "Markers redrawed.");
if (switchTo != null) { //go to marker
mapView.getController().setCenter(switchTo.getPosition());
mapView.getController().setZoom(14);
}
問題:地圖設置中心不在標記處,但距離它一些公里。我不知道發生了什麼事。標記站在正常位置...