EastCoastGreenwayAlliance / ecg-map

Interactive map and trip planner for the ECGA
https://map.greenway.org
7 stars 0 forks source link

Active Turning calculation + UI start #45

Closed gregallensworth closed 7 years ago

gregallensworth commented 7 years ago

New concept of giving turn-by-turn in realtime per issue #37 Internally I'm calling this "ActiveTurning"

Still to do:

gregallensworth commented 7 years ago

After an hour, I have the following:

that closestLayerSnap() is returning a new L.Polyline object, instead of the matching object in the L.geoJson dataset this.searchRoute This was not the behavior until I did a git pull here: I ran a few routes just fine before I remembered your note that you had made a modification. Maybe this is some version change in L.GeometryUtil via unpkg instead of via npm, despite the version numbers allegedly being the same...

I do see that the yarn/npm version of leaflet-geometryutil brings in Leaflet 1.0.0 while the website uses 0.7.3 (cartodb.js) This may be the source of the problem here.

gregallensworth commented 7 years ago

Tracked it down further:

Under Leaflet 0.7.3 each L.Polyline instance within the L.geoJson structure, is in fact a L.LayerGroup and not a L.Path (searchRoute.getLayers()[2] instanceof L.LayerGroup is true). In this condition, thenhandling and return are completely different: it returns simply the subResult This being a L.LayerGroup (under 0.7 but not under 1.0) the .layer attribute is indeed to the parent L.geoJson structure and not to the specific sub-layer.

https://github.com/makinacorpus/Leaflet.GeometryUtil/blob/master/src/leaflet.geometryutil.js#L281

clhenrick commented 7 years ago

thanks @gregallensworth for catching that I'll take another look. We have to use the unkpg CDN because as you mentioned, Carto is already pulling in Leaflet.JS, Leaflet Geom Utils requires Leaflet when installing via NPM, so we definitely don't want two different versions of Leaflet pulled into the app!

gregallensworth commented 7 years ago

As of 0417bc4 there is no longer a dependency on L.GeometryUtil which doesn't work properly in Leaflet 0.7 I rewrote the geometry calculations to emulate the same effect, though, so nobody will notice...

clhenrick commented 7 years ago

Thanks @gregallensworth, I'll finish up the work to integrate this feature into the app. Appreciate the help!