gpt4 book ai didi

leaflet - 单张:反向/反向多边形样式

转载 作者:行者123 更新时间:2023-12-04 22:32:17 25 4
gpt4 key购买 nike

我有一个geojson格式的省界多边形。我想要的是在 map 上显示该省份,使非省份区域显示为灰色(不透明),而省份区域显示为不带样式。我怎样才能做到这一点?

最佳答案

Polygon api documentation:

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.



因此,我认为您可以使用它为外圈制作一个非常大的多边形,并在内部将孔切成一个小孔。当然,如果缩放到比大多边形大的水平,那看起来会很尴尬。也许最好设置一个最小缩放级别,以免发生这种情况。
var polygon = L.polygon(
[[[52, -1],
[52, 1],
[50, 1],
[50, -1]], //outer ring
[[51.509, -0.08],
[51.503, -0.07],
[51.51, -0.047]]] // cutout
).addTo(map);

JSfiddle

或设置外部多边形以覆盖整个世界:
[[90, -180],
[90, 180],
[-90, 180],
[-90, -180]]

关于leaflet - 单张:反向/反向多边形样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18082192/

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