Commit c661343a32ae8146297c04ee5e59c5c6085e9e02

Authored by Mrkartoshka
1 parent 423a491e

Fixed types

... ... @@ -8027,6 +8027,11 @@
8027 8027 "resolved": "https://registry.npmjs.org/leaflet/-/leaflet-1.6.0.tgz",
8028 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 8035 "leaflet-polylinedecorator": {
8031 8036 "version": "1.6.0",
8032 8037 "resolved": "https://registry.npmjs.org/leaflet-polylinedecorator/-/leaflet-polylinedecorator-1.6.0.tgz",
... ...
... ... @@ -330,7 +330,7 @@ export class MapWidgetController implements MapWidgetInterface {
330 330 update() {
331 331 const formattedData = parseData(this.data);
332 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 334 this.map.setDataSources(formattedData);
335 335 }
336 336 }
... ...
... ... @@ -22,7 +22,7 @@ import { WidgetContext } from '@home/models/widget-component.models';
22 22 export class OpenStreetMap extends LeafletMap {
23 23 constructor(ctx: WidgetContext, $container, options: UnitedMapSettings) {
24 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 26 let tileLayer;
27 27 if (options.useCustomProvider)
28 28 tileLayer = L.tileLayer(options.customProviderTileUrl);
... ...
... ... @@ -524,6 +524,11 @@ export const mapPolygonSchema =
524 524 type: 'string',
525 525 default: 'coordinates'
526 526 },
  527 + editablePolygon: {
  528 + title: 'Enable polygon edit',
  529 + type: 'boolean',
  530 + default: false
  531 + },
527 532 polygonColor: {
528 533 title: 'Polygon color',
529 534 type: 'string'
... ... @@ -581,6 +586,7 @@ export const mapPolygonSchema =
581 586 form: [
582 587 'showPolygon',
583 588 'polygonKeyName',
  589 + 'editablePolygon',
584 590 {
585 591 key: 'polygonColor',
586 592 type: 'color'
... ...
... ... @@ -14,7 +14,7 @@
14 14 /// limitations under the License.
15 15 ///
16 16
17   -import * as Leaflet from 'leaflet';
  17 +import * as leaflet from 'leaflet';
18 18
19 19 declare module 'leaflet' {
20 20
... ... @@ -31,7 +31,11 @@ declare module 'leaflet' {
31 31 /**
32 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 40 * Class to be used when creating a new Polyline.
37 41 */
... ... @@ -55,7 +59,7 @@ declare module 'leaflet' {
55 59 /**
56 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 65 * Default layer used to store drawn features (marker, polyline…).
... ... @@ -104,7 +108,7 @@ declare module 'leaflet' {
104 108 * This is not a plug and play UI, and will not. This is a minimal, lightweight, and fully extendable API to
105 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 113 * Options to pass to L.Editable when instanciating.
110 114 */
... ... @@ -172,15 +176,12 @@ declare module 'leaflet' {
172 176 }
173 177
174 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 182 * Options to pass to L.Editable when instanciating.
182 183 */
183   - editOptions: EditOptions;
  184 + editOptions: MapOptions;
184 185
185 186 /**
186 187 * L.Editable plugin instance.
... ... @@ -201,7 +202,7 @@ declare module 'leaflet' {
201 202 /**
202 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 270 interface Polyline extends EditableMixin, PolylineEditor {}
270 271
271 272 interface Polygon extends EditableMixin, PolygonEditor {}
  273 +
  274 + function map(element: string | HTMLElement, options?: EditOptions): Map;
272 275 }
... ...