Browse Source

Fixed types

pull/3280/head
Mrkartoshka 6 years ago
parent
commit
c661343a32
  1. 5
      ui-ngx/package-lock.json
  2. 2
      ui-ngx/src/app/modules/home/components/widget/lib/maps/map-widget2.ts
  3. 2
      ui-ngx/src/app/modules/home/components/widget/lib/maps/providers/openstreet-map.ts
  4. 6
      ui-ngx/src/app/modules/home/components/widget/lib/maps/schemes.ts
  5. 23
      ui-ngx/src/typings/leadflet-editable.d.ts

5
ui-ngx/package-lock.json

@ -8027,6 +8027,11 @@
"resolved": "https://registry.npmjs.org/leaflet/-/leaflet-1.6.0.tgz", "resolved": "https://registry.npmjs.org/leaflet/-/leaflet-1.6.0.tgz",
"integrity": "sha512-CPkhyqWUKZKFJ6K8umN5/D2wrJ2+/8UIpXppY7QDnUZW5bZL5+SEI2J7GBpwh4LIupOKqbNSQXgqmrEJopHVNQ==" "integrity": "sha512-CPkhyqWUKZKFJ6K8umN5/D2wrJ2+/8UIpXppY7QDnUZW5bZL5+SEI2J7GBpwh4LIupOKqbNSQXgqmrEJopHVNQ=="
}, },
"leaflet-editable": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/leaflet-editable/-/leaflet-editable-1.2.0.tgz",
"integrity": "sha512-wG11JwpL8zqIbypTop6xCRGagMuWw68ihYu4uqrqc5Ep0wnEJeyob7NB2Rt5t74Oih4rwJ3OfwaGbzdowOGfYQ=="
},
"leaflet-polylinedecorator": { "leaflet-polylinedecorator": {
"version": "1.6.0", "version": "1.6.0",
"resolved": "https://registry.npmjs.org/leaflet-polylinedecorator/-/leaflet-polylinedecorator-1.6.0.tgz", "resolved": "https://registry.npmjs.org/leaflet-polylinedecorator/-/leaflet-polylinedecorator-1.6.0.tgz",

2
ui-ngx/src/app/modules/home/components/widget/lib/maps/map-widget2.ts

@ -330,7 +330,7 @@ export class MapWidgetController implements MapWidgetInterface {
update() { update() {
const formattedData = parseData(this.data); const formattedData = parseData(this.data);
this.map.updateData(this.data, formattedData, this.drawRoutes, this.settings.showPolygon); this.map.updateData(this.data, formattedData, this.drawRoutes, this.settings.showPolygon);
if (this.settings.draggableMarker) { if (this.settings.draggableMarker || this.settings.editablePolygon) {
this.map.setDataSources(formattedData); this.map.setDataSources(formattedData);
} }
} }

2
ui-ngx/src/app/modules/home/components/widget/lib/maps/providers/openstreet-map.ts

@ -22,7 +22,7 @@ import { WidgetContext } from '@home/models/widget-component.models';
export class OpenStreetMap extends LeafletMap { export class OpenStreetMap extends LeafletMap {
constructor(ctx: WidgetContext, $container, options: UnitedMapSettings) { constructor(ctx: WidgetContext, $container, options: UnitedMapSettings) {
super(ctx, $container, options); super(ctx, $container, options);
const map = new L.Map($container, {editable: !!options.editablePolygon}).setView(options?.defaultCenterPosition, options?.defaultZoomLevel); const map = L.map($container, {editable: !!options.editablePolygon}).setView(options?.defaultCenterPosition, options?.defaultZoomLevel);
let tileLayer; let tileLayer;
if (options.useCustomProvider) if (options.useCustomProvider)
tileLayer = L.tileLayer(options.customProviderTileUrl); tileLayer = L.tileLayer(options.customProviderTileUrl);

6
ui-ngx/src/app/modules/home/components/widget/lib/maps/schemes.ts

@ -524,6 +524,11 @@ export const mapPolygonSchema =
type: 'string', type: 'string',
default: 'coordinates' default: 'coordinates'
}, },
editablePolygon: {
title: 'Enable polygon edit',
type: 'boolean',
default: false
},
polygonColor: { polygonColor: {
title: 'Polygon color', title: 'Polygon color',
type: 'string' type: 'string'
@ -581,6 +586,7 @@ export const mapPolygonSchema =
form: [ form: [
'showPolygon', 'showPolygon',
'polygonKeyName', 'polygonKeyName',
'editablePolygon',
{ {
key: 'polygonColor', key: 'polygonColor',
type: 'color' type: 'color'

23
ui-ngx/src/typings/leadflet-editable.d.ts

@ -14,7 +14,7 @@
/// limitations under the License. /// limitations under the License.
/// ///
import * as Leaflet from 'leaflet'; import * as leaflet from 'leaflet';
declare module 'leaflet' { declare module 'leaflet' {
@ -31,7 +31,11 @@ declare module 'leaflet' {
/** /**
* Options to pass to L.Editable when instanciating. * Options to pass to L.Editable when instanciating.
*/ */
interface EditOptions extends Leaflet.MapOptions{ interface EditOptions extends leaflet.MapOptions{
/**
* Whether to create a L.Editable instance at map init or not.
*/
editable: boolean;
/** /**
* Class to be used when creating a new Polyline. * Class to be used when creating a new Polyline.
*/ */
@ -55,7 +59,7 @@ declare module 'leaflet' {
/** /**
* Layer used to store edit tools (vertex, line guide…). * Layer used to store edit tools (vertex, line guide…).
*/ */
editLayer?: LayerGroup<Leaflet.Layer>; editLayer?: LayerGroup<leaflet.Layer>;
/** /**
* Default layer used to store drawn features (marker, polyline…). * Default layer used to store drawn features (marker, polyline…).
@ -104,7 +108,7 @@ declare module 'leaflet' {
* This is not a plug and play UI, and will not. This is a minimal, lightweight, and fully extendable API to * This is not a plug and play UI, and will not. This is a minimal, lightweight, and fully extendable API to
* control editing of geometries. So you can easily build your own UI with your own needs and choices. * control editing of geometries. So you can easily build your own UI with your own needs and choices.
*/ */
interface Editable extends Leaflet.Evented { interface Editable extends leaflet.Evented {
/** /**
* Options to pass to L.Editable when instanciating. * Options to pass to L.Editable when instanciating.
*/ */
@ -172,15 +176,12 @@ declare module 'leaflet' {
} }
interface Map { interface Map {
/**
* Whether to create a L.Editable instance at map init or not.
*/
editable: boolean;
/** /**
* Options to pass to L.Editable when instanciating. * Options to pass to L.Editable when instanciating.
*/ */
editOptions: EditOptions; editOptions: MapOptions;
/** /**
* L.Editable plugin instance. * L.Editable plugin instance.
@ -201,7 +202,7 @@ declare module 'leaflet' {
/** /**
* Options to pass to L.Editable when instanciating. * Options to pass to L.Editable when instanciating.
*/ */
editOptions?: EditOptions; editOptions?: MapOptions;
} }
} }
@ -269,4 +270,6 @@ declare module 'leaflet' {
interface Polyline extends EditableMixin, PolylineEditor {} interface Polyline extends EditableMixin, PolylineEditor {}
interface Polygon extends EditableMixin, PolygonEditor {} interface Polygon extends EditableMixin, PolygonEditor {}
function map(element: string | HTMLElement, options?: EditOptions): Map;
} }

Loading…
Cancel
Save