gpt4 book ai didi

leaflet - 使用 Leaflet.js 在全国范围内变暗/隐藏 map 的其余部分

转载 作者:行者123 更新时间:2023-12-04 11:51:39 28 4
gpt4 key购买 nike

除了标准的leaflet.js map 上的一个国家之外,是否可以将“世界其他地区”变暗或隐藏? Mabye 用某种带有国家轮廓的“倒多边形”覆盖?任何代码示例或链接将不胜感激。

最佳答案

扩展@tmcw 的答案......

秘诀是使用 http://leafletjs.com/reference.html#polygon 中描述的属性绘制多边形。

You can also create a polygon with holes by passing an array of arrays of latlngs, with the first latlngs array representing the exterior ring while the remaining represent the holes inside.



第一个多边形将是一个与 map 本身一样大的矩形,洞将是您要突出显示的国家/地区。
L.polygon( [outerBoundsLatLngs, latLngs] ); 

这是一个工作示例: http://jsfiddle.net/FranceImage/1yaqtx9u/

关于leaflet - 使用 Leaflet.js 在全国范围内变暗/隐藏 map 的其余部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25652189/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com