There is an issue with zooming (effectiveLods in MapView.constraints is null) when using WMTS as a basemap. The metadata from the WMTS is converted into TileInfo, but it’s stored in an undocumented property called tilemapCache. However, this TileInfo object is not applied to MapView.constraints.lods, which causes improper handling of LODs during map rendering and zooming.
According to the MapView documentation (section Zoom and LODs) https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html effectiveLODs will be null if the basemap doesn’t have tileInfo. However, WMTS services do have TileInfo (calculated from their metadata - TileMatrixSet), so effectiveLODs should not be null.
Referring to this page
https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html
Chapter Zoom and LODs
the effective LODs will be null in these cases
The MapView'sconstraints.effectiveLODswill benullif the following statements are true:
- The map doesn't have abasemap, or
- the basemap does not have aTileInfo,
- AND the first layer added to the map does not have aTileInfo.
If the effectiveLODs are null, it is not possible to set zoom on the MapView because the conversion is not possible. The zoom value will be -1 in this case. Setting scale will work. To address this, the MapView's constraints.lods can be defined at the time of its initialization by calling TileInfo.create().lods.
I tested that:
const view = new MapView({
container: "mapViewDiv",
map,
constraints: constraints,
popup: {},
popupEnabled: false,
highlightOptions: {
color: new Color({
r: 0,
g: 158,
b: 247,
a: 1 // Optional
}),
haloOpacity: 0.9,
fillOpacity: 0.6
}
});
const lodsCreated = TileInfo.create({
// create the LODs to match the spatial reference of the view
spatialReference: view.spatialReference
}).lods;
view.constraints.lods = lodsCreated;
After that we receive:
const effectiveLODs = view.constraints.effectiveLODs; // -> 14 LODs
const LODs = view.constraints.lods; // -> 24 LODs
A an alternative you could put LODs by hand (as const) since they are kind of hart coded on ESRI side:
https://developers.arcgis.com/documentation/mapping-and-location-services/reference/zoom-levels-and-...
There you can see that the conversion tool distinghuishes between LODs for Image tile layers and LODs for Vector tile layers. The scale of the same LOD on image tile layers is twice the value on the devider side as for vector tile layers.
Sample:
Zoom level: 13
Vector: 1 : 36111.909643
Image: 1 : 72223.819286