Hi,
I am trying to add basemap with different projections to my map while map load.
baseLayer = new TileLayer({ url: baseMapService.MapServiceURL });
var myBasemap = new Basemap({
baseLayers: [baseLayer ],
thumbnailUrl: baseMapService.MapServiceURL + '/info/thumbnail',
title: 'My custom basemap', id: 'my_custom_basemap' });
map.basemap = myBasemap
The above code works fine when the base map projection is similar to the projection of base map gallery. But does not work with different projection.
Any idea.
Thanks
Aditya Kumar
Solved! Go to Solution.
@UndralBatsukh I just managed to solve it by changing the mapview projection to basemap projection.
if(view.spatialrefrence != basemap.spatialrefrence)
{
view.spatialrefrence = basemap.spatialrefrence;
}
Hi there,
I am not sure what issue you are running into. Can you please explain the problem bit more in detail? If you are using 4.23 and later, you can change spatialReference of the MapView at runtime. Here are the details how it works: https://developers.arcgis.com/javascript/latest/4.23/#basemaps-with-different-spatial-references
Hi @UndralBatsukh ,
Thanks for the response. I am trying to add a custom basemap to the map on map load. Below is the code I am using for same.
baseLayer = new TileLayer({ url: baseMapService.MapServiceURL });
var myBasemap = new Basemap({
baseLayers: [baseLayer ],
thumbnailUrl: baseMapService.MapServiceURL + '/info/thumbnail',
title: 'My custom basemap', id: 'my_custom_basemap' });
map.basemap = myBasemap
But on map load the basemap is not loading.Its coming without a basemap.
Thanks
Aditya Kumar
It is hard to suggest things to try without a repro case. What happens if you set the basemap in the map constructor?
It is blank perhaps because your TileLayer cannot be reprojected to the spatialReference of the view.spatialReference. The server must be able to reproject the TileLayer to match the spatialReference of the view.
@UndralBatsukh Exactly. I am getting a blank basemap because the basemap is not getting reprojected
TileLayer needs to be reprojected on the server. If the server does not support the projection of the mapview then nothing will be displayed.
@UndralBatsukh I just managed to solve it by changing the mapview projection to basemap projection.
if(view.spatialrefrence != basemap.spatialrefrence)
{
view.spatialrefrence = basemap.spatialrefrence;
}