Base Groups
1. Base Groups
Similar to how we added overlay groups, we can add base map groups to allow our users to toggle between different maps. Unlike overlay groups, only one base group may be selected at a time.2. Base Groups and Multiple Map Tiles
To add multiple base groups, we need to call addProviderTiles() one time for each base map we want to make available to our users. For example, to add the OSM, CartoDB, and Esri tiles we could do the following. That's a nice map, but how do we change the base maps?3. Base Groups and Multiple Map Tiles
Just like when adding multiple overlay groups, we need to include a call to addLayersControl() in our chain of functions to give our users the ability to toggle between different base maps. Otherwise, the last map tile that we add will be the only one that our users can see. That is a nice splash of color in the Esri map after using our greyscale map for most of the course. Let's use our new knowledge of base groups to take a look at all of the Esri map tiles that are available in the leaflet package.4. Exploring Esri Base Maps
It can be handy to add a few base maps during an exploratory analysis to see how different markers appear on various map tiles. Using base groups, we can accomplish this with a single leaflet map, like this one that displays the 11 Esri provider tiles included in the leaflet package. Feel free to experiment with different map tiles while you are working on the exercises in this chapter.5. Overlay and Base Groups
Putting all of these groups together takes a lot of code. Let's break it down into four steps. First, we initialize the leaflet htmlwidget. Then we add our three base maps with group names.6. Overlay and Base Groups
Then we add one marker layer for each sector with a corresponding group name. For each marker layer, we also apply our color palette and add the label argument. Lastly, we add our layer controls so our users can toggle both the base groups and the overlay groups on a single map.7. The Big Reveal
Here's the map we'll be making in the next set of exercises. In a relatively short period of time we have gone from mapping one state's colleges with a single color to creating a map of all American colleges that uses a color palette and provides several base and overlay groups.8. Let's practice!
Now it's your turn. Keep up the great work!Create Your Free Account
or
By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.