jgpacker / osm-smart-menu

An OpenStreetMap webextension for Firefox and Chrome
GNU General Public License v3.0
56 stars 12 forks source link

To support opening in JOSM directly, add bounding box template arguments and a flag to not open a new tab #213

Open rkflx opened 1 year ago

rkflx commented 1 year ago

If you notice a bug or space for improvement, please report it.

Here we go (via #14):

use this template for JOSM: https://www.openstreetmap.org/edit?editor=remote#map={zoom}/{latitude}/{longitude}

Can confirm this works, but it will open an extra tab and load osm.org before calling out to JOSM, which could be considered a bit too much friction.

The following URL example works more smoothly for JOSM (and possibly any software with a compatible interface), i.e. changing the viewport via its "Remote Control" through the load_and_zoom command directly (no extra tab needed since you could call the URL directly): http://127.0.0.1:8111/load_and_zoom?left=8.19&right=8.20&top=48.605&bottom=48.590

JOSM needs to be running and have the "Remote Control" interface enabled via "Edit > Preferences > Remote Control > Enable".

osm.org is implicitly translating {zoom}/{latitude}/{longitude} into left=...&right=...&top=...&bottom=... bounds for load_and_zoom via Leaflet, see remoteEditHandler and getBounds. However, those template arguments are not available in OSM Smart Menu. If they could be added, that would be great. (Can you get access to the map's Leaflet object? Otherwise, just assume a common browser viewport size.) Another approach would be to improve JOSM to be able to handle a zoom parameter.

Adding bounds arguments would likely also solve #191. If you are willing to shrink bounds dynamically, this could even handle #211 (but arguably the latter is probably better fixed/configured in JOSM itself).

Once that is done, the only thing left would be adding a config flag to call a URL directly without opening a new tab. (Adding a third option, i.e. opening a URL in the current tab, would also be nice, but not applicable here.)

Note: For anyone willing to accept incorrect zoom levels, there is a workaround available. It will still open a new tab, but at least without loading osm.org. Set left=right and top=bottom: http://127.0.0.1:8111/load_and_zoom?left={longitude}&right={longitude}&top={latitude}&bottom={latitude}

(I looked into this due to a request in nrenner/brouter-web#694.)