ffwdme / ffwdme.js

[DEPRECATED!] 🛑 A JavaScript toolkit that aims to bring interactive GPS driving directions to the mobile browser
http://ffwdmejs.org
MIT License
153 stars 36 forks source link

Uncaught TypeError: Cannot read property 'lat' of null #13

Closed adamduren closed 8 years ago

adamduren commented 8 years ago

I am trying to get started using the library from the guides but am encountering an issue. I looked at the function where the error occured and the desiredPos argument is null which is causing the error. I followed up the stacktrack and it doesn't appear to ever be set. Not sure if I am doing something wrong or if it is a bug in the library. Thanks in advance for the help!


// initialization code above and not included

ffwdme.on('routecalculation:success', function(response) {
    ffwdme.navigation.setRoute(response.route).start();
});

new ffwdme.routingService({
    start: { lat: 49.932707, lng: 11.588051 },
    dest: { lat: 50.3404, lng: 11.64705 }
}).fetch();
Uncaught TypeError: Cannot read property 'lat' of null
Base.extend.drawHelpLine
@ ffwdme-components.js:1156Base.extend.navigationOffRoute
@ ffwdme-components.js:1105(anonymous function)
@ ffwdme-core.js:173ffwdme.trigger
@ ffwdme-core.js:596Class.extend.notFoundOnRoute
@ ffwdme-core.js:806Class.extend.getPositionOnRoute
@ ffwdme-core.js:840(anonymous function)
@ ffwdme-core.js:173Class.extend.start
@ ffwdme-core.js:783(anonymous function)
@ MapDirective.ts:94ffwdme.trigger
@ ffwdme-core.js:596Class.extend.success
@ ffwdme-core.js:1279Base.extend.parse
@ ffwdme-core.js:1441(anonymous function)
@ ffwdme-core.js:173callbacks.(anonymous function)
@ ffwdme-core.js:1656(anonymous function)
@ route?type=jsonp&key=c554015e-0998-451f-b6a3-fb802f2a09c5&locale=en_EN&vehicle=car&weighting=fastes…:1
adamduren commented 8 years ago

If it helps any my coordinates were far from the start and end points and I think that messed it up in drawing the help line.

fabrik42 commented 8 years ago

Hi, sorry for the delay! Yes, you are right - this seems to be a bug in the lib. The data passed with the event is gathered here: https://github.com/ffwdme/ffwdme.js/blob/master/src/core/navigation.js#L164-L201

But, the nearest point can be null in a scenario like yours. I think we should make the drawHelpLine method of the Leaflet component null safe.

Would you be interested in submitting a patch? I would be happy to help you however I can.

Cheers, Christian

adamduren commented 8 years ago

I'm just starting to dive into the library and would be willing to contribute back to the library once I get more familiar with the concepts of mapping.

fabrik42 commented 8 years ago

This sounds good, thank you!