I had problems when I needed to add some of the Leaflet plugins, not to one specifical map, or all Leaflet maps on my Website, but specific groups. For example, to only specified content types or specific pages.
In order to get this to work as expected, you’ll need to include all libraries that the plugin needs. You can find all of them on the official Leaflet Website.
So let’s start, here are the plugins I`ve installed on my Leaflet maps:
Mini-map is a plugin which allows us to see a minimized version of the map with our position on it, while users can simultaneously see the rest of the map in standard size. Usually a different layer is used for Mini-map, in order to see the difference between it and the main map. All code I’ll present to you is pure JavaSript. Code for the feature described above:
In the previous code, we have positioned the Mini-map on the top left side of our map and minimized it by default on page load. That Mini-map will be presented only on the Leaflet maps that are on pages which include ‘your_string’ as the value in URL.
Measure control is another very usefull Leaflet plugin that helps us measure distance between two points on the map. It uses nanometer as the unit of length. The code for it:
Full screen is probably one of the most used plugins. It’s purpose is very simple, and as the name says, it gives us the opportunity to see the map in full screen and later to exit it. Code:
Another interesting plugin. It provides coordinates of the current Mouse position on the map. Code:
This part of code displays Mouse position coordinates in Latitude and Longitude with 2 decimals, positioned in the bottom left side of the map.
One of the features that is also available is Double-click on the Leaflet map. It opens the content we specify ( by double-clicking on it ). Following part of the code defines this feature:
The result is presented in the picture below.
More about Leaflet you can find here: