Bergen88
Bergen88

Reputation: 177

Polygon highlighting with Mapbox or Leaflet

I am trying to replicate polygon highlighting on mouseover event in mapbox.js or leaflet.js similar to the example below:

http://projects.nytimes.com/census/2010/explorer?view=raceethnicity&lat=40.6311&lng=-73.994&l=12

How does this work?

Upvotes: 0

Views: 1430

Answers (2)

Sushant Bindra
Sushant Bindra

Reputation: 63

You can create a per-feature hover effect by using events and feature states of Mapbox GL JS.

Follow this link for implementation!

Upvotes: 0

Alexandru Pufan
Alexandru Pufan

Reputation: 1912

Using Leaflet, you simply have to define a function to set the style of the polygon on mouseover event. For example:

polygonLayer.on('mouseover', function (this) {
    this.setStyle({
        fillOpacity: 0,
        color: 'black'
        });
});

Upvotes: 1

Related Questions