Browse Source

moved from Array<> to LatLngTuple[] types

pull/3280/head
Mrkartoshka 6 years ago
parent
commit
ac6e946b2b
  1. 10
      ui-ngx/src/app/modules/home/components/widget/lib/maps/leaflet-map.ts
  2. 10
      ui-ngx/src/app/modules/home/components/widget/lib/maps/providers/image-map.ts

10
ui-ngx/src/app/modules/home/components/widget/lib/maps/leaflet-map.ts

@ -362,12 +362,12 @@ export default abstract class LeafletMap {
return L.latLng(lat, lng) as L.LatLng; return L.latLng(lat, lng) as L.LatLng;
} }
convertPositionPolygon(expression:LatLngExpression[][] | LatLngExpression[][][]) { convertPositionPolygon(expression: (LatLngTuple | LatLngTuple[] | LatLngTuple[][])[]) {
return (expression as Array<any>).map((el) => { return (expression).map((el) => {
if (el.length === 2 && !el.some(isNaN)) { if (!Array.isArray(el[0]) && el.length === 2) {
return el; return el;
} else if (isArray(el) && el.length) { } else if (Array.isArray(el) && el.length) {
return this.convertPositionPolygon(el); return this.convertPositionPolygon(el as LatLngTuple[] | LatLngTuple[][]);
} else { } else {
return null; return null;
} }

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

@ -224,14 +224,14 @@ export class ImageMap extends LeafletMap {
expression.y * this.height); expression.y * this.height);
} }
convertPositionPolygon(expression: LatLngExpression[][] | LatLngExpression[][][]) { convertPositionPolygon(expression: (LatLngTuple | LatLngTuple[] | LatLngTuple[][])[]){
return (expression as Array<any>).map((el) => { return (expression).map((el) => {
if (el.length === 2 && !el.some(isNaN)) { if (!Array.isArray(el[0]) && !Array.isArray(el[1]) && el.length === 2) {
return this.pointToLatLng( return this.pointToLatLng(
el[0] * this.width, el[0] * this.width,
el[1] * this.height) el[1] * this.height)
} else if (isArray(el) && el.length) { } else if (Array.isArray(el) && el.length) {
return this.convertPositionPolygon(el); return this.convertPositionPolygon(el as LatLngTuple[] | LatLngTuple[][]);
} else { } else {
return null; return null;
} }

Loading…
Cancel
Save