If I understand your question correctly, you want different behaviour on devices with touchscreen capabilities: no tooltip shown on such devices.
WRONG ANSWER: For this you can use touch
property of L.Browser
namespace. Property L.Browser.touch
is set to true
for touchscreen devices.
Your code could be something like:
...
pointToLayer: function (feature, latlng) {
var marker = L.marker(latlng, {icon: iubyt});
if (L.Browser.touch)
return marker;
else
return marker.bindTooltip(feature.properties.name);
...
EDIT (correct answer): In above answer I was obviously a little bit naïve in my assumptions. @MarcelWaldvogel is right in his comment, L.Browser.touch
is set to true
in all browsers supporting touch events, which effectively means ALL browsers. As such L.Browser.touch
property is practically useless.
To correctly test for device touch capabilities, one of classic JS DOM tests has to be used. Here is one (tested):
function Is_touch_device() {
return (('ontouchstart' in window)
|| (navigator.MaxTouchPoints > 0)
|| (navigator.msMaxTouchPoints > 0));
}