Leaflet: set the click tolerance around a marker o a line

Created on 18 May 2014  路  5Comments  路  Source: Leaflet/Leaflet

Hi,
is there a way to expand around a marker (or a line) the area that responds to the mouse click? A sort of a pixels buffer around?

It's too narrow for a geojson line object.

Thank you very much,

Andrea

feature

Most helpful comment

For other finding this issue, Makina Corpus' plugin AlmostOver might be of help to you: https://github.com/makinacorpus/Leaflet.AlmostOver

All 5 comments

Currently no, as line events are handled by the SVG events implementation. I think we can add this as an option for the master version though (when using the Canvas renderer).

For other finding this issue, Makina Corpus' plugin AlmostOver might be of help to you: https://github.com/makinacorpus/Leaflet.AlmostOver

@perliedman thank you very much

I'll also add that it can be a pain for a GeoJSON line feature to register a "click" on touch devices. While AlmostOver is nice, it would be great if there could be a great tolerance for click events on lines for touch devices.

FWIW, I've also made this plugin to solve this problem: https://github.com/perliedman/leaflet-touch-helper

@pmacMaps I'll ponder over if there's something I can do in that plugin to help with the GeoJSON use case you mention.

Was this page helpful?
0 / 5 - 0 ratings