Skip to content

avoid map zoom out every time a new point is added #775

Closed

Description

@karussell

It would also be nice if the map did not zoom out every time a new point is added.

Activity

  1. fbonzon commented on Aug 23, 2016

    @fbonzon
    Contributor

    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.

  2. devemux86 commented on Aug 24, 2016

    @devemux86
    Contributor

    It would also be nice if the map did not zoom out every time a new point is added.

    Doesn't the zoom adjustment happens after each route geometry calculation?

  3. fbonzon commented on Aug 24, 2016

    @fbonzon
    Contributor

    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.

  4. devemux86 commented on Aug 24, 2016

    @devemux86
    Contributor

    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?

  5. fbonzon commented on Aug 24, 2016

    @fbonzon
    Contributor

    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):


    I'm adding a new similar parameter for zoom out only.

  6. karussell commented on Aug 24, 2016

    @karussell
    MemberAuthor

    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 :)

  7. fbonzon commented on Aug 24, 2016

    @fbonzon
    Contributor

    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?

  8. easbar commented on Aug 25, 2016

    @easbar
    Member

    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.

  9. karussell commented on Aug 25, 2016

    @karussell
    MemberAuthor

    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 :)

  10. easbar commented on Aug 25, 2016

    @easbar
    Member

    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) (?).

  11. easbar commented on Aug 25, 2016

    @easbar
    Member

    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
  12. easbar commented on Aug 25, 2016

    @easbar
    Member

    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).

  13. karussell commented on Aug 25, 2016

    @karussell
    MemberAuthor

    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 :)

  14. 5 remaining items

  15. fbonzon commented on Aug 30, 2016

    @fbonzon
    Contributor

    @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

    • Go here
    • 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"

    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

    • Go here
    • 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"

    Actual

    Zoom in occurs

    Expected

    Actual is fine, same.

  16. karussell commented on Aug 30, 2016

    @karussell
    MemberAuthor

    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?

  17. fbonzon commented on Aug 30, 2016

    @fbonzon
    Contributor

    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).

  18. karussell commented on Aug 30, 2016

    @karussell
    MemberAuthor

    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:

    map.fitBounds(polyline.getBounds());
  19. easbar commented on Sep 10, 2016

    @easbar
    Member

    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".

    I fixed this here: #791

  20. jeffrey-friedl commented on Apr 19, 2017

    @jeffrey-friedl

    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

  21. boldtrn commented on Apr 19, 2017

    @boldtrn
    Member

    Did "do_zoom" or the like ever make it public?

    Not to my knowledge, but you are more than welcome to create a PR :).

  22. fbonzon commented on May 5, 2018

    @fbonzon
    Contributor

    @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
  23. changed the title [-]Further improve web UI[/-] [+]avoid map zoom out every time a new point is added[/+] on May 5, 2018
  24. karussell commented on May 5, 2018

    @karussell
    MemberAuthor

    Thanks & Done

  25. self-assigned this
    on May 5, 2018
  26. easbar commented on Jan 28, 2020

    @easbar
    Member

    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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions