Leaflet: Polygon Constructor with Multi-Dimensional Array (#18260)

This commit is contained in:
Markus Chmelar 2017-07-21 00:53:59 +02:00 committed by Wesley Wigham
parent 2b0f00ff27
commit b50f4e4556
2 changed files with 12 additions and 2 deletions

View File

@ -615,13 +615,13 @@ declare namespace L {
function polyline(latlngs: LatLngExpression[], options?: PolylineOptions): Polyline;
class Polygon extends InternalPolyline {
constructor(latlngs: LatLngExpression[], options?: PolylineOptions);
constructor(latlngs: LatLngExpression[] | LatLngExpression[][], options?: PolylineOptions);
toGeoJSON(): GeoJSONFeature<GeoJSONPolygon | GeoJSONMultiPolygon>;
feature?: GeoJSONFeature<GeoJSONPolygon | GeoJSONMultiPolygon>;
}
function polygon(latlngs: LatLngExpression[], options?: PolylineOptions): Polygon;
function polygon(latlngs: LatLngExpression[] | LatLngExpression[][], options?: PolylineOptions): Polygon;
class Rectangle extends Polygon {
constructor(latLngBounds: LatLngBoundsExpression, options?: PolylineOptions);

View File

@ -450,6 +450,16 @@ L.marker([1, 2], {
className: 'my-div-icon'
}));
const latLngs = [
{ lat: 0, lng: 0 },
{ lat: 1, lng: 1 }
];
let polygon = new L.Polygon(latLngs);
let polygonExclusion = new L.Polygon([latLngs, latLngs]);
L.polygon(latLngs).addTo(map);
L.polygon([latLngs, latLngs]).addTo(map);
L.Util.extend({});
L.Util.create({});
L.Util.bind(() => {}, {});