2011-03-16 26 views
2

我可以把我的位置,myLocationOverlay容易,我想設置爲我的位置的中心,我想映象控制器:我該如何使用mylocationoverlay來集中我的位置?

MapController mc = myMap.getController(); 
mc.animateTo(); 
mc.setCenter(myLocOverlay.getMyLocation()); 

這些代碼沒有工作,所以我改變

p = new GeoPoint((int) (myLocOverlay.getMyLocation().getLatitudeE6()), (int) (myLocOverlay.getMyLocation().getLongitudeE6())); 

mc.setCenter(p); 

但沒有好消息。我把空指針異常,然後我myLocationOverlay(),但它不工作之前分配新的位置..謝謝..提前

回答

2

的animateTo可以用於此,

GeoPoint point = this.currentLocationOverlay.getMyLocation(); 
if(point==null) 
    return; 
//center map on that geopoint 
mc.animateTo(point); 
相關問題