El servicio de capa de mapa base proporciona un número de estilos de capas de mapa base tales como topográfico, calles e imágenes que puede usar en sus mapas.
En este ejercicio usará los widgets BasemapGallery y BasemapToggle para seleccionar y mostrar diferentes capas de mapa base.
require, agregue los módulos BasemapToggle, BasemapGallery y Expand.
```html## Alterne entre mapas base
Una forma sencilla para habilitar la selección entre dos mapas base es usar el widget **Basemap Toggle**. Use el widget para alternar entre los mapas base `arcgis-topographic` y `arcgis-imagery`.
3. Cree un **Basemap Toggle** y establezca la vista.
```javascript
const view = new MapView({
map: map,
center: [-74.090923, 4.694939],
zoom: 11,
container: "viewDiv"
});
const basemapToggle = new BasemapToggle({
view: view,
nextBasemap: "arcgis-imagery"
});
bottom-right) de la vista view.
const basemapToggle = new BasemapToggle({
view: view,
nextBasemap: "arcgis-imagery"
});
/* BLOQUE AGREGADO */
view.ui.add(basemapToggle,"bottom-right");
/* FIN BLOQUE AGREGADO */
También puede usar el widget BasemapGallery para seleccionar diferentes mapas base. En este ejercicio se usará el widget Expand para incluir la galería en un botón y mantener una interfaz más limpia.
BasemapGallery.
view.ui.add(basemapToggle,"bottom-right");
/* BLOQUE AGREGADO */
const basemapGallery = new BasemapGallery({
view: view
});
/* FIN BLOQUE AGREGADO */
Expand y establezca las propiedades view, content y autoCollapse como view, basemapGallery y true respectivamente.
const basemapGallery = new BasemapGallery({
view: view
});
/* BLOQUE AGREGADO */
const bgExpand = new Expand({
view: view,
content: basemapGallery,
autoCollapse: true
});
/* FIN BLOQUE AGREGADO */
Expand a la esquina superior derecha (top-right) de la vista view.
const bgExpand = new Expand({
view: view,
content: basemapGallery,
autoCollapse: true
});
/* BLOQUE AGREGADO */
view.ui.add(bgExpand, "top-right");
/* FIN BLOQUE AGREGADO */
Agregue su documento al servidor web de su preferencia y visualice el resultado en un navegador web.