如何放大到kml中标记的位置

How to zoom in to the location of the marker in kml

我正在使用 kml 文件在 google 地图上显示位置。我想在单击标记时放大到该标记位置。这是我的 kml 图层代码,

 function initMap() {
    map = new google.maps.Map(document.getElementById('map'), {
      center: new google.maps.LatLng(11.024747, 76.898037),
      zoom: 2,
      mapTypeId: 'terrain'
    });

    var kmlLayer = new google.maps.KmlLayer(src, {
      suppressInfoWindows: true,
      preserveViewport: false,
      map: map
    });



    kmlLayer.addListener('click', function(event) {
      var content = event.featureData.infoWindowHtml;
      var testimonial = document.getElementById('capture');
      testimonial.innerHTML = content;
     });
  }

请帮帮我

您可以使用 event.latLng 并手动设置缩放级别缩放至点击的经纬度。

  kmlLayer.addListener('click', function(event) {

     map.setCenter(event.latLng);
     map.setZoom(20)

     var content = event.featureData.infoWindowHtml;
     var testimonial = document.getElementById('capture');
     testimonial.innerHTML = content;
  });

请找到这个 fiddle -> https://jsfiddle.net/Rohith_KP/mcwzh4an/1/