Skip to content

Commit

Permalink
Add location pin on zoom in (#1966)
Browse files Browse the repository at this point in the history
* Preview Panels for WFNEWS-2122,2123,2124,2125,2130

* Clean up

* Update icon and css

* Zoom on evac select and open preview when one result identified

* Remove commented line

* Simplify current reference check on identify changes

* Add location pin on zoom in

* Clean up
  • Loading branch information
ssylver93 authored Jun 14, 2024
1 parent 39a8b42 commit 3fa5876
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</div>
<div class="button-row">
<div class="buttons">
<button mat-flat-button class="mobile-button" (click)="zoomIn()" >
<button mat-flat-button class="mobile-button" (click)="zoomInWithLocationPin()" >
<mat-icon class="incident-icon-title" svgIcon='zoom-in'></mat-icon>
Zoom to
</button>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component } from '@angular/core';
import { MapConfigService } from '@app/services/map-config.service';
import { convertToDateYear, hidePanel, showPanel, getActiveMap } from '@app/utils';
import { convertToDateYear, hidePanel, showPanel, zoomInWithLocationPin } from '@app/utils';

@Component({
selector: 'wfnews-closed-rec-sites',
Expand All @@ -11,8 +11,10 @@ export class ClosedRecSitesComponent {
constructor(private mapConfigService: MapConfigService) {}

convertToDateYear = convertToDateYear;
zoomInWithLocationPin = zoomInWithLocationPin;
public data;
defaultZoomLevel = 13;
defaultZoomLevel = 11;
pinDrop;

setContent(data) {
this.data = data;
Expand All @@ -27,19 +29,4 @@ export class ClosedRecSitesComponent {
hidePanel('desktop-preview');
}

zoomIn(){
const long = Number(this.data?._identifyPoint?.longitude);
const lat = Number(this.data?._identifyPoint?.latitude);

if(long && lat) {
this.mapConfigService.getMapConfig().then(() => {
getActiveMap().$viewer.panToFeature(
window['turf'].point([long, lat]),
this.defaultZoomLevel
);
});
}
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
</div>
<div class="button-row">
<div class="buttons">
<button mat-flat-button class="mobile-button" (click)="zoomIn()">
<button mat-flat-button class="mobile-button" (click)="zoomInWithLocationPin()">
<mat-icon class="incident-icon-title" svgIcon='zoom-in'></mat-icon>
Zoom to
</button>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component } from '@angular/core';
import { MapConfigService } from '@app/services/map-config.service';
import { convertToDateYear, hidePanel, showPanel, openLink, getActiveMap } from '@app/utils';
import { convertToDateYear, hidePanel, showPanel, openLink, zoomInWithLocationPin } from '@app/utils';
import { AppConfigService } from '@wf1/core-ui';

@Component({
Expand All @@ -14,8 +14,10 @@ export class RoadEventsPreviewComponent {

convertToDateYear = convertToDateYear;
openLink = openLink
zoomInWithLocationPin = zoomInWithLocationPin;
public data;
defaultZoomLevel = 13;
defaultZoomLevel = 11;
pinDrop;

setContent(data) {
this.data = data;
Expand All @@ -29,19 +31,5 @@ export class RoadEventsPreviewComponent {
showPanel('identify-panel-wrapper')
hidePanel('desktop-preview');
}

zoomIn(){
const long = Number(this.data?._identifyPoint?.longitude);
const lat = Number(this.data?._identifyPoint?.latitude);

if(long && lat) {
this.mapConfigService.getMapConfig().then(() => {
getActiveMap().$viewer.panToFeature(
window['turf'].point([long, lat]),
this.defaultZoomLevel
);
});
}
}

}
35 changes: 35 additions & 0 deletions client/wfnews-war/src/main/angular/src/app/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -879,3 +879,38 @@ export function addMarker(incident: any) {
const viewer = getActiveMap().$viewer;
this.marker.addTo(viewer.map);
}

export function zoomInWithLocationPin(){
const viewer = getActiveMap().$viewer;
const long = Number(this.data?._identifyPoint?.longitude);
const lat = Number(this.data?._identifyPoint?.latitude);

if(long && lat) {
this.mapConfigService.getMapConfig().then(() => {
getActiveMap().$viewer.panToFeature(
window['turf'].point([long, lat]),
this.defaultZoomLevel
);
});
const markerOptions = {
icon: L.divIcon({
className: 'custom-icon-class',
html: `<div class="custom-marker" style="margin-top:-30px">
<img alt="icon" src="/assets/images/svg-icons/pin-drop.svg"/>
</div>`,
iconSize: [32, 32],
}),
draggable: false,
};
if (this.pinDrop) {
viewer.map.removeLayer(this.pinDrop);
}

this.pinDrop = L.marker(
[lat, long],
markerOptions,
).addTo(viewer.map);
}
}


0 comments on commit 3fa5876

Please sign in to comment.