日期:2014-05-17 浏览次数:20482 次
if (navigator.geolocation) {
// WILL GET TO THIS POINT WITH TEST `ALERT()`
navigator.geolocation.getCurrentPosition(
// WILL NOT GET OT THIS POINT IN ANDROID BROWSER
function(position) {
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
}, showError, {
enableHighAccuracy: true,
timeout : 5000,
maximumAge: 0
}
);
} else {
return alert('No Geolocation Support.');
}
};
//百度地图定位到当前城市
var map = new BMap.Map('map');
var gc = new BMap.Geocoder();
map.enableScrollWheelZoom(); //鼠标滑轮缩放
map.centerAndZoom("北京", 11);
//定位到当前城市
var geolocation = new BMap.Geolocation();
geolocation.getCurrentPosition(function (r) {
if (this.getStatus() == BMAP_STATUS_SUCCESS) {