umap-project / umap

uMap lets you create maps with OpenStreetMap layers in a minute and embed them in your site.
https://umap-project.org
Other
1.21k stars 227 forks source link

Accept gps coordinates in search input #1000

Closed brunetton closed 11 months ago

brunetton commented 2 years ago

Hi

I'm using uMap for some projects (and thanks for this great tool !). But I really misses the ability to center the map to given coordinates. Entering GPS coordinates (example 48.85839, 2.29458) isn't recognized:

image

ThePieMonster commented 1 year ago

This would be great to have. It would also remove the need to edit existing waypoints which causes a webpage freeze https://github.com/umap-project/umap/issues/1183.

yohanboniface commented 1 year ago

I know this is not user friendly, but as a workaround one can change the hash in the URL, example #10/48.85839, 2.29458.

But having a more intuitive and friendly way to do it would indeed makes sense!

Shohreh commented 1 year ago

Until this feature is implemented, for Windows users, here's an AutoIt script to 1) grab the coordinates from the clipboard, 2) find the map and grab itsURL to get the map #, and 3) build a new URL:

;grab map URL, get map #, prompt for GPS coords, generate new map URL

#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>
#include <StringConstants.au3>

;from Au3Record
Func _WinWaitActivate($title,$text,$timeout=0)
    Local $result = False

    If Not WinActive($title,$text) Then WinActivate($title,$text)
    WinWaitActive($title,$text,$timeout)

    $result = WinWait($title,$text,$timeout)
    if $result = False then Exit MsgBox($MB_ICONERROR,"Bad...","Window not displayed")
EndFunc

;grab GPS coords
Local $sAnswer = InputBox("Reference location", "Where from? LAT,LON", ClipGet())
if not $sAnswer Then Exit ConsoleWrite("Closed inputbox" & @CRLF)
$aArray = StringSplit(StringStripWS($sAnswer,$STR_STRIPLEADING + $STR_STRIPTRAILING + $STR_STRIPSPACES), ',')
If $aArray[0] <> 2 Then Exit MsgBox($MB_ICONERROR,"Error","User entered no (correct) LAT,LON: " & UBound($aArray))
Local $REF_LAT,$REF_LON
$REF_LAT = StringStripWS($aArray[1],$STR_STRIPLEADING + $STR_STRIPTRAILING + $STR_STRIPSPACES)
$REF_LON = StringStripWS($aArray[2],$STR_STRIPLEADING + $STR_STRIPTRAILING + $STR_STRIPSPACES)
ConsoleWrite($REF_LAT & " " & $REF_LON & @CRLF)

;https://umap.openstreetmap.fr/en/map/whatever_123456#19/41.40159/2.19385
Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
_WinWaitActivate("[TITLE:uMap; CLASS:Chrome_WidgetWin_1]","",5)
;grab URL
Send("^l^c")
ConsoleWrite("Input: " & ClipGet() & @CRLF)
;grab map #
Local $aParent = StringRegExp(ClipGet(), "_(\d+)#", $STR_REGEXPARRAYMATCH)
If @error Then Exit MsgBox($MB_ICONERROR,"Map #", "Not found")
Local $sMapNumber = $aParent[0]
ConsoleWrite("Map #:" & $sMapNumber & @CRLF)

;build URL
$sAnswer = StringFormat("https://umap.openstreetmap.fr/en/map/blah_%s#19/%s/%s",$sMapNumber,$REF_LAT,$REF_LON)
ClipPut($sAnswer)
ConsoleWrite("Output:" & $sAnswer & @CRLF)
brunetton commented 10 months ago

Is this deployed in public online version ? I tried it but it doesn't seems to work: searching for 50.85161,4.35286 doesn't return anything

davidbgk commented 10 months ago

@brunetton which instance of umap?

yohanboniface commented 10 months ago

Argh, it should have been, but there is a CORS issue due to a misconfiguration (Leaflet.Photon has not been updated, so it does not contain the correct domain for API calls…). This needs a new release sadly to include the correct JS file.

brunetton commented 10 months ago

@brunetton which instance of umap?

https://umap.openstreetmap.fr but I think you figured out regarding to @yohanboniface comment.

Thanks !