我无法将我的坐标转换为地址......下面几乎有调整功能......但是有多少标记,只创建最后一个标记......:
我创建标记的功能:
function createMarker(point,info,map) {
var iconURL = 'img/pata.png';
var iconSize = new google.maps.Size(32,34);
var iconOrigin = new google.maps.Point(0,0);
var iconAnchor = new google.maps.Point(15,30);
var myIcon = new google.maps.MarkerImage(iconURL, iconSize, iconOrigin, iconAnchor);
var marker = new google.maps.Marker({
position : point,
html : info,
map : map,
icon: myIcon
});
var infowindow = new google.maps.InfoWindow({
content: "Dispositivo: " + info + "<br> Endereço: " + point
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map,this);
});
}
我创建书签的功能:试图适应的功能(只是想发送坐标,然后他转换为地址并在单击时离开信息窗口)
function codeLatLng() {
var input = document.getElementById('latlng').value;
var latlngStr = input.split(',', 2);
var lat = parseFloat(latlngStr[0]);
var lng = parseFloat(latlngStr[1]);
var latlng = new google.maps.LatLng(lat, lng);
geocoder.geocode({'latLng': latlng}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (results[1]) {
map.setZoom(11);
marker = new google.maps.Marker({
position: latlng,
map: map
});
infowindow.setContent(results[1].formatted_address);
infowindow.open(map, marker);
} else {
alert('No results found');
}
} else {
alert('Geocoder failed due to: ' + status);
}
});
}