它首次呈现时对我来说工作正常。 但是,如果我改变了地图上的任何东西或重新创建它,它就会被破坏。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()方法。
有人能指出我在做什么错在这里。