Easiest way to add Vector Tile Basemaps to default Basemap Gallery Widget

988
6
Jump to solution
07-26-2018 07:58 AM
JohnMDye
Regular Contributor

The Basemap Gallery Widget in JS API 4.8 does not include the Esri Vector Basemaps by default. I couldn't find an easy way to add the Vector Basemaps in Esri's Vector Basemaps Group on ArcGIS Online to the Basemap Gallery Widget. Does anyone know of an easy way to cherry pick the Vector Basemaps in this group and add them to the default Basemap Gallery Widget so that the Vector Basemaps appear alongside the traditional raster Basemaps in the widget?

0 Kudos
1 Solution

Accepted Solutions
BjornSvensson
Esri Regular Contributor

By default the Basemap Gallery will use the basemap group of your organization. This can be changed in the organization "Settings->Maps->Basemap Gallery" where you can opt in to use the Esri vector basemaps.

Using the API you can use any other group of webmaps by setting the source of the BasemapGallery widget.
https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery.html#sourc... 

Check out this Codepen sample.

For best experience, make sure all the basemap have the same spatialreference.

View solution in original post

6 Replies
BjornSvensson
Esri Regular Contributor

By default the Basemap Gallery will use the basemap group of your organization. This can be changed in the organization "Settings->Maps->Basemap Gallery" where you can opt in to use the Esri vector basemaps.

Using the API you can use any other group of webmaps by setting the source of the BasemapGallery widget.
https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery.html#sourc... 

Check out this Codepen sample.

For best experience, make sure all the basemap have the same spatialreference.

JohnMDye
Regular Contributor

Great example. Thanks Ben. So, to ensure I understand, if I want to cherry pick vector base maps, then I need to create a group in my Portal that contains the specific basemaps I want to add. Gosh, that seems kind of weird for the JSAPI. I was expecting I could just pass an array of item ids or source URLs to the widget and it would add them alongside the default Esri Raster basemaps. 

0 Kudos
BjornSvensson
Esri Regular Contributor

There's no option for ad-hoc adding, but if you don't like using a group (PortalBasemapsSource), you could also create the list on the client using LocalBasemapsSource. You would then add both raster and vector basemaps.

One benefit of the PortalBasemapsSource option is that it gives you an easy way of controlling the set of basemaps using the "group" without having to update your actual application code.

As a side note, if you add both raster and vector basemap for users to pick between with, they might get confused since the basemap names are the same. The vector basemaps are supposed to be used instead of (not together with) the raster basemaps.  Out of curiosity, what's your specific need for showing users both raster and vectors?

/Bjorn

0 Kudos
JohnMDye
Regular Contributor

Thanks Bjorn. Use case to mix and match basemap types - I want to use Vector Maps exclusively except for World Imagery and World Imagery with Labels. Obviously, those are going to be Raster. 

0 Kudos
BjornSvensson
Esri Regular Contributor

Then you don't need to do any of this...

When your organization opts in to vector, that only means replace those raster that have vector equivalents. It doesn't drop world imagery etc to make it vector-only.

JohnMDye
Regular Contributor

oOo

0 Kudos