1

我遇到了 geocoder.geocode( {'address': address enter code here} 的问题,方法没有执行并跳到下一个方法,以下是我的方法。

请帮帮我,我从前两天一直在苦苦挣扎,但没有输出,它没有抛出任何错误,但是 geocoder.geocode()enter code here没有执行,只是跳过它

function VerifyLocation() {
    $('#verify').click(function () {
    alert("verification");
        $('#verifyLocationVerify').hide();
        var address=$("#address").val();
        var sutenumber=$("#sutenumber").val();
        var city=$("#city").val();
        var country=$("#country option:selected").text();
        var state=$("#state option:selected").text();
        var pincode=$("#pincode").val();
        var addressdata=address+","+sutenumber+","+city+","+state+","+country+","+pincode;
         geocoder = new google.maps.Geocoder();
         geocoder.geocode(
         {'address': addressdata },
        function(data, status) { 
        if(data.length==0)
        {
                alert("location not found");
                $('#verifyLocationVerify').show();
                $('#verifyLocationConfirm').hide();
                $('#verifyLocationVerifySuccess').hide();
            }
            else{
            glat=data[0].geometry.location.nb;
            glng=data[0].geometry.location.ob;
                setCookie("latitude1",glat);
                setCookie("langitude1",glng);
                var styles = [{
                    "featureType": "road",
                    "stylers": [
                    { "lightness": 40 },
                    { "saturation": -100 }
                    ]
                }];
            var styledMap = new google.maps.StyledMapType(styles, { name: "Styled Map" });
            var latlang = new google.maps.LatLng(glat, glng);
            var mapOptions = {
                zoom: 15,
                center: latlang,
                mapTypeId: google.maps.MapTypeId.ROADMAP
                };
            map =  new google.maps.Map(document.getElementById("new_location"), mapOptions);
            map.mapTypes.set('map_style', styledMap);
            map.setMapTypeId('map_style');
            var marker = new google.maps.Marker({
                position: latlang,
                map: map,
                title: 'Entered Address Location'
            });
            }
        });

        $('#verifyLocationConfirm').show(function () {
            $('#verifyNo').click(function () {
                $('#verifyLocationVerify').show();
                $('#verifyLocationConfirm').hide();
                $('#verifyLocationVerifySuccess').hide();

                setCookie("verificationstatus","no");
            });

            $('#verifyYes').click(function () {
                //$('#verifyLocation').empty().removeClass('secondary').addClass('success').html('<p>Your Location has been Verified</p>');
                //$('#saveNew , #saveCont').removeClass('disabled');
                $('#verifyLocationVerify').hide();
                $('#verifyLocationConfirm').hide();
                $('#verifyLocationVerifySuccess').show();
                setCookie("verificationstatus","yes");
            });

        });
    });
}

谢谢和问候, Sathish Gai

4

1 回答 1

0

我不确定这个问题有多老,但我首先,我看到你没有打电话给

<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=$GoogleAPIKey&sensor=false"></script>

但我有它,我也没有收到回电。所以IDK。

于 2013-12-07T03:21:35.523 回答