Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get user's current coordinates from browser #98

Closed
krabina opened this issue Dec 16, 2015 · 14 comments · Fixed by #784
Closed

Get user's current coordinates from browser #98

krabina opened this issue Dec 16, 2015 · 14 comments · Fixed by #784

Comments

@krabina
Copy link
Contributor

krabina commented Dec 16, 2015

It should be possible to get the current location of a user (the user's browser) via JavaScript:
https://www.mediawiki.org/wiki/API:Showing_nearby_wiki_information#How_to_get_geographic_coordinates

This can then be used e. g. in Semantic Maps queries, or also simply in Maps, centering a map around a current location or displaying the current location on a map.

http://semantic-mediawiki.org/wiki/Semantic_Maps_examples/Distance_query - here the distance query is done with a fixed coordinate, it would be great if we could do:
[[Has coordinates::{{CURRENTLOCATION}} (0.3 km)]]

@JeroenDeDauw
Copy link
Member

Thanks for the enhancement request. For Maps this is relatively easy to do. However for Semantic Maps some serious work is needed to make such a feature work properly, as the query would need to be aware of the location.

@krabina
Copy link
Contributor Author

krabina commented Dec 21, 2015

But if we hade something like {{CURRENTLOCATION}} that results in the current coordinates, it would be easy, both for maps and semantic maps...

@JeroenDeDauw
Copy link
Member

Sure... however how would this work? Wikitext is evaluated on the server and does not depend on the user. Both of these things prevent you from getting information from the clients browser.

@mwjames
Copy link
Contributor

mwjames commented Feb 3, 2016

Both of these things prevent you from getting information from the clients browser.

According to [0], "Using HTML Geolocation.. to get the user's position."

<script>
var x = document.getElementById("demo");
function getLocation() {
    if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(showPosition);
    } else {
        x.innerHTML = "Geolocation is not supported by this browser.";
    }
}
function showPosition(position) {
    x.innerHTML = "Latitude: " + position.coords.latitude + 
    "<br>Longitude: " + position.coords.longitude; 
}
</script>

[0] http://www.w3schools.com/html/html5_geolocation.asp

@JeroenDeDauw
Copy link
Member

That gets you the information in the clients browser, not on the server side. So I still don't see how this can work for Semantic Maps.

@acnetj
Copy link
Contributor

acnetj commented Apr 13, 2016

For me, it requires a few extensions to make it work, including Widgets and UrlGetParameters. The Widgets is used to make button to request geolocation, and put it on the url string, and then directs to a new page where the lat lngs in the url parameters are parsed and the queried. See http://www.transitunlimited.org/Main_Page for the first button.

@kghbln
Copy link
Member

kghbln commented Jun 8, 2016

I guess WhatsNearby makes this feature available.

@PeterTheOne
Copy link
Contributor

Also I could create options for SemanticMediaWiki/SemanticMaps#52 like centercurrentlocation or markeroncurrentlocation.

@mwjames
Copy link
Contributor

mwjames commented Jun 8, 2016

Also I could create options for SemanticMediaWiki/SemanticMaps#52 like centercurrentlocation or markeroncurrentlocation.

Well, the reason I didn't put it into SM directly was mainly for privacy reasons. A users makes a concious decision about being traceable if it is not disabled.

@PeterTheOne
Copy link
Contributor

A users makes a concious decision about being traceable if it is not disabled.

I'm all for respecting to users choice not to be traced. I don't understand why this is linked to putting it in SM or not. Anyway I will focus on different things for now.

@kghbln
Copy link
Member

kghbln commented Jan 23, 2017

We have the WhatsNearby extension mentioned earlier in this thread. I have not fully understood why Maps should be extended rather than using WhatsNearby to do the job. Does WhatsNearby actually do the job?

@nischayn22 FYI

@krabina
Copy link
Contributor Author

krabina commented Jan 24, 2017 via email

@kghbln
Copy link
Member

kghbln commented Jan 24, 2017

Looks like this is developing in a melange of things which should or could be addressed after the originating question is answered.

@JeroenDeDauw
Copy link
Member

Closing since this is presumably handled by WhatsNearby. If not and there is still demand for this, please create a new issue.

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

Successfully merging a pull request may close this issue.

6 participants