var template=new esri.InfoTemplate("My Title","${*}");
var template=new esri.dijit.PopupTemplate({ title: result.layerName, fieldInfos: [{ fieldName: "*",visible: true}] });
Fui,
Sorry for the confusion. The PopupTemplate in 4.x does not have a description property it has a content property
So it would be:
var template = new PopupTemplate({
title:"Marriage in NY, Zip Code: {ZIP}",
content: "{*}"
});
I tried with the sandbox and it works without the loop. Thank you so much Robert!
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
<title>Intro to PopupTemplate - 4.8</title>
<style>
html,
body,
#viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
</style>
<link rel="stylesheet" href="https://js.arcgis.com/4.8/esri/css/main.css">
<script src="https://js.arcgis.com/4.8/"></script>
<script>
require([
"esri/Map",
"esri/PopupTemplate",
"esri/layers/FeatureLayer",
"esri/views/MapView",
"dojo/domReady!"
], function(
Map,
PopupTemplate,
FeatureLayer,
MapView
) {
// Create the map
var map = new Map({
basemap: "gray"
});
// Create the MapView
var view = new MapView({
container: "viewDiv",
map: map,
center: [-73.950, 40.702],
zoom: 11
});
var template = { // autocasts as new PopupTemplate()
title: "Marriage in NY, Zip Code: {ZIP}",
content: "{*}"
};
// Reference the popupTemplate instance in the
// popupTemplate property of FeatureLayer
var featureLayer = new FeatureLayer({
url: "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/ArcGIS/rest/services/NYCDemographics1/FeatureServer/0",
outFields: ["*"],
popupTemplate: template
});
map.add(featureLayer);
});
</script>
</head>
<body>
<div id="viewDiv"></div>
</body>
</html>
Sorry to ask you this late after you last answer, any idea why this doesnt work on 4.16 ?
Thanks,
Julien REME this is not implemented in the 4.x API. It was taken out at 4.12. I can confirm it is not present in 4.17 either which is coming in the fall. Hopefully it will return for 4.18 or 4.19. For now, you have to implement this yourself such as with code in these comments.
https://community.esri.com/thread/239435-412-popup-changes-why-and-what-now#comment-943951