Showing
5 changed files
with
26 additions
and
12 deletions
@@ -8027,6 +8027,11 @@ | @@ -8027,6 +8027,11 @@ | ||
8027 | "resolved": "https://registry.npmjs.org/leaflet/-/leaflet-1.6.0.tgz", | 8027 | "resolved": "https://registry.npmjs.org/leaflet/-/leaflet-1.6.0.tgz", |
8028 | "integrity": "sha512-CPkhyqWUKZKFJ6K8umN5/D2wrJ2+/8UIpXppY7QDnUZW5bZL5+SEI2J7GBpwh4LIupOKqbNSQXgqmrEJopHVNQ==" | 8028 | "integrity": "sha512-CPkhyqWUKZKFJ6K8umN5/D2wrJ2+/8UIpXppY7QDnUZW5bZL5+SEI2J7GBpwh4LIupOKqbNSQXgqmrEJopHVNQ==" |
8029 | }, | 8029 | }, |
8030 | + "leaflet-editable": { | ||
8031 | + "version": "1.2.0", | ||
8032 | + "resolved": "https://registry.npmjs.org/leaflet-editable/-/leaflet-editable-1.2.0.tgz", | ||
8033 | + "integrity": "sha512-wG11JwpL8zqIbypTop6xCRGagMuWw68ihYu4uqrqc5Ep0wnEJeyob7NB2Rt5t74Oih4rwJ3OfwaGbzdowOGfYQ==" | ||
8034 | + }, | ||
8030 | "leaflet-polylinedecorator": { | 8035 | "leaflet-polylinedecorator": { |
8031 | "version": "1.6.0", | 8036 | "version": "1.6.0", |
8032 | "resolved": "https://registry.npmjs.org/leaflet-polylinedecorator/-/leaflet-polylinedecorator-1.6.0.tgz", | 8037 | "resolved": "https://registry.npmjs.org/leaflet-polylinedecorator/-/leaflet-polylinedecorator-1.6.0.tgz", |
@@ -330,7 +330,7 @@ export class MapWidgetController implements MapWidgetInterface { | @@ -330,7 +330,7 @@ export class MapWidgetController implements MapWidgetInterface { | ||
330 | update() { | 330 | update() { |
331 | const formattedData = parseData(this.data); | 331 | const formattedData = parseData(this.data); |
332 | this.map.updateData(this.data, formattedData, this.drawRoutes, this.settings.showPolygon); | 332 | this.map.updateData(this.data, formattedData, this.drawRoutes, this.settings.showPolygon); |
333 | - if (this.settings.draggableMarker) { | 333 | + if (this.settings.draggableMarker || this.settings.editablePolygon) { |
334 | this.map.setDataSources(formattedData); | 334 | this.map.setDataSources(formattedData); |
335 | } | 335 | } |
336 | } | 336 | } |
@@ -22,7 +22,7 @@ import { WidgetContext } from '@home/models/widget-component.models'; | @@ -22,7 +22,7 @@ import { WidgetContext } from '@home/models/widget-component.models'; | ||
22 | export class OpenStreetMap extends LeafletMap { | 22 | export class OpenStreetMap extends LeafletMap { |
23 | constructor(ctx: WidgetContext, $container, options: UnitedMapSettings) { | 23 | constructor(ctx: WidgetContext, $container, options: UnitedMapSettings) { |
24 | super(ctx, $container, options); | 24 | super(ctx, $container, options); |
25 | - const map = new L.Map($container, {editable: !!options.editablePolygon}).setView(options?.defaultCenterPosition, options?.defaultZoomLevel); | 25 | + const map = L.map($container, {editable: !!options.editablePolygon}).setView(options?.defaultCenterPosition, options?.defaultZoomLevel); |
26 | let tileLayer; | 26 | let tileLayer; |
27 | if (options.useCustomProvider) | 27 | if (options.useCustomProvider) |
28 | tileLayer = L.tileLayer(options.customProviderTileUrl); | 28 | tileLayer = L.tileLayer(options.customProviderTileUrl); |
@@ -524,6 +524,11 @@ export const mapPolygonSchema = | @@ -524,6 +524,11 @@ export const mapPolygonSchema = | ||
524 | type: 'string', | 524 | type: 'string', |
525 | default: 'coordinates' | 525 | default: 'coordinates' |
526 | }, | 526 | }, |
527 | + editablePolygon: { | ||
528 | + title: 'Enable polygon edit', | ||
529 | + type: 'boolean', | ||
530 | + default: false | ||
531 | + }, | ||
527 | polygonColor: { | 532 | polygonColor: { |
528 | title: 'Polygon color', | 533 | title: 'Polygon color', |
529 | type: 'string' | 534 | type: 'string' |
@@ -581,6 +586,7 @@ export const mapPolygonSchema = | @@ -581,6 +586,7 @@ export const mapPolygonSchema = | ||
581 | form: [ | 586 | form: [ |
582 | 'showPolygon', | 587 | 'showPolygon', |
583 | 'polygonKeyName', | 588 | 'polygonKeyName', |
589 | + 'editablePolygon', | ||
584 | { | 590 | { |
585 | key: 'polygonColor', | 591 | key: 'polygonColor', |
586 | type: 'color' | 592 | type: 'color' |
@@ -14,7 +14,7 @@ | @@ -14,7 +14,7 @@ | ||
14 | /// limitations under the License. | 14 | /// limitations under the License. |
15 | /// | 15 | /// |
16 | 16 | ||
17 | -import * as Leaflet from 'leaflet'; | 17 | +import * as leaflet from 'leaflet'; |
18 | 18 | ||
19 | declare module 'leaflet' { | 19 | declare module 'leaflet' { |
20 | 20 | ||
@@ -31,7 +31,11 @@ declare module 'leaflet' { | @@ -31,7 +31,11 @@ declare module 'leaflet' { | ||
31 | /** | 31 | /** |
32 | * Options to pass to L.Editable when instanciating. | 32 | * Options to pass to L.Editable when instanciating. |
33 | */ | 33 | */ |
34 | - interface EditOptions extends Leaflet.MapOptions{ | 34 | + interface EditOptions extends leaflet.MapOptions{ |
35 | + /** | ||
36 | + * Whether to create a L.Editable instance at map init or not. | ||
37 | + */ | ||
38 | + editable: boolean; | ||
35 | /** | 39 | /** |
36 | * Class to be used when creating a new Polyline. | 40 | * Class to be used when creating a new Polyline. |
37 | */ | 41 | */ |
@@ -55,7 +59,7 @@ declare module 'leaflet' { | @@ -55,7 +59,7 @@ declare module 'leaflet' { | ||
55 | /** | 59 | /** |
56 | * Layer used to store edit tools (vertex, line guide…). | 60 | * Layer used to store edit tools (vertex, line guide…). |
57 | */ | 61 | */ |
58 | - editLayer?: LayerGroup<Leaflet.Layer>; | 62 | + editLayer?: LayerGroup<leaflet.Layer>; |
59 | 63 | ||
60 | /** | 64 | /** |
61 | * Default layer used to store drawn features (marker, polyline…). | 65 | * Default layer used to store drawn features (marker, polyline…). |
@@ -104,7 +108,7 @@ declare module 'leaflet' { | @@ -104,7 +108,7 @@ declare module 'leaflet' { | ||
104 | * This is not a plug and play UI, and will not. This is a minimal, lightweight, and fully extendable API to | 108 | * This is not a plug and play UI, and will not. This is a minimal, lightweight, and fully extendable API to |
105 | * control editing of geometries. So you can easily build your own UI with your own needs and choices. | 109 | * control editing of geometries. So you can easily build your own UI with your own needs and choices. |
106 | */ | 110 | */ |
107 | - interface Editable extends Leaflet.Evented { | 111 | + interface Editable extends leaflet.Evented { |
108 | /** | 112 | /** |
109 | * Options to pass to L.Editable when instanciating. | 113 | * Options to pass to L.Editable when instanciating. |
110 | */ | 114 | */ |
@@ -172,15 +176,12 @@ declare module 'leaflet' { | @@ -172,15 +176,12 @@ declare module 'leaflet' { | ||
172 | } | 176 | } |
173 | 177 | ||
174 | interface Map { | 178 | interface Map { |
175 | - /** | ||
176 | - * Whether to create a L.Editable instance at map init or not. | ||
177 | - */ | ||
178 | - editable: boolean; | 179 | + |
179 | 180 | ||
180 | /** | 181 | /** |
181 | * Options to pass to L.Editable when instanciating. | 182 | * Options to pass to L.Editable when instanciating. |
182 | */ | 183 | */ |
183 | - editOptions: EditOptions; | 184 | + editOptions: MapOptions; |
184 | 185 | ||
185 | /** | 186 | /** |
186 | * L.Editable plugin instance. | 187 | * L.Editable plugin instance. |
@@ -201,7 +202,7 @@ declare module 'leaflet' { | @@ -201,7 +202,7 @@ declare module 'leaflet' { | ||
201 | /** | 202 | /** |
202 | * Options to pass to L.Editable when instanciating. | 203 | * Options to pass to L.Editable when instanciating. |
203 | */ | 204 | */ |
204 | - editOptions?: EditOptions; | 205 | + editOptions?: MapOptions; |
205 | } | 206 | } |
206 | } | 207 | } |
207 | 208 | ||
@@ -269,4 +270,6 @@ declare module 'leaflet' { | @@ -269,4 +270,6 @@ declare module 'leaflet' { | ||
269 | interface Polyline extends EditableMixin, PolylineEditor {} | 270 | interface Polyline extends EditableMixin, PolylineEditor {} |
270 | 271 | ||
271 | interface Polygon extends EditableMixin, PolygonEditor {} | 272 | interface Polygon extends EditableMixin, PolygonEditor {} |
273 | + | ||
274 | + function map(element: string | HTMLElement, options?: EditOptions): Map; | ||
272 | } | 275 | } |