标记的某些部分的事件不起作用

问题描述 投票:-1回答:1

我有一个看起来像这样的代码

var data = [tons of lat long];

/* Create the markers */
for (var i = 0; i = data.length; i++) {
    /* Put the markers */

    var marker = new google.maps.Marker({
    position: { 
        lat: parseFloat(lat1),
        lng: parseFloat(lng1)
    },
      map: map,
      icon: icon,
      label: {
        text: "Testing"
        color: 'black',
        fontSize: "9px"
      }
    });

    /* create popup */
    marker.content = sndformat();

     /* Put the pop up in the markers */
    var infoWindow = new google.maps.InfoWindow();

    /* Marker events  On Click */
    google.maps.event.addListener(marker, 'click', function (event) {
        /* Display popup */
        infoWindow.setContent(this.content);
        infoWindow.open(this.getMap(), this);

        /* Zoom In */
        curmarker = this.position;
        map.setCenter(curmarker);
        map.setZoom(20);

        /* If zoom out image has been clicked */
        $('#imgclick').bind('click', function() {          
          map.setCenter(default latlong);
          map.setZoom(7);
        });
    });
}

现在这是我的问题。专注于此2

marker.content = sndformat();

function sndformat() {
    return 'a Image with a name and id called imgclick'
}

上面的示例代码工作,其输出是创建一个标记,弹出窗口上有一个按钮,所以当我点击标记时它会放大,当我点击弹出窗口上的图像时,它会缩小或转到默认区域。

这里我的问题是放大工作但是当图像点击不能在所有按钮上工作时只有一些缩小

javascript jquery google-maps google-maps-api-3
1个回答
0
投票

找到了。

$('#imgclick').bind('click', function() {
                      center = {lat: 12.8797, lng: 121.7740};          
                      map.setCenter(center);
                      map.setZoom(7);
                    });
© www.soinside.com 2019 - 2024. All rights reserved.