我有一个谷歌地图高程服务(适用于我的宾夕法尼亚州地理学生),在谷歌的 basemap 上点击可以正常工作。我想添加一个显示 PA 县的 kml 图层。当我添加它时,海拔信息窗口不再显示。有没有办法添加 kml 但抑制其点击响应以显示高程响应?
当前代码(部分):
function initialize() {
var mapOptions = {
zoom: 7,
center: centerOfPA,
mapTypeId: 'roadmap'
}
map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
var paCounties = new google.maps.KmlLayer('http://mapmaker.millersville.edu/arcgis/services/PAcounties/MapServer/KmlServer', {suppressInfoWindows: true});
paCounties.setMap(map);
// Create an ElevationService
elevator = new google.maps.ElevationService();
// Add a listener for the click event and call getElevation on that location
google.maps.event.addListener(map, 'click', getElevation);
}
最佳答案
抑制 KmlLayer 上的点击事件(可点击:false)或处理点击事件并调用高程服务(使用来自 click event 的 latLng)。
Here is a working example
关于google-maps - kml 阻止高程服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12940109/