You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
avoid map zoom out every time a new point is added #775
It would also be nice if the map did not zoom out every time a new point is added.
This feature, I have actually recently implemented on my GraphHopper fork. I will isolate needed changes and send a PR !
I did it with an additional allow_zoom_out parameter in GHRequest, initially true, then set to false if the request is triggered with a right-click on the map.
Yes. Currently, zoom adjustment happens after every route calculation, so that the entire route fits the map. When you were zoomed in even closer before the route calculation, staying at that zoom level is often desirable, instead of being zoomed out to see the entire route.
Then an external setting wouldn't be more appropriate, as the auto-zoom is app's responsibility after getting the result, instead of passing options to GH core?
Correct. That's the idea. Only the webapp would be changed. There is already a do_zoom parameter actually in the JavaScript code, for doing any zoom (in or out):
Yes. Currently, zoom adjustment happens after every route calculation
It does not happen if you just drag the markers. Couldn't we use the same mechanism when adding new points? I think I introduced the zoom parameter for this purpose but not sure to long ago :)
Correct, we could do the same. Is actually what I did, but I added a new parameter specific for zoom out. do_zoom forbids zooms in both directions.
In case adding new points through mouse click would result in a zoom in, I still allow the zoom in in my implementation, because it is not harmful. Thus is a different parameter, to disallow an automatic zoom out only. Do you agree?
intermediate points should be added just between the two closest points to the newly-added one
By 'two closest points' do you mean the two closest points in terms of a linear connection or the two points that are connected by the two shortest possible paths ? The first version would of course be easier to realize and would probably be sufficient if the user knows in which order he wants to travel the different destinations. If the order is not as he intended he can easily change the order especially if the intermediate points get numbered in the side bar (as you suggest). The second version would be interesting in case the user adds a destination and wants the shortest connection regardless of the final order of the different points. I n my opinion it would be best to start with the first version and make it the default.
By 'two closest points' do you mean the two closest points in terms of a linear connection or the two points that are connected by the two shortest possible paths
I think it should work like: user clicks&drags then determine location and do "snap to a coordinate of the route", now insert a new via point at the correct position between potential other via points. See the prototype mentioned in my initial comment or a version without the dragging feature at kurviger.de
The second version would be interesting in case the user adds a destination and wants the shortest connection regardless of the final order of the different points.
Do you mean sorting the locations via TSP? This should not be our aim :)
I was just wondering if we should use the beeline (Luftlinie) or the actual length of the shortest drivable route as distance metric to decide which are the 'two closest points'. Consider route1 on kurviger.de. Adding another intemediate point in "Ranies" (just west from points 2&3) results in route2 which goes to "Ranies" before crossing the river. However, if the intermediate point would be simply added as a stopover between the two closest (by means of the beeline) points (points 3&4 in route2) we would get route3, which is much longer and only makes sense if this specific order of the intermediate points is really wanted. I thought it would be sufficient to simply use the beeline to find the two 'closest' points nonetheless as it is easy to manually reorder the intermediate points in the few cases the results are not as desired. It saves the effort of calculating the routes from the point that is about to be added to all the others.
Do you mean sorting the locations via TSP?
I did not mean TSP for all locations, but rather meant what kurviger.de apparently does: When a new point is chosen as intermediate it chooses its position such that the length of the total route is minimized (route2 instead of route3 in the above example). This I guess is done by finding the two existing points that are closest by means of the length of the route to get there (and not the beeline) (?).
I think it should work like: user clicks&drags then determine location and do "snap to a coordinate of the route", now insert a new via point at the correct position between potential other via points
If we want to be able to drag the route, we first have to figure out which points the dragged route segment connects. I have not looked into this and I am not sure if this information is already available for all the route segments after the first routing request. If we only know the intermediate points (and not the relation between the segments and the points) we could do the following:
mousedown/begin of drag: use this coordinate to find the two closest points A and B (by means of real routes). This asserts we are modifying the correct segment.
mouseup/end of drag: use this coordinate for the new intermediate point that is inserted between the two points A and B
I would prefer the clicking method using the beeline distance to find the two closest points. It is the most simple solution and works in almost every case. The dragging on kasheftin is not very fun to use in my opinion (probably even more so on a phone).
With "beeline" you mean finding out the closest point on the route or finding the closest via-point? I guess the first option and then yes, this is what I also think is the simplest solution for now.
Click twice on the [+] icon to zoom in 2 levels. The static link URLs in GraphHopper Maps do not save the zoom levels, thus this step is required to reproduce the zoom out behaviour.
Right click somewhere in the middle of the screen, and select "Set intermediate"
Click twice on the [-] icon to zoom out 2 levels. The static link URLs in GraphHopper Maps do not save the zoom levels, thus this step is required to reproduce the zoom in behaviour.
Right click somewhere in the middle of the screen, between the existing start and end points, and select "Set intermediate"
Don't you think this makes it too complex? I would be fine if it does not zoom in both cases and avoid two parameters (and just use one :)). Maybe we add a button that "zooms to fit the whole route" instead?
Both implementations make sense (no zoom either direction, or zoom in only), or also add a button to manually fit the route to the viewport. That's your decision in the end, I will not argue.
I was personally annoyed by the zoom out behavior when using GraphHopper, so I added code to disable that. When I'm zoomed in deeply to precisely add intermediate points, this zoom out is clearly not wanted. I think we agree here. Your first post in this thread ("It would also be nice if the map did not zoom out every time a new point is added.") mentions this case only.
When adding a new point results in zoom in, I am not annoyed. I think it's even better. I still see as much of the route as I was seeing before, and I don't work less precisely as before (even the contrary, since I was zoomed in).
Ok. As you are good with both options :) I would slightly prefer to have just one parameter (do_zoom) and disable zooming it in both cases. Plus provide a "fit to route" button (e.g. below zoom buttons?), which should be very simple via:
Some minor problem I stumbled over (inserted as "1" where it should be "2") which I currently debug. E.g. use this route in Bavaria and put a new intermediate point at "Neuenmark in der Oberpfalz".
Hi. Did "do_zoom" or the like ever make it public? I'd love to be able to disable auto-zoom when working with the map. Also, is there any chance that the markers along the side can be numbered like they are on the map? These two changes would make things perfect.....
@karussell Can we have separate issue for each improvement suggested here ? Will be easier to discuss and follow status.
I suggest we keep this one for the zoom problem, since we discuss it above. I'll address it, you can assign to me. Please modify this issue title, and edit first message in this issue to keep only the sentence about zoom.
For the 3 remaining:
"intermediate points should be added just between the two closest points ". This was fixed.
"It would be nice if the list of points along the left were numbered, just as the points are on the actual map" → Create new issue
"in addition to "Set as End", an option to "Extend route To" would be very useful. This would turn the current end point into an intermediate point, then set the selected location as the end point." → Create new issue
Activity
fbonzon commentedon Aug 23, 2016
This feature, I have actually recently implemented on my GraphHopper fork. I will isolate needed changes and send a PR !
I did it with an additional
allow_zoom_outparameter in GHRequest, initiallytrue, then set tofalseif the request is triggered with a right-click on the map.devemux86 commentedon Aug 24, 2016
Doesn't the zoom adjustment happens after each route geometry calculation?
fbonzon commentedon Aug 24, 2016
Yes. Currently, zoom adjustment happens after every route calculation, so that the entire route fits the map. When you were zoomed in even closer before the route calculation, staying at that zoom level is often desirable, instead of being zoomed out to see the entire route.
devemux86 commentedon Aug 24, 2016
Then an external setting wouldn't be more appropriate, as the auto-zoom is app's responsibility after getting the result, instead of passing options to GH core?
fbonzon commentedon Aug 24, 2016
Correct. That's the idea. Only the webapp would be changed. There is already a
do_zoomparameter actually in the JavaScript code, for doing any zoom (in or out):graphhopper/web/src/main/webapp/js/graphhopper/GHRequest.js
Line 40 in 1e30238
I'm adding a new similar parameter for zoom out only.
karussell commentedon Aug 24, 2016
It does not happen if you just drag the markers. Couldn't we use the same mechanism when adding new points? I think I introduced the zoom parameter for this purpose but not sure to long ago :)
fbonzon commentedon Aug 24, 2016
Correct, we could do the same. Is actually what I did, but I added a new parameter specific for zoom out. do_zoom forbids zooms in both directions.
In case adding new points through mouse click would result in a zoom in, I still allow the zoom in in my implementation, because it is not harmful. Thus is a different parameter, to disallow an automatic zoom out only. Do you agree?
easbar commentedon Aug 25, 2016
By 'two closest points' do you mean the two closest points in terms of a linear connection or the two points that are connected by the two shortest possible paths ? The first version would of course be easier to realize and would probably be sufficient if the user knows in which order he wants to travel the different destinations. If the order is not as he intended he can easily change the order especially if the intermediate points get numbered in the side bar (as you suggest). The second version would be interesting in case the user adds a destination and wants the shortest connection regardless of the final order of the different points. I n my opinion it would be best to start with the first version and make it the default.
karussell commentedon Aug 25, 2016
I think it should work like: user clicks&drags then determine location and do "snap to a coordinate of the route", now insert a new via point at the correct position between potential other via points. See the prototype mentioned in my initial comment or a version without the dragging feature at kurviger.de
Do you mean sorting the locations via TSP? This should not be our aim :)
easbar commentedon Aug 25, 2016
I was just wondering if we should use the beeline (Luftlinie) or the actual length of the shortest drivable route as distance metric to decide which are the 'two closest points'. Consider route1 on kurviger.de. Adding another intemediate point in "Ranies" (just west from points 2&3) results in route2 which goes to "Ranies" before crossing the river. However, if the intermediate point would be simply added as a stopover between the two closest (by means of the beeline) points (points 3&4 in route2) we would get route3, which is much longer and only makes sense if this specific order of the intermediate points is really wanted. I thought it would be sufficient to simply use the beeline to find the two 'closest' points nonetheless as it is easy to manually reorder the intermediate points in the few cases the results are not as desired. It saves the effort of calculating the routes from the point that is about to be added to all the others.
I did not mean TSP for all locations, but rather meant what kurviger.de apparently does: When a new point is chosen as intermediate it chooses its position such that the length of the total route is minimized (route2 instead of route3 in the above example). This I guess is done by finding the two existing points that are closest by means of the length of the route to get there (and not the beeline) (?).
easbar commentedon Aug 25, 2016
If we want to be able to drag the route, we first have to figure out which points the dragged route segment connects. I have not looked into this and I am not sure if this information is already available for all the route segments after the first routing request. If we only know the intermediate points (and not the relation between the segments and the points) we could do the following:
easbar commentedon Aug 25, 2016
I would prefer the clicking method using the beeline distance to find the two closest points. It is the most simple solution and works in almost every case. The dragging on kasheftin is not very fun to use in my opinion (probably even more so on a phone).
karussell commentedon Aug 25, 2016
With "beeline" you mean finding out the closest point on the route or finding the closest via-point? I guess the first option and then yes, this is what I also think is the simplest solution for now.
BTW: the TSP version has a really nice effect :)
5 remaining items
fbonzon commentedon Aug 30, 2016
@karussell Consider these 2 cases. Do you agree with the "Expected" sections? I will send PR to change behavior in case 1) if you agree.
1) Adding a point results in zoom out
Steps to reproduce
Actual
Zoom out occurs
Expected
No zoom out occurs. Zoom level stays the same.
2) Adding a point results in zoom in
Steps to reproduce
Actual
Zoom in occurs
Expected
Actual is fine, same.
karussell commentedon Aug 30, 2016
Don't you think this makes it too complex? I would be fine if it does not zoom in both cases and avoid two parameters (and just use one :)). Maybe we add a button that "zooms to fit the whole route" instead?
fbonzon commentedon Aug 30, 2016
Both implementations make sense (no zoom either direction, or zoom in only), or also add a button to manually fit the route to the viewport. That's your decision in the end, I will not argue.
I was personally annoyed by the zoom out behavior when using GraphHopper, so I added code to disable that. When I'm zoomed in deeply to precisely add intermediate points, this zoom out is clearly not wanted. I think we agree here. Your first post in this thread ("It would also be nice if the map did not zoom out every time a new point is added.") mentions this case only.
When adding a new point results in zoom in, I am not annoyed. I think it's even better. I still see as much of the route as I was seeing before, and I don't work less precisely as before (even the contrary, since I was zoomed in).
karussell commentedon Aug 30, 2016
Ok. As you are good with both options :) I would slightly prefer to have just one parameter (
do_zoom) and disable zooming it in both cases. Plus provide a "fit to route" button (e.g. below zoom buttons?), which should be very simple via:easbar commentedon Sep 10, 2016
I fixed this here: #791
jeffrey-friedl commentedon Apr 19, 2017
Hi. Did "do_zoom" or the like ever make it public? I'd love to be able to disable auto-zoom when working with the map. Also, is there any chance that the markers along the side can be numbered like they are on the map? These two changes would make things perfect.....
Thanks so much,
Jeffrey
boldtrn commentedon Apr 19, 2017
Not to my knowledge, but you are more than welcome to create a PR :).
fbonzon commentedon May 5, 2018
@karussell Can we have separate issue for each improvement suggested here ? Will be easier to discuss and follow status.
I suggest we keep this one for the zoom problem, since we discuss it above. I'll address it, you can assign to me. Please modify this issue title, and edit first message in this issue to keep only the sentence about zoom.
For the 3 remaining:
[-]Further improve web UI[/-][+]avoid map zoom out every time a new point is added[/+]karussell commentedon May 5, 2018
Thanks & Done
easbar commentedon Jan 28, 2020
After opening the separate issues #1359 and graphhopper/graphhopper-maps#248 this issue was only about the map zooming and now this was fixed via #1868, thanks @twitwi!