它首次呈現時對我來說工作正常。 但是,如果我改變了地圖上的任何東西或重新創建它,它就會被破壞。GWT Google Map Api V3 - 更換時發生故障
下面是屏幕截圖的外觀。
下面是更改每頁結果值後的屏幕截圖。
這是我的代碼。
@UiField DivElement mapPanel;
private GoogleMap googleMap;
public void loadAllMarkers(final List<LatLng> markers)
{
if(!markers.isEmpty())
{
final MapOptions options = MapOptions.create();
options.setMapTypeId(MapTypeId.ROADMAP);
googleMap = GoogleMap.create(mapPanel, options);
final LatLngBounds latLngBounds = LatLngBounds.create();
for(LatLng latLng : markers)
{
final MarkerOptions markerOptions = MarkerOptions.create();
markerOptions.setPosition(latLng);
markerOptions.setMap(googleMap);
final Marker marker = Marker.create(markerOptions);
latLngBounds.extend(marker.getPosition());
}
googleMap.setCenter(latLngBounds.getCenter());
googleMap.fitBounds(latLngBounds);
}
}
無論何時需要加載新結果,我都會調用loadAllMarkers()方法。
有人能指出我在做什麼錯在這裏。