diff --git a/projects/library/src/lib/components/map-outlet/map-outlet.component.html b/projects/library/src/lib/components/map-outlet/map-outlet.component.html index 9b692a1..d348a49 100644 --- a/projects/library/src/lib/components/map-outlet/map-outlet.component.html +++ b/projects/library/src/lib/components/map-outlet/map-outlet.component.html @@ -6,6 +6,7 @@ [(zoom)]="zoom" (zoomChange)="updateZoom($event)" [(center)]="center" + [lock]="lock" (centerChange)="updateCenter($event)" [map]="map" [element]="map_element" diff --git a/projects/library/src/lib/components/map-outlet/map-outlet.component.ts b/projects/library/src/lib/components/map-outlet/map-outlet.component.ts index cc08023..fe3f46a 100644 --- a/projects/library/src/lib/components/map-outlet/map-outlet.component.ts +++ b/projects/library/src/lib/components/map-outlet/map-outlet.component.ts @@ -50,6 +50,8 @@ export class MapOutletComponent implements OnInit, OnChanges, OnDestroy { @Input() public listeners: MapListener[] = []; /** List of text to render over the map */ @Input() public text: MapRenderFeature[] = []; + /** Whether Map cannot be moved */ + @Input() public lock: boolean; /** Emitter for changes to the zoom value */ @Output() public zoomChange = new EventEmitter(); /** Emitter for changes to the center value */ diff --git a/projects/library/src/lib/components/map/map.component.html b/projects/library/src/lib/components/map/map.component.html index d0a0ca3..fe15a11 100644 --- a/projects/library/src/lib/components/map/map.component.html +++ b/projects/library/src/lib/components/map/map.component.html @@ -9,4 +9,5 @@ [listeners]="listeners" [text]="text_list" [class.locked]="options?.lock" + [lock]="lock" > diff --git a/projects/library/src/lib/components/map/map.component.ts b/projects/library/src/lib/components/map/map.component.ts index 7bcfb02..c49ba9f 100644 --- a/projects/library/src/lib/components/map/map.component.ts +++ b/projects/library/src/lib/components/map/map.component.ts @@ -45,6 +45,8 @@ export class MapComponent implements OnInit, OnChanges, OnDestroy { @Input() public focus: string | Point; /** Optional flags for the map */ @Input() public options: MapOptions; + /** Whether Map cannot be moved */ + @Input() public lock: boolean; /** Emitter for changes to the zoom value */ @Output() public zoomChange = new EventEmitter(); /** Emitter for changes to the center value */ diff --git a/projects/library/src/lib/directives/map-center.directive.ts b/projects/library/src/lib/directives/map-center.directive.ts index 1ec0c4a..53c6d83 100644 --- a/projects/library/src/lib/directives/map-center.directive.ts +++ b/projects/library/src/lib/directives/map-center.directive.ts @@ -29,6 +29,8 @@ export class MapCenterDirective implements OnDestroy { @Input() public center: Point; /** Element containing the map */ @Input() public element: ElementRef; + /** Lock Map */ + @Input() public lock: boolean; /** Emitter for changes to the center value */ @Output() public centerChange = new EventEmitter(); /** Bound box of the host element */ @@ -44,11 +46,13 @@ export class MapCenterDirective implements OnDestroy { @HostListener('mousedown', ['$event']) public startMoveMouse(event: MouseEvent) { + if (this.lock) { return; } this.startMove(event); } @HostListener('touchstart', ['$event']) public startMoveTouch(event: any) { + if (this.lock) { return; } this.startMove(event); } @@ -103,6 +107,9 @@ export class MapCenterDirective implements OnDestroy { */ private move(event: MouseEvent | TouchEvent) { if (!this._box) { return; } + if (this.lock) { + return; + } const position = eventToPoint(event); if (!insideRect(position, this._parent_box)) { return; } event.preventDefault();