I am using the ESRI JS 4.24 API to create a mapping application that pulls in a Map Image Layer that is hosted on ArcGIS Portal. I am having trouble getting attributes to show in my pop-up. I would like to display all attributes in the pop-up, not just a select few.
According to documentation the
outFields: ["*"]
has been replaced with
defaultPopupTemplateEnabled: true
However, I am getting no content in my pop-up at the moment. Here's what I'm looking at currently:
Here is my code currently. Any suggestions?
require([
"esri/config",
"esri/WebMap",
"esri/views/MapView",
"esri/widgets/AreaMeasurement2D",
"esri/widgets/Compass",
"esri/widgets/Home",
"esri/widgets/LayerList",
"esri/widgets/ScaleBar",
"esri/widgets/Search",
"esri/widgets/BasemapToggle",
"esri/widgets/Legend",
"esri/widgets/Expand",
"esri/core/reactiveUtils",
"esri/widgets/Popup",
"esri/Map",
"esri/layers/MapImageLayer",
"esri/PopupTemplate",
], function (esriConfig, WebMap, MapView, AreaMeasurement2D,
Compass, Home, LayerList, ScaleBar, Search, BasemapToggle,
Legend, Expand, reactiveUtils, Popup, Map, MapImageLayer,
PopupTemplate) {
esriConfig.portalUrl = "PORTAL_URL";
const map = new Map({
basemap: "gray-vector"
});
const view = new MapView({
map: map,
container: "viewDiv",
center: [-95, 40],
zoom: 4,
});
let layer = new MapImageLayer({
portalItem: {
id: "1acc2c72f17f44b0bd47ca31f63c9a95",
},
});
map.add(layer);
layer.when(() => {
layer.allSublayers.forEach((sublayer) => {
sublayer.popupEnabled = true;
sublayer.popupTemplate = {
defaultPopupTemplateEnabled: true,
outFields: ["*"],
}
});
});
2 Answers 2
MapImageLayer does not support popup. As the documentation states:
MapImageLayer...exporting images instead of features
https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html
images do not hold features to be displayed in a popup. You might want to check FeatureLayer instead.
-
I am able to get pop-ups. The fields just need to be hard-coded.MoreMeowbell– MoreMeowbell2022年11月09日 00:24:47 +00:00Commented Nov 9, 2022 at 0:24
That's partly incorrect.
The popup is applied to the mapimagelayer sublayers. If you want to use the default popup template, you can do: MPl is a defined mapimagelayer
for (let sublayer of MPl.allSublayers) {
sublayer.popupEnabled = true;
}
Explore related questions
See similar questions with these tags.