arcgisruntime for android 调用wms服务,只显示底图,不显示wms服务图层?

我用的编译工具是Android studio,加载的是廊坊四维墨卡托矢量的服务,底图加载的四维的全国地图,底图可以正常显示,戴氏,廊坊的wms服务无法显示。具体代码如下:

public class MainActivity extends AppCompatActivity {

    private MapView mMapView;

    private String wms_layer_url = "http://gis.internet.enn.cn/arcgis/services/LangFang0011_Map_MCT_D/MapServer/WMSServer?request=GetCapabilities&service=WMS";
    //private String wmts_url  = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/WorldTimeZones/MapServer/WMTS";amp;?request=GetCapabilities&service=WMS

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mMapView = (MapView) findViewById(R.id.mapview);

        //瓦片
        String strMapUrl="http://gis.enn.cn:8080/OneMapServer/rest/services/Map_CHINA_T/MapServer";
        ArcGISTiledLayer layerBaseMap = new ArcGISTiledLayer(strMapUrl);

        //设置切片图层作为底图
        Basemap basemap = new Basemap(layerBaseMap);

        Viewpoint vp = new Viewpoint(39.524,116.719,3);
        ArcGISMap map = new ArcGISMap(basemap);
        map.setInitialViewpoint(vp);
        mMapView.setMap(map);

        // 保存一个用于显示的唯一标识WMS层名称的列表2.0,18.0,3
        List<String> wmsLayerNames = new ArrayList<>();
        wmsLayerNames.add("0");

        // create a new WMS layer displaying the specified layers from the service
        WmsLayer wmsLayer = new WmsLayer(wms_layer_url, wmsLayerNames);

        // add the layer to the map
        map.getOperationalLayers().add(wmsLayer);

        wmsLayer.addDoneLoadingListener(new Runnable() {

            @Override
            public void run() {
                if (wmsLayer.getLoadStatus() == LoadStatus.LOADED) {
                    // work with WMS layer here
                }
            }
        });

    }

    @Override
    protected void onPause() {
        super.onPause();
        mMapView.pause();
    }

    @Override
    protected void onResume() {
        super.onResume();
        mMapView.resume();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mMapView.dispose();
    }

}

显示如下:
图片说明
我想要在红框位置显示我调用的wms服务,求助大神指点

2个回答

/ 保存一个用于显示的唯一标识WMS层名称的列表2.0,18.0,3
        List<String> wmsLayerNames = new ArrayList<>();
        wmsLayerNames.add("0");

        // create a new WMS layer displaying the specified layers from the service
        WmsLayer wmsLayer = new WmsLayer(wms_layer_url, wmsLayerNames);

wmsLayerNames.add("0"); 添加的String 必须是wms_layer_url服务里面图层的名字

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐