Giter Club home page Giter Club logo

Comments (8)

Raruto avatar Raruto commented on May 13, 2024

Commenting out this line fixes the initial crash, but I don't know what it's purpose is so I guess there may be other side effects to doing so?

That is the svg group (line + label + text) displayed when the mouse hovers the graph.

If there is existing GeoJSON data in the control and the clear() method is called, this error appears.

Could you also provide a concrete example? (in v1.0.6 i've fixed another problem related to empty draggings, but i havent found anything about what you say)

from leaflet-elevation.

britainbybike avatar britainbybike commented on May 13, 2024

Thanks for your prompt reply. I think I've figured it out - it's my own fault because I'm using your excellent control in a more "creative" way.

The _clearPath() method is failing in my instance, because the control is bound to an existing and more complex GeoJSON path layer (bound with addData()), not your default path created by the control using one of the methods like loadGeoJSON(). Therefore it appears the control is trying to hide a path that doesn't exist, or is incomplete..

The loop at line 93 It deletes a single layer successfully for the overlay (appears over the path when the chart is hovered over), but then fails on the next layer, which I presume is the path itself?

My workaround solution is to call just the private method _clearData() instead of the public method clear(), so _clearPath() (and _clearChart()) are never called.

from leaflet-elevation.

Raruto avatar Raruto commented on May 13, 2024

it's my own fault because I'm using your excellent control in a more "creative" way.

As you can see the addData() function is already public, there is nothing strange in using it.

The loop at line 93 It deletes a single layer successfully for the overlay (appears over the path when the chart is hovered over), but then fails on the next layer, which I presume is the path itself?

Which loop are you referring to?

This example shows more or less the behavior you described.

from leaflet-elevation.

britainbybike avatar britainbybike commented on May 13, 2024

Sorry, that should be 983

_clearPath: function() {
  this._hidePositionMarker();
  for (let id in this._layers) {
    L.DomUtil.removeClass(this._layers[id]._path, this.options.polyline.className);
    L.DomUtil.removeClass(this._layers[id]._path, this.options.theme);
  }
}

In the debugger it loops twice, crashing on the second iteration.

from leaflet-elevation.

Raruto avatar Raruto commented on May 13, 2024

In the debugger it loops twice, crashing on the second iteration.

I would not be wrong, but that loop should only run once per geoJSON track.

Basically it should remove these css classes to the map path:

<path class="elevation-polyline lightblue-theme"></path>

from leaflet-elevation.

britainbybike avatar britainbybike commented on May 13, 2024

Here's my theory for what it's worth!

In the Fiddle the GeoJSON layer has no custom events or styling. The mouseover event triggers an overlay on the line, which you indicated earlier is the layer than clear is trying to remove the class from?

If there is custom events/styling (as in mine), this layer doesn't appear when the mouse is over the path because the default mouseover event has been overridden. That's fine as It still appears when there is a mouseover on the graph. but maybe _focusG hasn't been created, or the class not applied?

Therefore when trying to clean up without checking first that it exists, we get the error. Looks like that's all it needs to do,

from leaflet-elevation.

Raruto avatar Raruto commented on May 13, 2024

Without a concrete example it is difficult to know ...

from leaflet-elevation.

britainbybike avatar britainbybike commented on May 13, 2024

True. Not a big deal as far as I am concerned, because the workaround works OK. I just thought it might help someone else who might encounter the same problem.
If you're interested, www.britainbybike.com (not currently complete or 24/7)

from leaflet-elevation.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.