Changing Map type based on navigation toolbar button

2265
3
07-10-2012 08:07 AM
JohnMcleod1
New Contributor III
Hello Everyone,
I was wondering how to change the map type by clicking a navigation toolbar button.
I'm thinking of creating another web map with Aerial as a base map. Then, on click of button reloading the map with new aerial web map.
Is there an easier method?

Any help with this is greatly appreciated.

John
0 Kudos
3 Replies
Nicholas-Furness
Esri Regular Contributor
Hi John,

Have you looked at AGSWebMap::openIntoMapView:withAlternateBaseMap: and AGSWebMap::openIntoMapView:withAlternateBaseMap:resetMapView:?

If you have an AGSWebMap whose basemap layers you want to use, use the AGSWebMap::baseMap property to get an AGSWebMapBaseMap object, and pass that in to one of the above function on the AGSWebMap whose basemap you want to update.

Note, you could just use the stock basemaps (although Bing and OSM may be special cases) rather than creating your own.

Hope this helps, though I'm not 100% sure I understood your question.

Nick.
0 Kudos
JohnMcleod1
New Contributor III
Thanks for the reply.
It sounds like what I'm looking for.
Do you know of any examples using AGSWebMap::openIntoMapView:withAlternateBaseMap: and AGSWebMap::openIntoMapView:withAlternateBaseMap:resetMapView:?

John
0 Kudos
Nicholas-Furness
Esri Regular Contributor
Afraid not, so I wrote you one 🙂

For simplicity, I load up a few WebMaps ahead of time (you might want to do this on-the-fly in your app). I'll use these as basemap options. I'll also load up one WebMap with actual content. When the user picks a different basemap, I reference the content WebMap and the appropriate basemap WebMap.

The only additional trick is to store and set the extent "around" the basemap change, otherwise each basemap change returns the map view to the content WebMap's default (saved) extent.

I also don't initially set the basemap, but just rely on the "Content" basemap. You'd want to take care of that in a real app.

Hope this helps,

Nick.
0 Kudos