Commit ac6e946b2b9f849d35095181b7826db4c41bcf76

Authored by Mrkartoshka
1 parent 5db2c85f

moved from Array<> to LatLngTuple[] types

... ... @@ -362,12 +362,12 @@ export default abstract class LeafletMap {
362 362 return L.latLng(lat, lng) as L.LatLng;
363 363 }
364 364
365   - convertPositionPolygon(expression:LatLngExpression[][] | LatLngExpression[][][]) {
366   - return (expression as Array<any>).map((el) => {
367   - if (el.length === 2 && !el.some(isNaN)) {
  365 + convertPositionPolygon(expression: (LatLngTuple | LatLngTuple[] | LatLngTuple[][])[]) {
  366 + return (expression).map((el) => {
  367 + if (!Array.isArray(el[0]) && el.length === 2) {
368 368 return el;
369   - } else if (isArray(el) && el.length) {
370   - return this.convertPositionPolygon(el);
  369 + } else if (Array.isArray(el) && el.length) {
  370 + return this.convertPositionPolygon(el as LatLngTuple[] | LatLngTuple[][]);
371 371 } else {
372 372 return null;
373 373 }
... ...
... ... @@ -224,14 +224,14 @@ export class ImageMap extends LeafletMap {
224 224 expression.y * this.height);
225 225 }
226 226
227   - convertPositionPolygon(expression: LatLngExpression[][] | LatLngExpression[][][]) {
228   - return (expression as Array<any>).map((el) => {
229   - if (el.length === 2 && !el.some(isNaN)) {
  227 + convertPositionPolygon(expression: (LatLngTuple | LatLngTuple[] | LatLngTuple[][])[]){
  228 + return (expression).map((el) => {
  229 + if (!Array.isArray(el[0]) && !Array.isArray(el[1]) && el.length === 2) {
230 230 return this.pointToLatLng(
231 231 el[0] * this.width,
232 232 el[1] * this.height)
233   - } else if (isArray(el) && el.length) {
234   - return this.convertPositionPolygon(el);
  233 + } else if (Array.isArray(el) && el.length) {
  234 + return this.convertPositionPolygon(el as LatLngTuple[] | LatLngTuple[][]);
235 235 } else {
236 236 return null;
237 237 }
... ...