Select to view content in your preferred language

Map.setBasemap function doesn't work as expected

3116
3
Jump to solution
05-11-2015 07:53 AM
fuliaoli
Deactivated User

I use Map.setBasemap function to change the basemap. The basemap is changed, but it changes back to the default if I pan and zoom out the map.  Is there a way to solve it, instead of use basemap gallery?

Thanks in advance,

li

0 Kudos
1 Solution

Accepted Solutions
fuliaoli
Deactivated User

Thanks for your quick response.

There is not much code at all.

I declare a function and use a menu item to pass basemap name. That's it.

It seems to me that the default map object doesn't get swopped.

var selectBasemap = function(basemapId) {

  if (cwiMap.map.getBasemap() != basemapId) {

   cwiMap.map.setBasemap(basemapId);

  }

};

Regards,

li

View solution in original post

3 Replies
TimWitt2
MVP Alum

Can you show us your code? It is hard to trouble shoot without seeing any code.

fuliaoli
Deactivated User

Thanks for your quick response.

There is not much code at all.

I declare a function and use a menu item to pass basemap name. That's it.

It seems to me that the default map object doesn't get swopped.

var selectBasemap = function(basemapId) {

  if (cwiMap.map.getBasemap() != basemapId) {

   cwiMap.map.setBasemap(basemapId);

  }

};

Regards,

li

fuliaoli
Deactivated User

My bad. I reset the default according to the current extent and forgot it.