moved from Array<> to LatLngTuple[] types

This commit is contained in:
Mrkartoshka 2020-08-11 16:23:41 +03:00
parent 5db2c85f4c
commit ac6e946b2b
2 changed files with 10 additions and 10 deletions

View File

@ -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;
} }

View File

@ -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;
} }