Har*_*M V 11 google-maps geocoding
我有这个代码,它是在加载时启动的
// 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.');
}
});
}
Run Code Online (Sandbox Code Playgroud)
我收到以下错误
geocoder is not defined
http://localhost/bakasura1/js/modal.js
Line 74
Run Code Online (Sandbox Code Playgroud)
bob*_*nce 38
嗯......呃......它说的是什么.你说geocoder.geocode(...),但你实际上并没有定义任何被称为变量的变量geocoder.你忘了吗:
var geocoder= new google.maps.Geocoder();
Run Code Online (Sandbox Code Playgroud)
你在某处有这条线吗?我在提供的代码中看不到它。
geocoder = new google.maps.Geocoder();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
23096 次 |
| 最近记录: |