-2

我无法将我的坐标转换为地址......下面几乎有调整功能......但是有多少标记,只创建最后一个标记......:

我创建标记的功能:

    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);
    }
  });
}
4

1 回答 1

0

可以,

但不知道如何分别获取地址以列出...但得到了点击信息窗口:

function createMarkerAtual(point,info,dt,map) {
    var iconURL = 'img/dog2.png';               
    var iconSize = new google.maps.Size(45,45);
    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
    });

    google.maps.event.addListener(marker, 'click', function() {
        endereco(info,this.position);
        infowindow.open(map,this);
    });

  } 

function endereco(info,point){
    var geocoder = new google.maps.Geocoder();
    geocoder.geocode({'latLng': point}, function(results, status){
        if (status == google.maps.GeocoderStatus.OK){
            infowindow.setContent('<b>Coordenadas: </b>' + point + '<br><b>Dispositivo:</b> ' + info + '<br><b>Endereço: </b>' + results[0].formatted_address);
        } else {

        }
    });
} 
于 2013-10-25T17:48:24.043 回答