<div dir="ltr"><div><div><div><div><div><div><div><div><div><div>Does that mean that having coords in the directions boxes is not always a must-avoid situation?<br></div>I assumed that for user functionality, it would always be best to have a physical location name in the boxes, but if the target of the site is for more mapping enthusiasts then I could be wrong, and accuracy is valued over looking-good.<br><br></div>I did have a look at the code in reference to the reverse_directions functionality though, and how it alway deletes the location and puts coords in the directions boxes, and its to do with the endpoint.setValue(<i>value</i>, <i>LatLng</i>) method..<br></div><br>```<br>endpoint.setValue = function(value, latlng) {<br>      endpoint.value = value;<br>      delete endpoint.latlng;<br>      input.val(value);<br><br>      if (latlng) {<br>        endpoint.setLatLng(latlng);<br>      } else {<br>        endpoint.getGeocode();<br>      }<br>    };<br>```<br></div><div>My initial thoughts are that this should set the value of the endpoint inner variables, as well as set the endpoint input value to the value passed in.<br><br></div>Sure enough, you can see that the inner endpoint.value variable is set, and then the input.val() is also set to value. And you can see when going through with a debugger, that the input's value changes in the HTML.<br></div>But, the next step is to either go into the setLatLng() or getGeocode() methods. When reversing directions, the router passes both the value and the LatLng coords into this method, so the code goes into setLatLng(), but in setLatLng() the input.val() value is overwritten with the LatLng coords, which to me, seems like unwarranted behaviour.<br><br>```<br>endpoint.setLatLng = function (ll) {<br>      var precision = OSM.zoomPrecision(map.getZoom());<br>      input.val(ll.lat.toFixed(precision) + ", " + ll.lng.toFixed(precision));<br>      endpoint.hasGeocode = true;<br>      endpoint.latlng = ll;<br>      endpoint.marker<br>        .setLatLng(ll)<br>        .addTo(map);<br>    };<br>```<br><br></div>So either the input.val(value) assignment in setValue() is completely redundant, as the input val is overwritten in both setLatLng() and getGeocode(), (and can therefore be removed), or setLatLng() should not concern itself with the setting of the input box values..<br><br></div>One way to sort of leave it remaining as it is as well as to set the input box value as the actual passed in value, would be to put the input.val(value) assignment after the call to setLatLng()<br><br></div>i.e. <br><br>```<br>endpoint.setValue = function(value, latlng) {<br>      endpoint.value = value;<br>      delete endpoint.latlng;<br><br>      if (latlng) {<br>        endpoint.setLatLng(latlng);<br>        input.val(value);<br>      } else {<br>        endpoint.getGeocode();<br>      }<br>    };<br>```<br><br></div>So now setLatLng()'s behaviour is not affected so nothing will break elsewhere, and setValue() actually sets the input value to the value that was passed in, which is surely the expected behaviour?<br><br></div>Jamie<br><div><div class="gmail_extra"><br><div class="gmail_quote">On 14 February 2018 at 07:10, Tom Hughes <span dir="ltr"><<a href="mailto:tom@compton.nu" target="_blank">tom@compton.nu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 14/02/18 02:04, Jamie Guthrie wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Or rather, is there any objection if I start working on being able to drag routes from any point along the route to create way points? (i.e. similar to how its possible in Google and Bing maps)<br>
<br>
It would require some work to allow OSM.Directions to handle more than just the two Endpoints, but I can't see it being too excessively difficult to implement..<br>
</blockquote>
<br></span>
The only thing I'd say is to bear in mind that we're not trying to<br>
reimplement Google Maps and provided a full featured end-user mapping<br>
experience.<br>
<br>
Routing exists because it's useful for mappers to check connectivity<br>
issues - the question is does adding waypoints help with that?<span class="HOEnZb"><font color="#888888"><br>
<br>
Tom<br>
<br>
-- <br>
Tom Hughes (<a href="mailto:tom@compton.nu" target="_blank">tom@compton.nu</a>)<br>
<a href="http://compton.nu/" rel="noreferrer" target="_blank">http://compton.nu/</a><br>
</font></span></blockquote></div><br></div></div></div>