当前位置功能无效,Alert2
已显示,即使这样,地图也不会出现。请帮帮我,我无法找到解决方案
if (navigator.geolocation){
navigator.geolocation.getCurrentPosition(function (position) {
// Set the user's position
userLocation = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
alert("currentloc1 : "+ userLocation);
mapObject.setCenter(userLocation);
setUserMarker();
// Get the user's address if possible
geoCodeObject.geocode({ 'latLng': userLocation }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
$("#location_details").html(results[0].formatted_address);
userAddress = results[0].formatted_address;
}
else {
var errormessage="There were no hospitals found at the location. Please provide another location.";
alertBox(errormessage);
$("body").css("cursor", "default");
}
});
},
function () {
userLocation = locationPune;
alert("currentloc2 : "+ userLocation);
},
{
timeout: 5000
}
);
}else{
userLocation = locationPune;
alert("currentloc3 : "+ userLocation);
}
答案 0 :(得分:0)
目前您有5秒超时。再尝试一下:
{
timeout: 15000
}
答案 1 :(得分:0)
你知道参数是吗?
getCurrentPosition(showLocation, ErrorHandler, options);
只有在出现错误情况时才会调用第二个警报。