1 Star 10 Fork 2

ptma / Leaflet.Mask

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

Leaflet.Mask

Leaflet.Mask 是一个 Leaflet 插件, 用于将边界数据以外的地图区域遮盖起来,可以用它来实现重点显示局部地图区域的效果。

在线 demo.

Preview

用法示例

var map = L.map("map", {
    center: [29, 120],
    zoom: 8
});
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
    attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);

L.mask('bound.json', {}).addTo(map);

调用

L.mask(geosjon, options?)
参数 类型 描述
geosjon String|Object .geojson URL 或 GeoJSON 对象
options Object 遮罩图层选项

选项

选项 类型 默认值 描述
interactive Boolean false 如果为 false,遮罩层将不处理鼠标事件,行为形同基础图层。
fitBounds Boolean true 如果为 true,地图会自动放大缩放等级到遮罩区域的最大边界。
restrictBounds Boolean true 如果为 true,地图将被会限制移动出遮罩区域。

继承自 L.Path 的样式选项

选项 类型 默认值 描述
stroke Boolean true 是否绘制边框。
color String '#3388ff' 边框颜色。
weight Number 2 边框宽度。
opacity Number 1.0 边框透明度。
lineCap String 'round' 指定如何绘制每一条线段末端的属性。有 3 个可能的值,分别是:'butt','round' 或 ’square‘。
lineJoin String 'round' 用来设置2个长度不为0的相连部分(线段,圆弧,曲线)如何连接在一起的属性(长度为0的变形部分,其指定的末端和控制点在同一位置,会被忽略)。
dashArray String null 控制用来描边的点划线的图案范式。
dashOffset String null dash模式到路径开始的距离。
fill Boolean depends 是否用颜色填充。
fillColor String '#FFFFFF' 填充色。
fillOpacity Number 0.2 填充透明度。
fillRule String 'evenodd' 填充规则。
MIT License Copyright (c) 2020 ptma@163.com Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

从 geojson 加载多边形数据并遮盖地图的其余部分 展开 收起
JavaScript
MIT
取消

发行版 (1)

全部

贡献者

全部

近期动态

加载更多
不能加载更多了
JavaScript
1
https://gitee.com/ptma/Leaflet.Mask.git
git@gitee.com:ptma/Leaflet.Mask.git
ptma
Leaflet.Mask
Leaflet.Mask
master

搜索帮助