-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(geo): adding initial button component files (#957)
* adding initial button component files * correcting initialbutton * corrections to initial button * correction to initial button * Button name changed to home-extent-button * adding package.json as required * minors fix * fix package * refactor(home-extent-button): update with config * fix event parameter * feat(home-extent): allow to provide homeExtent properties from context Co-authored-by: Philippe Lafreniere <philippe.lafreniere@msp.gouv.qc.ca> Co-authored-by: Pierre-Etienne Lord
- Loading branch information
1 parent
f0366a0
commit 81f0ace
Showing
15 changed files
with
102 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
packages/geo/src/lib/map/home-extent-button/home-extent-button.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<div class="igo-home-extent-button-container"><button | ||
mat-icon-button | ||
[matTooltip]="'igo.geo.mapButtons.home-extent' | translate" | ||
matTooltipPosition="left" | ||
[color]="color" | ||
(click)="onToggleClick()"><mat-icon svgIcon = "home-map-marker"></mat-icon></button></div> |
13 changes: 13 additions & 0 deletions
13
packages/geo/src/lib/map/home-extent-button/home-extent-button.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
@import '../../../../../core/src/style/partial/core.variables'; | ||
|
||
.igo-home-extent-button-container { | ||
width: $igo-icon-size; | ||
background-color: #fff; | ||
&:hover { | ||
background-color: #efefef; | ||
} | ||
} | ||
button, | ||
:host ::ng-deep button .mat-button-ripple-round { | ||
border-radius: 0; | ||
} |
50 changes: 50 additions & 0 deletions
50
packages/geo/src/lib/map/home-extent-button/home-extent-button.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { ConfigService } from '@igo2/core'; | ||
import { Component, Input } from '@angular/core'; | ||
import { IgoMap } from '../shared/map'; | ||
import { MapExtent } from '../shared/map.interface'; | ||
import * as olproj from 'ol/proj'; | ||
/* | ||
Button to center the map to the home extent | ||
*/ | ||
@Component({ | ||
selector: 'igo-home-extent-button', | ||
templateUrl:'./home-extent-button.component.html', | ||
styleUrls: ['./home-extent-button.component.scss'], | ||
}) | ||
export class HomeExtentButtonComponent { | ||
@Input() map: IgoMap; | ||
@Input() color: string; | ||
@Input() extentOverride?: MapExtent | ||
@Input() centerOverride?: [number, number]; | ||
@Input() zoomOverride?: number; | ||
|
||
private homeExtentButtonExtent; | ||
private homeExtentButtonCenter; | ||
private homeExtentButtonZoom; | ||
|
||
constructor(public configService: ConfigService) { | ||
this.computeHomeExtent(); | ||
} | ||
|
||
computeHomeExtent() { | ||
this.homeExtentButtonExtent = this.extentOverride || this.configService.getConfig('homeExtentButton.homeExtButtonExtent'); | ||
this.homeExtentButtonCenter = this.centerOverride || this.configService.getConfig('homeExtentButton.homeExtButtonCenter'); | ||
this.homeExtentButtonZoom = this.zoomOverride || this.configService.getConfig('homeExtentButton.homeExtButtonZoom'); | ||
|
||
// priority over extent if these 2 properties are defined; | ||
if (this.centerOverride && this.zoomOverride) { | ||
this.homeExtentButtonExtent = undefined; | ||
} | ||
} | ||
|
||
onToggleClick() { | ||
this.computeHomeExtent(); | ||
if (this.homeExtentButtonExtent) { | ||
this.map.viewController.zoomToExtent(this.homeExtentButtonExtent); | ||
} else if (this.homeExtentButtonCenter && this.homeExtentButtonZoom) { | ||
const center = olproj.fromLonLat(this.homeExtentButtonCenter, this.map.viewController.olView.getProjection().getCode()); | ||
this.map.viewController.olView.setCenter(center); | ||
this.map.viewController.zoomTo(this.homeExtentButtonZoom); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './home-extent-button.component'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters