2011-05-13 85 views
1

我在我的應用程序中有一個地圖活動。當用戶首次啓動地圖活動時,地圖呈現europe.i概述,當用戶猛地啓動地圖活動指向希臘例如,而不是孔europe..is是可能的..謝謝如何更改我對地圖活動的第一視圖

回答

3

可以使用MapController做到這一點:?

MapView map = (MapView) findViewById(R.id.mapview); 

GeoPoint center = new GeoPoint(myLatitude, myLongitude); 

MapController controller = map.getController(); 
controller.setCenter(center); 
controller.setZoom(ZOOM_LEVEL_DEFAULT); 

,或者如果你想計算的變焦適合一些經度/緯度範圍:

int latitudeSpan = latitude1 - latitude2; 
int longitudeSpan = longitude1 - longitude2; 
controller.zoomToSpan(latitudeSpan, longitudeSpan); 
+0

eclipse突出顯示紅色的map.getController並提示我創建一個變量map ...我的錯誤是什麼? – kostas 2011-05-13 12:18:23

+0

地圖是MapView的一個實例。在佈局XML中使用MapView的ID來創建它。我已經編輯過我的帖子。 – TofferJ 2011-05-13 13:01:07