The TileLayer allows you to work with a cached map service and add it to a Map as a tile layer. A cached service accesses tiles from a cache instead of dynamically rendering images. Because they are cached, tiled layers render faster than MapImageLayers.
This sample shows how to add an instance of TileLayer from a portal to a WebMap in a MapView. The resulting polygon features can be clicked on to see the popup and the highlighted features.
How it works
After loading the TileLayer, find the layer of interest in the cached map service. Then create a PopupTemplate for one or more sublayers.
layer.load().then(() => {
const sublayer = layer.allSublayers.find((sublayer) => sublayer.title === "Eugene_OR_Zoning");
sublayer.popupTemplate = new PopupTemplate({
title: "{zonename}",
content: [{
type: "fields",
fieldInfos: [{
fieldName: "zonejuris",
label: "Juristiction"
},
{
fieldName: "zonecode",
label: "Code"
}
]
}]
});
})