我正在运行问题geocoder.geocode(
{'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");
});
});
});
}
谢谢&amp;问候, Sathish Gai
答案 0 :(得分:0)
我不确定这个问题有多久,但我首先看到你没有打电话
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=$GoogleAPIKey&sensor=false"></script>
但是我已经拥有它而且我也没有接到回电话。所以IDK。