0

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

2 回答 2

0

目前您有 5 秒的超时时间。多尝试一点:

{
    timeout: 15000
}
于 2013-01-14T13:41:28.607 回答
0

你知道这些论点是什么吗?

getCurrentPosition(showLocation, ErrorHandler, options);

只有在出现错误情况时才会调用第二个警报。

于 2013-01-14T13:47:51.630 回答