Geolocation API on the iPhone(iPhone 上的地理定位 API)
问题描述
有谁知道 iPhone 是否支持或即将支持
(来源:
(来源:bemoko.com)
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><头><title>地理定位 API 演示</title><元内容=宽度=设备宽度;初始比例=1.0;最大比例=1.0;用户可缩放=0;"名称="视口"/><脚本>功能成功处理程序(位置){var message = document.getElementById("message"), html = [];html.push("
Does anyone know whether the iPhone supports or will soon support the W3C Geolocation specification?
I'm looking to build an app for mobile users, but rather than spend the time developing apps for every different platform (iPhone, Android, etc...), I'd much prefer to create a web app that makes use of the W3C Standard.
This code worked for me -- on the iPhone web browser Safari and as an added bonus it even worked with FireFox 3.5 on my laptop! The Geolocation API Specification is part of the W3 Consortium’s standards But be warned: it hasn’t been finalized as yet.
(source:
(source: bemoko.com)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Geolocation API Demo</title>
<meta content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" name="viewport"/>
<script>
function successHandler(location) {
var message = document.getElementById("message"), html = [];
html.push("<img width='256' height='256' src='http://maps.google.com/maps/api/staticmap?center=", location.coords.latitude, ",", location.coords.longitude, "&markers=size:small|color:blue|", location.coords.latitude, ",", location.coords.longitude, "&zoom=14&size=256x256&sensor=false' />");
html.push("<p>Longitude: ", location.coords.longitude, "</p>");
html.push("<p>Latitude: ", location.coords.latitude, "</p>");
html.push("<p>Accuracy: ", location.coords.accuracy, " meters</p>");
message.innerHTML = html.join("");
}
function errorHandler(error) {
alert('Attempt to get location failed: ' + error.message);
}
navigator.geolocation.getCurrentPosition(successHandler, errorHandler);
</script>
</head>
<body>
<div id="message">Location unknown</div>
</body>
</html>
这篇关于iPhone 上的地理定位 API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:iPhone 上的地理定位 API
基础教程推荐
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01