JAVASCRIPT
我确定这是一个非常简单的问题。
我正在修改下面的行并想用一个变量替换 (53, 0) 。但是,创建的名为“result”的变量等于“(34, 2)”,即它已经有括号括起来。
center: new google.maps.LatLng.(53, 0)
我试过了
center: new google.maps.LatLng.(result)
center: new google.maps.LatLng.result
center: new google.maps.LatLng.({result})
它没有工作!
完整代码
var geocoder = new google.maps.Geocoder();
if (geocoder) {
geocoder.geocode({ 'address': address }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
window.result = results[0].geometry.location;
alert(result);
}
else {
alert('nothing');
}
});
}
function load() {
map = new google.maps.Map(document.getElementById("map"), {
center: new google.maps.LatLng.(53, 0),
zoom: 10,
mapTypeId: 'roadmap',
mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU}
});
}
作为参考, alert(result) 返回
(53.8622017,-2.405405999999971)