Hi all,
I am seeing an interesting issue when trying to use a WFSLayer. This is not returning the name field in the response. Is this a reserved word or am I missing something else?
An example call to our endpoint: https://ugs-geoserver-prod-flbcoqv7oa-uc.a.run.app/geoserver/groundwater/ows?service=WFS&version=1.0...
See below for a code sample:
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />
<title>WFSLayer | Sample | ArcGIS Maps SDK for JavaScript 4.30</title>
<style>
html,
body,
#viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
</style>
<link rel="stylesheet" href="https://js.arcgis.com/4.30/esri/themes/light/main.css" />
<script src="https://js.arcgis.com/4.30/"></script>
<script type="module" src="https://js.arcgis.com/calcite-components/2.8.5/calcite.esm.js"></script>
<link rel="stylesheet" type="text/css" href="https://js.arcgis.com/calcite-components/2.8.5/calcite.css" />
<script>
require([
"esri/Map",
"esri/views/MapView",
"esri/layers/WFSLayer",
"esri/layers/ogc/wfsUtils",
"esri/widgets/LayerList"
], function (Map, MapView, WFSLayer, wfsUtils, LayerList) {
let wfsCapabilities;
// set up map and view
const map = new Map({
basemap: "gray-vector"
});
const view = new MapView({
container: "viewDiv",
map: map,
center: [-112, 39.5],
zoom: 7,
});
// create and add a WFSLayer to the map
const layer = new WFSLayer({
url: "https://ugs-geoserver-prod-flbcoqv7oa-uc.a.run.app/geoserver/groundwater/ows", // url to your WFS endpoint
name: "groundwater:ugs_gw_sites", // name of the FeatureType
popupTemplate: {
title: "{site_name}",
content: "this should be a name: {name}, projectId: {projectId}, siteId: {siteId}"
}
});
map.add(layer);
view.ui.add(
new LayerList({
view: view
}),
"bottom-left"
);
});
</script>
</head>
<html lang="en">
<body>
<div id="viewDiv"></div>
</body>
</html>
https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#outFields
If you are going to make your own PopupTemplate, you need to define the outFields property. This is an array of fields that the popup will need to access to properly construct your popup.
the outFields was set on the wfsLayer as ["*"]. It seems as though that field/column gets lost when moves to the layerview. I see the attribute in the call to get the json from the endpoint.