我是ArcGIS API Javascript的新手,我有通过WFS图层编辑特征图层的任务。问题是我不知道如何使用WFS图层显示地图。请帮忙!
答案 0 :(得分:0)
您需要使用WFSLayer
将WFS服务添加到地图中。以下是ESRI提供的示例。看看吧。
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/>
<title>WFS Layer</title>
<link rel="stylesheet" href="https://js.arcgis.com/3.18/esri/css/esri.css">
<style>
html, body, #map {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
</style>
<script src="https://js.arcgis.com/3.18/"></script>
<script>
var map;
require(["esri/map", "esri/InfoTemplate","esri/layers/WFSLayer", "esri/config", "dojo/domReady!"], function(Map, InfoTemplate, WFSLayer, esriConfig) {
map = new Map("map", {
basemap: "topo",
center: [-121.936, 37.346],
zoom: 10
});
var layer = new WFSLayer();
var opts = {
"url": "http://www.hcpmaps.com:8080/geoserver/HCP/wfs",
"version": "1.1.0",
"name": "citylimits",
"wkid": 3857,
"maxFeatures": 100
};
esriConfig.defaults.io.proxyUrl = "/sproxy/";
layer.fromJson(opts);
map.addLayer(layer);
});
</script>
</head>
<body>
<div id="map"></div>
</body>
</html>
更新:使用不同的wfs服务进行更新。