Closed danrademacher closed 7 years ago
Iterating that this view is only available on mobile. I think it a couple other issues need to be flushed out first:
Locate Me button for showing user's current location
More work on layout for mobile, including the "view cues" button and "start route" button, which enables a user to get to this point.
We'll also want to integrate a feature that tells the user if they aren't in the vicinity of the ECG and thus prevents the "Locate Me" feature from working. No point in showing their current location on the map if they are in West Virginia or elsewhere.
PR 45 brings the current state, which meets the spec per discussion.
Internally I'm calling this "ActiveTurning"
locate()
and locationfound
handlers. Finds the nearest segment in your route, gets info about the transition point at the end of that segment.Still to do:
I'm sure the distance given from one transition to the next will be confusing for users at first. I wonder if there's a somewhat elegant way we can word this or make it clear that it's not the actual distance from a user's current location to the next turn? cc @danrademacher
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...
This seems to be working well when fibbing my location in the browser.
The one part that I left out of the UI is the number in the upper left of the box to the left of the cancel button, which I believe represents the remaining mileage of the route from the user's current location. As @gregallensworth has already mentioned, without a true GPS implementation (which is beyond the scope of this feature) we can't accurately tell someone how much distance is left in the portion of the route they selected; nor can we tell them exactly how far they are from the next turn.
Implemented, waiting to be tested in the field. We can open a new issue for any bugs that come up.
Reopening for some testing: Chris hypothesizes that if we are nearby a very long segment (there's one record 9 miles in length) the "my distance to nearest line" calculations may be off, as if they're using the endpoint or nearest vertex? I thought I coded it to find the nearest point, but an extreme case sounds worth testing.
Relevant sections of code: https://github.com/EastCoastGreenwayAlliance/ecg-map/blob/master/client/src/components/LeafletMap.jsx#L290-L310
On review, the new version does use turfDistance(turfMidpoint())
so is fetching the distance to the midpoint of the vertex-pair. If the road is very straight (highway, ferry) a single vertex pair could hypothetically be a mile or more in length, giving an inflated result.
On a route from Philadelphia, PA to New Bruncwick, NJ there are some straight sections with wider spacing between vertices. Using these, I did confirm that the midpoint technique would give inflated distances in these situations.
I replaced the code with Leaflet code based on my original from July 5. The effective change was largely one line to convert the L.Point back to a L.LatLng before calling distanceTo()
In the process I did make some other small changes:
thanks @gregallensworth!
for this view:
We need:
For testing location, we can use dev tools to spoof other latlons
Assigned to Chris, but feel free to pull in Greg if helpful