Editable polygons

This commit is contained in:
Mrkartoshka 2020-08-11 13:36:13 +03:00
parent 5596bd9f61
commit 9413b68ebf
3 changed files with 133 additions and 133 deletions

File diff suppressed because one or more lines are too long

View File

@ -17,7 +17,7 @@
import L, { import L, {
FeatureGroup, FeatureGroup,
Icon, Icon,
LatLngBounds, LatLngBounds, LatLngExpression,
LatLngTuple, LatLngTuple,
markerClusterGroup, markerClusterGroup,
MarkerClusterGroup, MarkerClusterGroup,
@ -362,7 +362,7 @@ export default abstract class LeafletMap {
return L.latLng(lat, lng) as L.LatLng; return L.latLng(lat, lng) as L.LatLng;
} }
convertPositionPolygon(expression: Array<[number, number]> | Array<Array<[number, number]>>) { convertPositionPolygon(expression:LatLngExpression[][] | LatLngExpression[][][]) {
return (expression as Array<any>).map((el) => { return (expression as Array<any>).map((el) => {
if (el.length === 2 && !el.some(isNaN)) { if (el.length === 2 && !el.some(isNaN)) {
return el; return el;
@ -395,7 +395,7 @@ export default abstract class LeafletMap {
} }
} }
convertPolygonToCustomFormat(expression: Array<Array<any>>): object { convertPolygonToCustomFormat(expression: any[][]): object {
return { return {
[this.options.polygonKeyName] : this.convertToPolygonFormat(expression) [this.options.polygonKeyName] : this.convertToPolygonFormat(expression)
} }

View File

@ -14,7 +14,7 @@
/// limitations under the License. /// limitations under the License.
/// ///
import L, { LatLngBounds, LatLngLiteral, LatLngTuple } from 'leaflet'; import L, {LatLngBounds, LatLngExpression, LatLngLiteral, LatLngTuple} from 'leaflet';
import LeafletMap from '../leaflet-map'; import LeafletMap from '../leaflet-map';
import { MapImage, PosFuncton, UnitedMapSettings } from '../map-models'; import { MapImage, PosFuncton, UnitedMapSettings } from '../map-models';
import { Observable, ReplaySubject } from 'rxjs'; import { Observable, ReplaySubject } from 'rxjs';
@ -224,7 +224,7 @@ export class ImageMap extends LeafletMap {
expression.y * this.height); expression.y * this.height);
} }
convertPositionPolygon(expression: Array<[number, number]> | Array<Array<[number, number]>>) { convertPositionPolygon(expression: LatLngExpression[][] | LatLngExpression[][][]) {
return (expression as Array<any>).map((el) => { return (expression as Array<any>).map((el) => {
if (el.length === 2 && !el.some(isNaN)) { if (el.length === 2 && !el.some(isNaN)) {
return this.pointToLatLng( return this.pointToLatLng(
@ -269,7 +269,7 @@ export class ImageMap extends LeafletMap {
} }
} }
convertPolygonToCustomFormat(expression: Array<Array<any>>): object { convertPolygonToCustomFormat(expression: any[][]): object {
return { return {
[this.options.polygonKeyName] : this.convertToPolygonFormat(expression) [this.options.polygonKeyName] : this.convertToPolygonFormat(expression)
} }