A Leaflet plugin for creating a "highlight" effect on features near the user's cursor.
Leaflet >= 1.1.0
turf.js >= 5.1.6
npm i leaflet-spotlight
Import the library into your HTML document. Make sure that it is imported AFTER Leaflet and turf.js
Detailed examples for various use cases can be found in the examples folder.
How it works (generally)
The plugin enables an
L.Map object to manage new
L.Spotlight objects, which are linked to an
L.Layer object in the map. You as the developer must define a function which receives a receives an
L.latlng (which will be the user's mouse cursor), and constructs from it a
turf.js Polygon. You also must specify either an
L.Style object or a function which returns one, which will indicate how to draw the features which are contained within the spotlight area. You can also specify the style of the spotlight on the map itself.