2

GWT-Openlayers を使用しており、マップに WMS レイヤーを追加したいと考えています。コードは次のとおりです。

    ...
    MapOptions defaultMapOptions = new MapOptions();
    defaultMapOptions.setNumZoomLevels(7);

    //Create a MapWidget
    MapWidget mapWidget = new MapWidget("700px", "700px", defaultMapOptions);

    GoogleV3Options gSatelliteOptions = new GoogleV3Options();
    gSatelliteOptions.setIsBaseLayer(true);
    gSatelliteOptions.setType(GoogleV3MapType.G_SATELLITE_MAP);
    GoogleV3 gSatellite = new GoogleV3("Google Satellite", gSatelliteOptions);

    mapWidget.getMap().addLayer(gSatellite);

    //Create a WMS layer as base layer
    WMSParams wmsParams = new WMSParams();
    wmsParams.setFormat("image/png");
    wmsParams.setLayers("topp:tasmania_state_boundaries");
    wmsParams.setStyles("");
    wmsParams.setParameter("transparent", "true");

    //create a WMS layer
    WMSOptions wmsLayerParams = new WMSOptions();
    wmsLayerParams.setUntiled();
    wmsLayerParams.setTransitionEffect(TransitionEffect.RESIZE);
    wmsLayerParams.setIsBaseLayer(false);

    String wmsUrl = "http://demo.opengeo.org/geoserver/wms";

    final WMS wmsLayer = new WMS("Basic WMS", wmsUrl, wmsParams,
                                 wmsLayerParams);

    //Add the WMS to the map
    Map map = mapWidget.getMap();
    map.addLayer(wmsLayer);

    //Lets add some default controls to the map
    map.addControl(new LayerSwitcher()); //+ sign in the upperright corner to display the layer switcher
    map.addControl(new OverviewMap()); //+ sign in the lowerright to display the overviewmap
    map.addControl(new ScaleLine()); //Display the scaleline
    map.addControl(new MousePosition()); 

    //Center and zoom to a location
    LonLat lonLat = new LonLat(146.7, -41.8);
    lonLat.transform(new Projection(ProjectionCode.LONGLAT.getEpsgCode()).getProjectionCode(),
            map.getProjection()); //transform lonlat to OSM coordinate system
    map.setCenter(lonLat, 6);
    ...

このサイトで見つけたサンプル コードを使用しました: http://demo.gwt-openlayers.org/gwt_ol_showcase/GwtOpenLayersShowcase.html

wmsUrl はデモ サイトを指しているので、誰でも試すことができます。

問題は、最も外側のズーム レベルにズームアウトしたときにのみ WMS レイヤーが表示されることです。ズームインしようとすると、再び消えます。何か案が?

4

2 に答える 2

1

私は設定を見つけました:

wmsLayerParams.setDisplayOutsideMaxExtent(true);

しかし、真の値がデフォルトではない理由がわかりません...

于 2013-09-05T11:33:12.537 に答える
1

ズームレベルが正しく設定されていないようです。ズーム レベルの範囲は 6 ~ 7 のみです。最大を定義しました。7defaultMapOptions.setNumZoomLevels(7);にズームし、ズーム レベル 6 でマップを中央に配置しました。map.setCenter(lonLat, 6);したがって、マップはズーム レベル 6 と 7 の間でのみ表示されsetNumZoomLevelsます。より高い値に増やすと役立つ場合があります。

于 2016-09-02T11:35:57.947 に答える