Greetings!
During my usage of subclasses of BaseTileLayer, I have found that some spatial references are not being handled appropriately, particularly when creating the mapView with a TileLayer.
I have included a codepen that illustrates this behaviour in a minimal application, you can comment out the code defining currentLayer:
// Custom TileLayer STARTS HERE
const currentLayer = new SimpleLayer({
urlTemplate: nztmBasemapTileTemplate,
});
// ENDS HERE
// TileLayer Definition STARTS HERE
const currentLayer = new TileLayer({
url: nztmBasemap,
});
// ENDS HERE
The console logs show the issue well. It seems that the spatial reference is not being detected by the Basemap and MapView from the customized TileLayer. This seems to be preventing appropriate display of the TileLayer.
All of the above seems to me to show a bug in BaseTileLayer.
As an aside, I did manange to get some more SpatialReference's working in the CustomTileLayer, by manually adding spatialReference and tileInfo to the constructor, but it seems to me that the map servers response should be digested such that the spatial reference and tile info are automatically instantiated.
See below what this would look like:
const spatialReference = new SpatialReference({ wkid : mapServerResponse.wkid });
new CustomTileLayer({
urlTemplate: urlTemplate,
spatialReference : spatialReference,
tileInfo: new TileInfo({ spatialReference: spatialReference }),
});
This works for fixing NZTM(2193), but failed to fix it for other spatial references. I presume this is because certain required parameters are not being added to the SpatialReference, TileInfo or other relevant properties on the TileLayer.
Couple of requests/suggestions from this:
- If I'm missing something that will make this work for CustomTileLayers, what is it?
- If there is a fix for this involving providing the right parameters to the Custom TileLayer to be able to handle all SpatialReferences, then having that documented somewhere / provided here, that would be mint!
Cheers,
Greg.