Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: "curve.trace is not a function" #23

Closed
JensC opened this issue Apr 26, 2019 · 3 comments
Closed

TypeError: "curve.trace is not a function" #23

JensC opened this issue Apr 26, 2019 · 3 comments

Comments

@JensC
Copy link

JensC commented Apr 26, 2019

First of all, thanks for implementing the helpful trace method. In a react app I wanted to use the new method and I got the error mentioned in the title. Drawing the curve works just fine.

Here is the used code snippet

          if (this.map != null) {
            let curve = L.curve(path,
              this.props.polylineOptions).addTo(this.map);
            const points = curve.trace([0.25, 0.5, 0.75]);
            console.log('Curve trace *****', points)
//          this.addArrowDecorators(points);
          }

I am using leaflet 1.1.0 and the newest (0.5) Leaflet.curve. Any idea what is going wrong?

@elfalem
Copy link
Owner

elfalem commented Apr 26, 2019

From the code snippet you provide, I would expect it to work. I'm not sure what could be wrong.

What do you get if you debug the following?

console.log(curve)
console.log(curve.trace)

@khetamHamad
Copy link

I faced the same issue
console.log(curve.trace) returns :
ƒ (t){
t = t.filter(function(element){
return element >= 0 && element <= 1;
});
var point, curCommand, curStartPoint, curEndPoint;
var p1, p2, p3; ...

console.log(curve) returns:
e {options: {…}, _coords: Array(5), _bounds: T, _initHooksCalled: true, _popup: e, …}
options: {weight: 1.0592885375494072, opacity: 0.5592885375494072, color: "#228B22", animate: {…}}
_bounds: T {_southWest: M, _northEast: M}
_coords: (5) ["M", Array(2), "Q", Array(2), Array(2)]
_events: {click: Array(1), keypress: Array(1), remove: Array(1), move: Array(1)}
_initHooksCalled: true
_latLngToPointFn: ƒ (t)
_leaflet_id: 7342
_map: e {options: {…}, _handlers: Array(6), _layers: {…}, _zoomBoundLayers: {…}, _sizeChanged: false, …}
_mapToAdd: e {options: {…}, _handlers: Array(6), _layers: {…}, _zoomBoundLayers: {…}, _sizeChanged: false, …}
_path: path
_points: (5) ["M", x, "Q", x, x]
_popup: e {options: {…}, _source: e, _initHooksCalled: true, _content: "

Total number: 3
"}
_popupHandlersAdded: true
_renderer: e {options: {…}, _leaflet_id: 8644, _layers: {…}, _initHooksCalled: true, _mapToAdd: e, …}
_usingCanvas: false
_zoomAnimated: true
proto: e

@elfalem
Copy link
Owner

elfalem commented May 1, 2019

@JensC @khetamHamad An outdated version of the plugin was published as 0.5.0. This is why there were errors with the trace function not being recognized. An accurate package has been published as 0.5.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants