Browse Source
Merge pull request #5755 from vvlladd28/maps/edit-rectangle/cut
[3.3.2] UI: Fixed incorrect work edit rectangle with cut
pull/5762/head
Igor Kulikov
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
11 additions and
4 deletions
-
ui-ngx/src/app/modules/home/components/widget/lib/maps/leaflet-map.ts
-
ui-ngx/src/app/modules/home/components/widget/lib/maps/maps-utils.ts
-
ui-ngx/src/app/modules/home/components/widget/lib/maps/polygon.ts
|
|
|
@ -775,7 +775,7 @@ export default abstract class LeafletMap { |
|
|
|
if (coordinates.length === 1) { |
|
|
|
coordinates = coordinates[0]; |
|
|
|
} |
|
|
|
if (e.shape === 'Rectangle') { |
|
|
|
if (e.shape === 'Rectangle' && coordinates.length === 1) { |
|
|
|
// @ts-ignore
|
|
|
|
const bounds: L.LatLngBounds = e.layer.getBounds(); |
|
|
|
const boundsArray = [bounds.getNorthWest(), bounds.getNorthEast(), bounds.getSouthWest(), bounds.getSouthEast()]; |
|
|
|
|
|
|
|
@ -56,3 +56,10 @@ export function bindPopupActions(popup: L.Popup, settings: MarkerSettings | Poly |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
export function isCutPolygon(data): boolean { |
|
|
|
if (Array.isArray(data[0]) && Array.isArray(data[0][0])) { |
|
|
|
return true; |
|
|
|
} |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
@ -15,7 +15,7 @@ |
|
|
|
///
|
|
|
|
|
|
|
|
import L, { LatLngExpression, LeafletMouseEvent } from 'leaflet'; |
|
|
|
import { createTooltip } from './maps-utils'; |
|
|
|
import { createTooltip, isCutPolygon } from './maps-utils'; |
|
|
|
import { |
|
|
|
fillPattern, |
|
|
|
functionValueCalculator, |
|
|
|
@ -39,7 +39,7 @@ export class Polygon { |
|
|
|
const polygonColor = this.getPolygonColor(settings); |
|
|
|
const polygonStrokeColor = this.getPolygonStrokeColor(settings); |
|
|
|
const polyData = data[this.settings.polygonKeyName]; |
|
|
|
const polyConstructor = polyData.length > 2 ? L.polygon : L.rectangle; |
|
|
|
const polyConstructor = isCutPolygon(polyData) || polyData.length > 2 ? L.polygon : L.rectangle; |
|
|
|
this.leafletPoly = polyConstructor(polyData, { |
|
|
|
fill: true, |
|
|
|
fillColor: polygonColor, |
|
|
|
@ -102,7 +102,7 @@ export class Polygon { |
|
|
|
this.data = data; |
|
|
|
this.dataSources = dataSources; |
|
|
|
const polyData = data[this.settings.polygonKeyName]; |
|
|
|
if (polyData.length > 2) { |
|
|
|
if (isCutPolygon(polyData) || polyData.length > 2) { |
|
|
|
if (this.leafletPoly instanceof L.Rectangle) { |
|
|
|
this.map.removeLayer(this.leafletPoly); |
|
|
|
const polygonColor = this.getPolygonColor(settings); |
|
|
|
|