【问题标题】:Google map highlight KML layers on mouse click谷歌地图在鼠标点击时突出显示 KML 图层
【发布时间】:2014-12-27 11:51:24
【问题描述】:

我使用 gmap3 jquery 插件创建了一个地图,显示效果很好。

但是当我们在区域上移动鼠标时,我需要突出显示这些区域。

我使用 Google 地球创建了图层,并将其保存在 KML 文件中。当我调用 kml 文件时,它会显示 kml 文件中描述的所有选定区域。

1- 我只需要突出显示鼠标单击的区域。 2- 获取高亮区域的值/id/地址。

我尝试了一个代码:

$("#my_map").height(300).gmap3({marker:{
latLng: [25.185442, 55.280040],
options:{
  draggable:true
},
events:{
  dragend: function(marker){
    $(this).gmap3({
      getaddress:{
        latLng:marker.getPosition(),
        callback:function(results){
          var map = $(this).gmap3("get"),
            infowindow = $(this).gmap3({get:"infowindow"}),
            content = results && results[1] ? results && results[1].formatted_address : "no address";
          if (infowindow){
            infowindow.open(map, marker);
            infowindow.setContent(content);
          } else {
            $(this).gmap3({
      kmllayer:{
options:{
  url: "http://path_to_site/Dubai_Highlights.kml",
  opts:{
    suppressInfoWindows: true
  }
},
events:{
  click: function(kml, event){
    alert(content);
  }
}
}});
          }
}
      }
    });
  }
}
},
map:{
options:{
  zoom: 8
}
}

});

有一个网站 dubizzle.com,当“添加任何广告”时它们是 di(需要注册)。所以我附上截图。 http://i61.tinypic.com/3179p3b.png

【问题讨论】:

    标签: google-maps google-maps-api-3 jquery-gmap3


    【解决方案1】:

    您缺少 featureData 对象。您可以在 KML 覆盖here 上找到文档。此外,link 将有助于将其嵌入您的代码中。

    如果您想设置 KML 文件,上面第二个链接中提供了指向工具的链接。希望它是有帮助的。

    【讨论】:

      猜你喜欢
      • 2019-08-06
      • 1970-01-01
      • 1970-01-01
      • 2019-03-26
      • 1970-01-01
      • 1970-01-01
      • 2018-08-04
      • 1970-01-01
      • 2017-08-10
      相关资源
      最近更新 更多