【发布时间】:2013-11-25 15:02:29
【问题描述】:
这是我在点击链接时调用的函数,它在 iPhone 和 PC/Apple 设备浏览器上运行良好,但在任何 Android 设备浏览器中都不起作用:
function currentLocation() {
// Initialize the Google Maps API v3
var MyMarker = null;
function autoUpdate() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var newPoint = new google.maps.LatLng(position.coords.latitude,
position.coords.longitude);
if (MyMarker) {
// Marker already created - Move it
MyMarker.setPosition(newPoint);
}
else {
// Marker does not exist - Create it
marker = new google.maps.Marker({
position: newPoint,
map: map
});
}
// Center the map on the new position
map.setCenter(newPoint);
});
} // End if
// Call the autoUpdate() function every 5 seconds
setTimeout(autoUpdate, 5000);
}
autoUpdate();
}
一旦我访问包含此脚本的页面并按下按钮以显示我当前的位置设备确实要求我让我共享位置,但没有任何反应。控制台没有错误。
请就如何使其适用于基于 android 的设备提供建议。
【问题讨论】:
-
html5demos.com/geo - 这个链接在我的安卓手机上也不起作用!有什么想法???
标签: javascript google-maps-api-3 cross-platform android-browser