gpt4 book ai didi

google-maps - 谷歌地图地理编码未定义

转载 作者:行者123 更新时间:2023-12-04 01:17:46 25 4
gpt4 key购买 nike

我有这个在加载时启动的代码

// Display the map

function map_it() {
var myLatlng = new google.maps.LatLng(13.005621, 77.577531);
var myOptions = {
zoom: zoomLevel,
center: myLatlng,
disableDefaultUI: true,
mapTypeId: google.maps.MapTypeId.ROADMAP,
navigationControl: true,
navigationControlOptions: {
style: google.maps.NavigationControlStyle.SMALL
}
}
map = new google.maps.Map(document.getElementById("map-it"), myOptions);
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
draggable: true
});
google.maps.event.addListener(marker, 'dragend', function (event) {
document.getElementById('mapLat').value = marker.getPosition().lat();
document.getElementById('mapLng').value = marker.getPosition().lng();
geocodePosition(marker.getPosition());
});
}

function geocodePosition(pos) {
geocoder.geocode({
latLng: pos
}, function (responses) {
if (responses && responses.length > 0) {
updateMarkerAddress(responses[0].formatted_address);
alert(responses[0].formatted_address);
} else {
updateMarkerAddress('Cannot determine address at this location.');
}
});
}

我收到以下错误
geocoder is not defined
http://localhost/bakasura1/js/modal.js
Line 74

最佳答案

嗯......呃......它说什么。你是说geocoder.geocode(...) ,但您实际上并没有定义任何名为 geocoder 的变量.你忘了吗:

var geocoder= new google.maps.Geocoder();

关于google-maps - 谷歌地图地理编码未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4045333/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com