2013-04-02 20 views

回答

1

谷歌地圖沒有一個「fitAllMarkers」函數/方法,但你應該能夠合理地實現這一目標只需使用fitBounds方法。

測試下面的代碼,但這樣的事情應該工作:

// A list of all your markers. 
List<Marker> markers; 

// Get the current bounds of your map. 
LatLngBounds latLngBounds = googleMap.getBounds(); 

for(Marker marker : markers) { 
    // Extend the bounds of your map to fit the position (LatLng) of each marker. 
    latLngBounds.extend(marker.getPosition()); 
} 

// This may not be needed - test it. 
// Tell the map to zoom to fit the bounds that you defined for your markers. 
googleMap.fitBounds(latLngBounds); 
+0

它的工作...謝謝... – Sree

相關問題