Select to view content in your preferred language

Basemap with different projection

949
6
Jump to solution
05-04-2023 06:01 AM
ADITYAKUMAR1
Occasional Contributor III

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

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
ADITYAKUMAR1
Occasional Contributor III

@UndralBatsukh I just managed to solve it by changing the mapview projection to basemap projection.

if(view.spatialrefrence != basemap.spatialrefrence)

{

view.spatialrefrence = basemap.spatialrefrence;

}

View solution in original post

0 Kudos
6 Replies
UndralBatsukh
Esri Regular Contributor

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

 

0 Kudos
ADITYAKUMAR1
Occasional Contributor III

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

0 Kudos
UndralBatsukh
Esri Regular Contributor

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. 

0 Kudos
ADITYAKUMAR1
Occasional Contributor III

@UndralBatsukh Exactly. I am getting a blank basemap because the basemap is not getting reprojected

0 Kudos
UndralBatsukh
Esri Regular Contributor

TileLayer needs to be reprojected on the server. If the server does not support the projection of the mapview then nothing will be displayed. 

ADITYAKUMAR1
Occasional Contributor III

@UndralBatsukh I just managed to solve it by changing the mapview projection to basemap projection.

if(view.spatialrefrence != basemap.spatialrefrence)

{

view.spatialrefrence = basemap.spatialrefrence;

}

0 Kudos