开发者

Not able to get address using lat and long in iPhone

开发者 https://www.devze.com 2022-12-10 23:23 出处:网络
Please can any one 开发者_Python百科help me get the latitude/longitude location of the user. I have tried many things but I\'m not able to solve this problem. If anyone has an idea please help me.

Please can any one 开发者_Python百科help me get the latitude/longitude location of the user. I have tried many things but I'm not able to solve this problem. If anyone has an idea please help me.

I'm a beginner in iPhone so please give brief explanation.


I assume you mean in the browser (not a native application), since you have tagged this question as javascript. You do it via an asynchronous callback:

//Function that does something once the device has a location
//May be called repeatedly
function handler(location) {
  var longitude = location.coords.longitude;
  var latitude = location.coords.latitude;
  var accuracy = location.coords.accuracy

  //Do something with them
}

//Register the handler and tell the phone to start finding a location
navigator.geolocation.getCurrentPosition(handler);

It is all part of the HTML5 geolocation stuff, there is a draft here.

0

精彩评论

暂无评论...
验证码 换一张
取 消