1

我对信息窗口数据有错误。我无法得到请帮我检查我的代码。

function initialize() {

    map = new google.maps.Map(document.getElementById(map), {
    center: new google.maps.LatLng(1.352083, 103.819836),
    zoom: 12,
    mapTypeId: google.maps.MapTypeId.ROADMAP

    });

      //var infowindow;
      if (markers) {

        for (var level in markers) {
          for (var i = 0; i < markers[level].length; i++) {
            var details = markers[level][i];
                //var infowindow;
                  markers[level][i] = new google.maps.Marker({
                  title: details.name,
                  position: new google.maps.LatLng(
                  details.location[0], details.location[1]),
                  clickable: true,
                  draggable: false,
                  icon: details.icon
                });
                var infowindow = new google.maps.InfoWindow({
                    content: details.description,
                    //content : markers[level][i].description,
                    position: new google.maps.LatLng(details.location[0], details.location[1])
                    //position: markers[level][i].position
                });
            google.maps.event.addListener(markers[level][i], 'click', function() {
                infowindow.setPosition(this.position);
                alert(this.position);
                //infowindow.setContent(markers[level][i].description);
                infowindow.open(map,markers[level][i]);
            });
         }
        }
      }

我无法获取描述数据。请帮我检查我的代码。

4

0 回答 0