以下变量my_cords是不确定的,当它到达了谷歌地图的功能,任何人都可以理解为什么和可能给我周围的工作? 我曾经就在顶部定义它,并设置一个回调函数,这是我以前见过的全局变量里面工作..
$(document).ready(function () {
var my_cords;
var map;
function getCareHome() {
geocoder = new google.maps.Geocoder();
//var address = document.getElementById("address").value;
var address = "address here";
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
my_cords = results[0].geometry.location;
} else {
alert("Sorry we couldn't locate the carehome on the map: " + status);
return false;
}
});
var myOptions = {
zoom: 7,
center: my_cords,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
}
getCareHome();
});