我正在使用kml文件在谷歌地图上显示位置。我想放大标记位置,同时单击标记。这是我的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;
});
}
请帮帮我
答案 0 :(得分:1)
您可以使用event.latLng
缩放到单击的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;
});
请找到这个小提琴 - > https://jsfiddle.net/Rohith_KP/mcwzh4an/1/