admin管理员组文章数量:1415645
Basically what I am trying to do is get access to the gps coordinates on the iphone 4. I'm not creating any type of web app. I can't find too much other than the geolocation api, but that seems to be geared toward creating web apps. Is there a javascript function that I can call from the phone itself that will return its own gps coordinates. Bascially what I'm working on is a weather widget that creates an xmlrequest and parses that returned data. The widget works fine for a specific zip code. however, I am wanting to see if I can get this running based on gps. The website which returns the xml response also allows gps coords. Just looking for the best way to fetch the coords and pass them to this site.
Basically what I am trying to do is get access to the gps coordinates on the iphone 4. I'm not creating any type of web app. I can't find too much other than the geolocation api, but that seems to be geared toward creating web apps. Is there a javascript function that I can call from the phone itself that will return its own gps coordinates. Bascially what I'm working on is a weather widget that creates an xmlrequest and parses that returned data. The widget works fine for a specific zip code. however, I am wanting to see if I can get this running based on gps. The website which returns the xml response also allows gps coords. Just looking for the best way to fetch the coords and pass them to this site.
Share Improve this question edited Aug 19, 2010 at 1:40 RedBlueThing 42.5k17 gold badges98 silver badges122 bronze badges asked Aug 19, 2010 at 1:19 cameron213cameron213 1692 gold badges5 silver badges12 bronze badges 3- create a simple app for the iphone with location manager – alecnash Commented Aug 19, 2010 at 1:27
- @alecnash Sounds like he is trying to do this from a web app, not a native app. – RedBlueThing Commented Aug 19, 2010 at 1:40
- The question is not super clear. @cameron213, are you trying to get the coordinates from your web page which users will see in Mobile Safari? Or a Cocoa iPhone app? The W3C Geolocation API and CoreLocation are the respective answers, I believe. – npdoty Commented Aug 19, 2010 at 2:48
1 Answer
Reset to default 5Try something like this:
navigator.geolocation.getCurrentPosition( function(loc){
var lat = loc.coords.latitude;
var lon = loc.coords.longitude;
doSomethingWith( lat, lon ); // your function
});
References: Mobile Safari Documentation
本文标签: javascriptAccess iPhone GPS coordinatesStack Overflow
版权声明:本文标题:javascript - Access iPhone GPS coordinates - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745242476a2649405.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论