iPhone 3.0 地理定位 Javascript API

来源:互联网 发布:如何应对人工智能 编辑:程序博客网 时间:2024/04/29 21:15

iPhone 3.0 固件支持地理定位 API (geolocation API),

现在我们可以直接用iPhone上的safari 定位自己当前的经度和纬度,

然后调用googlemap 看到自己的实际位置。

 

我们只需要使用javascript 和 新加入的 Navigator.Geolocation 接口,

就可以调用 getCurrentPosition() 方法得到当前iPhone的经度和纬度,

然后再传值给google map API来显示在浏览器里。

 

有兴趣的可以试一下下面的demo。

 

 

 

 

 

<script type="text/javascript"><!--google_ad_client = "pub-3004755595146091";/* 300x250, created 9/29/09 */google_ad_slot = "3679875882";google_ad_width = 300;google_ad_height = 250;// --></script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script>

原创粉丝点击