testadaz
testadaz

Reputation: 49

Clickable area around linestring in mapbox GL js

I'm using mapbox GL js to display linestrings.

Those linestrings are clickable in order to display various information about the linstring in a popup using :

      new mapboxgl.Popup()
          .setLngLat(coordinates)
          .setHTML(popup)
          .addTo(map);

But I have the feeling that the clickable area where the popup is displayed is very narrow. It can even manage to display the popup everytime on the first clic...

Is there a way to enlarge this zone ? Thanks

Upvotes: 1

Views: 1101

Answers (1)

Steve Bennett
Steve Bennett

Reputation: 126777

A common work around I use is to create a second line layer underneath, with a line-opacity of 0.01 and a line-width of 10. Add the click handler onto that line instead.

Upvotes: 1

Related Questions