ArcGIS for js 发布geoserver发布的wms服务
首先我们需要有一个geoserver发布的服务
虽然成功的用geoserver发布了服务,不过很多人还是找不到服务地址(包括我),所以我选择了一个折中的方式找到了服务地址
用openlayer的方式打开图层,打开开发者工具—网络,在这里可以找到服务地址
我的服务地址是http://localhost:8080/geoserver/myWorkpase/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&FORMAT=image/png&TRANSPARENT=true&STYLES&LAYERS=myWorkpase:古树名木-墨卡托&SRS=EPSG:102113&WIDTH=562&HEIGHT=768&BBOX=13364903.30089751,3493766.500208629,13407736.470473269,3552404.422194691
我们可以从地址中获取一个参数 LAYERS=myWorkpase:古树名木-墨卡托
var wmsLayer = new WMSLayer(“http://localhost:8080/geoserver/wms”, {
format: “png”,
resourceInfo: {
copyright: “GeoServer”,
description: “Africa Wind Data”,
extent: new Extent(-20037508.342787, -20037508.342787, 20037508.342787, 20037508.342787, { wkid: 102113 }),
featureInfoFormat: “text/html”,
getFeatureInfoURL: “http://localhost:8080/geoserver/ows”,
getMapURL: “http://localhost:8080/geoserver/ows”,
layerInfos: [
new WMSLayerInfo({
name: “myWorkpase:古树名木-墨卡托”,//命名空间:图层
title: “Mean annual generalized wind power density”,
queryable: true,
showPopup: true
})
],
spatialReferences: [102113],//坐标系
version: “1.3.0”
},
version: “1.3.0”,
visibleLayers: [
“myWorkpase:古树名木-墨卡托”//命名空间:图层
]
});
wmsLayer.on(“error”, function (response) {
console.log(“Error: %s”, response.error.message);
});
map.addLayer(wmsLayer, 10);
转载自:https://blog.csdn.net/qq_29176825/article/details/71123934