在 Google 地图中自定义 KML 图层时出现问题
我有一个文件,将新南威尔士州的选举边界覆盖在谷歌地图上。每个选区上弹出的标记在缩小时确实会干扰地图的视觉效果。我已经找到了如何禁用信息窗口,但无法弄清楚如何一起关闭标记。
地图示例在这里:
http://www.codepress.com.au/nsw_lower_house_map.html
关闭标记后,是否有办法使整个选区多边形可点击以在 JS 中使用?
I have got a file which overlays the state of New South Wales' electoral boundaries onto a Google Map. The markers which popup on each electorate really interfere with the visuals of the map when zoomed out. I have found how to disable the info window, but can't work out how to turn the markers off all together.
Map example is here:
http://www.codepress.com.au/nsw_lower_house_map.html
With markers turned off, is there then a way to make the whole electorate polygon clickable to work with in JS?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要使多边形可单击,请在将图层添加到地图后将事件侦听器绑定到图层。
上面将提醒您单击的要素的名称(前提是在 KML 中设置名称)。请注意:要使多边形能够“有效地”单击,需要设置填充。您的 KML 文件没有填充,因此唯一可单击的区域将是多边形的边界。您需要设置填充才能使此功能有用。
一般来说,KML 要素对象返回以下数据:
再次 - 前提是在 KML 中设置这些数据
要删除标记,您需要修改 KML 并删除所有地标及其包含的文件夹(其中未指定多边形) - 仅点数据(呈现为标记)。请确保在删除后重新验证您的 XML。
这是不带标记 http://www.mediafire.com/?f9ewd0c5ymk3ccv 的文件。但是,您需要确保多边形已设置填充,否则您将只能单击边框。
To make polygons clickable bind an event listener to a layer after you add layer to the map
The above will alert the name of the feature that you clicked on (providing the name is set in KML). PLEASE NOTE: for polygons to be "usefully" click able they need a fill to be set. Your KML file does not have the fill so the only area click able will be the border of the polygon. You will need to set the fill to make this feature useful.
In general The KML feature object returns the following data:
Again - providing these are set in KML
To get rid of the markers you will need to modify the KML and remove all Placemarks and their containing Folder which have no polygons specified in them - only Point data (which is rendered as a marker). Make sure you re-validate your XML after deletion.
Here is your file without the markers http://www.mediafire.com/?f9ewd0c5ymk3ccv . However you will need to make sure that your polys have fill set otherwise you will only be able to click on the borders.