1.WMS
https://ip地址/arcgis/services/图层名称/MapServer/WMSServe
a.查看WMS服务信息
https://ip地址/arcgis/services/图层名称/MapServer/WMSServe?Service=WMS&Request=GetCapabilities
2.WFS
https://ip地址/arcgis/services/图层名称/MapServer/WFSServe
a.查看WFS服务信息
https://ip地址/arcgis/services/图层名称/MapServer/WFSServe?Service=WFS&Request=GetCapabilities
b.执行查询
c.过滤参数filter的使用(属性过滤)
Filter=
<Filter xmlns="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml"> //构建数据过滤条件的根元素
<PropertyIsEqualTo> //条件元素
<PropertyName>OBJECTID</PropertyName> //指定要进行比较的字段名称
<Literal>51</Literal> //指定与字段进行比较的字面值
</PropertyIsEqualTo>
</Filter>
封装请求地址
//参数分别为wfs服务名称,请求图层名称,过滤比较字段,字段对应的值
buildWFSRequest (wfsName,typeNames,propertyName,propertyValue) {
axios
.get(
`https://${ip}/arcgis/services/${wfsName}/MapServer/WFSServer`,
{
dataType: 'jsonp',
jsonpCallback: 'getJson',
params: {
Service: 'WFS',
Request: 'GetFeature',
typenames: typeNames,
outputFormat: 'geoJSON',
filter: `<Filter xmlns="http://www.opengis.net/ogc">
<PropertyIsEqualTo>
<PropertyName>${propertyName}</PropertyName>
<Literal>${propertyValue}</Literal>
</PropertyIsEqualTo>
</Filter>`
}
}
)
.then((response) => {
console.log(response.data, 'filterData')
})
.catch((error) => {
console.log(error)
})
},
d.过滤参数filter的使用(空间过滤)
其中posList的内容为围成范围点集的x、y坐标组成.例如(x1,y1),(x2,y2),(x3,y3)三点围成的范围,则posList的内容为x1,y1,x2,y2,x3,y3
filter=`<Filter xmlns="http://www.opengis.net/ogc">
<Within>
<PropertyName>SHAPE</PropertyName>
<gml:Polygon srsName="EPSG:4547">
<gml:exterior>
<gml:LinearRing>
<gml:posList>466274.7299642606, 2525983.8824574836,488796.877278766, 2495022.7858061926,508177.64520696853, 2501637.382368719,466274.7299642606, 2525983.8824574836,</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
</Within>
</Filter>`
封装请求地址
areaWFSRequest (wfsName, typeNames, areaArray) {
axios
.get(
`https://${ip}/arcgis/services/SZSW/${wfsName}/MapServer/WFSServer`,
{
dataType: 'jsonp',
jsonpCallback: 'getJson',
params: {
Service: 'WFS',
Request: 'GetFeature',
typenames: typeNames,
outputFormat: 'geoJSON',
maxfeatures:100, //限制请求的最大数
filter: `<Filter xmlns="http://www.opengis.net/ogc">
<Within>
<PropertyName>SHAPE</PropertyName>
<gml:Polygon srsName="EPSG:4547">
<gml:exterior>
<gml:LinearRing>
<gml:posList>466274.7299642606, 2525983.8824574836,488796.877278766, 2495022.7858061926,508177.64520696853, 2501637.382368719,466274.7299642606, 2525983.8824574836,</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
</Within>
</Filter>`
}
}
)
.then((response) => {
console.log(response.data, 'filterData')
})
.catch((error) => {
console.log(error)
})
},