這種情況如下:我有一個圖層,上面有兩個點。第一個是在澳大利亞,第二個是在美國。大陸或點的確切位置不計算在內。基本部分是點之間的很大距離。當應用程序啓動時,出現第一個點(縮放級別爲18)。第二點不顯示,因爲它離這裏很遠,縮放級別很高。然後我用第二個點的位置調用panTo函數。地圖跳轉到正確的位置,但第二個點不出現。只有當我放大/縮小瀏覽器窗口或調整瀏覽器窗口大小時纔會出現此點。 GWT代碼:當它們之間有很大的距離時顯示點(GWT-Openlayers)
LonLat center = new LonLat(151.304485, -33.807831);
final LonLat usaPoint = new LonLat(-106.356183, 35.842721);
MapOptions defaultMapOptions = new MapOptions();
defaultMapOptions.setNumZoomLevels(20);
// mapWidget
final MapWidget mapWidget = new MapWidget("100%", "100%", defaultMapOptions);
// google maps layer
GoogleV3Options gSatelliteOptions = new GoogleV3Options();
gSatelliteOptions.setIsBaseLayer(true);
gSatelliteOptions.setDisplayOutsideMaxExtent(true);
gSatelliteOptions.setSmoothDragPan(true);
gSatelliteOptions.setType(GoogleV3MapType.G_SATELLITE_MAP);
GoogleV3 gSatellite = new GoogleV3("Google Satellite", gSatelliteOptions);
mapWidget.getMap().addLayer(gSatellite);
// pointLayer
VectorOptions options = new VectorOptions();
options.setDisplayOutsideMaxExtent(true);
Vector vector = new Vector("layer1", options);
mapWidget.getMap().addLayer(vector);
mapWidget.getMap().addControl(new LayerSwitcher());
mapWidget.getMap().addControl(new MousePosition());
mapWidget.getMap().addControl(new ScaleLine());
mapWidget.getMap().addControl(new Scale());
// two points are added to the layer
center.transform(new Projection("EPSG:4326").getProjectionCode(), mapWidget.getMap().getProjection());
vector.addFeature(new VectorFeature(new Point(center.lon(), center.lat())));
usaPoint.transform(new Projection("EPSG:4326").getProjectionCode(), mapWidget.getMap().getProjection());
vector.addFeature(new VectorFeature(new Point(usaPoint.lon(), usaPoint.lat())));
// the center of the map is the first point
mapWidget.getMap().setCenter(center, 18);
// 3 sec later panTo second point
Timer t = new Timer() {
@Override
public void run() {
mapWidget.getMap().panTo(usaPoint);
}
};
t.schedule(3000);
我試圖用純Openlayers重現這種情況,但它工作正常。這裏是link 所以我認爲問題是與GWT的Openlayers。有沒有人經歷過這種行爲?還是有人有解決這個問題?
Knarf,謝謝你的回覆。該解決方法正在工作:)我希望GWT-OL的人會發現這個問題的原因。 – Imreking