leaflet-touch-helper icon indicating copy to clipboard operation
leaflet-touch-helper copied to clipboard

Does not seem to be working with the current Leaflet

Open nekromoff opened this issue 4 years ago • 10 comments

No error is shown in the console.

nekromoff avatar Feb 13 '21 13:02 nekromoff

I've just implemented it and it seems to work fine for me, can you provide your implementation?

mjefim avatar Mar 14 '21 07:03 mjefim

SVG renderer is used, not a canvas one.

nekromoff avatar Mar 14 '21 09:03 nekromoff

I am using the default renderer, which if I'm not mistaking is an SVG renderer?

mjefim avatar Mar 14 '21 10:03 mjefim

Unfortunately, I don't have the code I was testing with as I have made many changes since then. But, just the basic example does not work:

L.path.touchHelper(core.paths["5-7717142810"]).addTo(map);
Uncaught TypeError: path is undefined
    initialize http://xxxx/js/leaflet-touch-helper.js:10
    i http://xxxx/js/leaflet.js:5
    touchHelper http://xxxx/js/leaflet-touch-helper.js:59
    <anonymous> debugger eval code:1

changing to L.Path does not work either

nekromoff avatar Mar 14 '21 11:03 nekromoff

I am using the following leaflet extensions:

  <script src="/js/leaflet.js"></script>
        <script src="/js/leaflet.markercluster.js"></script>
        <script src="/js/easy-button.js"></script>
        <script src="/js/leaflet.markercluster.layersupport.js"></script>
        <script src="/js/leaflet.textpath.js"></script>
        <script src="/js/leaflet-touch-helper.js"></script>

The polyline I am trying to add touchHelper to does not use clustering, but is added to a layer.

nekromoff avatar Mar 14 '21 11:03 nekromoff

Another testing and no error is shown in the console, but no touch thickness is added either:

L.path.touchHelper(core.paths["5-909582178"], {
                extraWeight: 50
            }).addTo(map);

nekromoff avatar Mar 14 '21 11:03 nekromoff

Maybe more info related: I am declaring layers like this: core.layers.layer5 = L.layerGroup();

nekromoff avatar Mar 14 '21 11:03 nekromoff

I see we are using different technologies, I am on ASP.NET Core MVC implementing layers using geoJSON (leaflet 1.7.1). Here is my snippet of the code in question.

L.geoJSON(geoJsonData, {
        onEachFeature: function (feature, item) {
            L.path.touchHelper(item, { extraWeight: 10 }).addTo(map);
        },
    }).addTo(map);

mjefim avatar Mar 14 '21 14:03 mjefim

I'll try that and report. Thanks.

nekromoff avatar Mar 14 '21 19:03 nekromoff

The solution proposed does not work with Leaflet.TextPath plugin, so no use to me, but thanks. As this plugin is quite old, I would say it's incompatible.

nekromoff avatar Oct 16 '23 10:10 nekromoff