Skip to content

Load polygons from geojson to masking the rest of the map.

License

Notifications You must be signed in to change notification settings

ptma/Leaflet.Mask

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

7 Commits

Repository files navigation

Leaflet.Mask

Leaflet.Mask is a Leaflet plugin that loading polygons from geojson to masking the rest of the map.

Check out the demo.

Preview

Useage example

varmap=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);

Creation

L.mask(geosjon,options?)
ParameterTypeDescription
geosjonString|Object.geojson URL or GeoJSON object
optionsObjectLayer options

Options

OptionTypeDefaultDescription
interactiveBooleanfalseIf false, the mask layer will not emit mouse events and will act as a part of the underlying map.
fitBoundsBooleantrueIf true, the map fits the maximum zoom level to the given geographical bounds.
restrictBoundsBooleantrueIf true, the map restricts the view to the given geographical bounds, bouncing the user back if the user tries to pan outside the view.

Options inherited from L.Path

OptionTypeDefaultDescription
strokeBooleantrueWhether to draw stroke along the path. Set it to false to disable borders on polygons or circles.
colorString'#3388ff'Stroke color
weightNumber2Stroke width in pixels
opacityNumber1.0Stroke opacity
lineCapString'round'A string that defines shape to be used at the end of the stroke.
lineJoinString'round'A string that defines shape to be used at the corners of the stroke.
dashArrayStringnullA string that defines the stroke dash pattern. Doesn't work on Canvas-powered layers in some old browsers.
dashOffsetStringnullA string that defines the distance into the dash pattern to start the dash. Doesn't work on Canvas-powered layers in some old browsers.
fillBooleandependsWhether to fill the path with color. Set it to false to disable filling on polygons or circles.
fillColorString'#FFFFFF'Fill color.
fillOpacityNumber1.0Fill opacity.
fillRuleString'evenodd'A string that defines how the inside of a shape is determined.

About

Load polygons from geojson to masking the rest of the map.

Resources

License

Stars

Watchers

Forks

Packages

No packages published