I have a map service published through ArcGIS Server. The map service has 3 layers and the layers have sublayers. I am trying to transition from Esri's JSAPI 3.x to 4.x. In 3.x, I used to call a ArcGISDynamicMapServiceLayer and use layer.setInfotemplates to add popups to the map. I have a few layers, so I do not want to use feature layer to create popups for the sake of performance.
Can I call popups using MapImageLayer in JS API 4.x?
The codes I used in 3.x is as follow:
var popupTemplate = new PopupTemplate({ "title": "Row Flags", fieldInfos: [ {fieldName: "GPS_Date", visible: true, label: "Date Collected", format: {dateFormat: "shortDate"}}, {fieldName: "GNSS_Heigh", visible: true, label: "Z-value"}, {fieldName: "Feature_Description", visible: true, label: "Description"} ] });
var dynamicLayer = new ArcGISDynamicMapServiceLayer("https://RESTURLEndpoints", { "imageParameters": imageParameters, opacity: 1 }); dynamicLayer.setInfoTemplates({ 1: {infoTemplate: popupTemplate}, 2: {infoTemplate: popupTemplate2}, 4: {infoTemplate: popupTemplate3}, 5: {infoTemplate: popupTemplate4}, 7: {infoTemplate: popupTemplate5}, 8: {infoTemplate: popupTemplate6}, 9: {infoTemplate: popupTemplate7}, 10: {infoTemplate: popupTemplate8} });
Thanks,
Solved! Go to Solution.
Saroj,
Sure just set the template on the sublayer:
var layer = new MapImageLayer({
url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer",
sublayers: [{
id: 0,
popupTemplate: {
title: "{COUNTY}",
content: "{POP2007} people lived in this county in 2007"
}
}]
});
Saroj,
Sure just set the template on the sublayer:
var layer = new MapImageLayer({
url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer",
sublayers: [{
id: 0,
popupTemplate: {
title: "{COUNTY}",
content: "{POP2007} people lived in this county in 2007"
}
}]
});
Thank you Robert.
Hi,
Try to use IdentifyTask for generating popup for mapimagelayer.
https://developers.arcgis.com/javascript/latest/sample-code/sandbox/?sample=identify
Hi,
Try to use IdentifyTask for generating popup for mapimagelayer.
https://developers.arcgis.com/javascript/latest/sample-code/sandbox/?sample=identify