当前位置功能不起作用,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);
}