javascript - HTML5 get geolocation function -


i'm trying write function returns geolocation using html5. function never returns. how come?

function getcurlocation() {     navigator.geolocation.getcurrentposition(function(position) {           return [position.coords.latitude, position.coords.longitude];     }); } 

navigator.geolocation.getcurrentposition asynchronous call. ajax, can't return it's value synchronously rest of code. can't know when complete or if complete. work relies on response (position in case) of ajax call must done in ajax callback.


Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -