Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rotation button 1.0.0-alpha.1 #312

Merged
merged 10 commits into from
Jul 24, 2019
2 changes: 1 addition & 1 deletion demo/src/app/context/context/context.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
[map]="map">
<igo-zoom-button [map]="map" color="primary"></igo-zoom-button>
<igo-geolocate-button [map]="map" color="primary"></igo-geolocate-button>
<igo-rotation-button [map]="map" color="primary"></igo-rotation-button>
<igo-rotation-button [map]="map" [showIfNoRotation]="true" color="primary"></igo-rotation-button>
</igo-map-browser>

<igo-panel title="Contexts list">
Expand Down
2 changes: 1 addition & 1 deletion demo/src/app/geo/directions/directions.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<igo-map-browser [map]="map" [view]="view">
<igo-zoom-button [map]="map" color="primary"></igo-zoom-button>
<igo-geolocate-button [map]="map" color="primary"></igo-geolocate-button>
<igo-rotation-button [map]="map" color="primary"></igo-rotation-button>
<igo-rotation-button [map]="map" [showIfNoRotation]="false" color="primary"></igo-rotation-button>
</igo-map-browser>

<igo-routing-form [map]="map"></igo-routing-form>
Expand Down
2 changes: 1 addition & 1 deletion demo/src/app/geo/print/print.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<igo-map-browser [map]="map" [view]="view">
<igo-zoom-button [map]="map" color="primary"></igo-zoom-button>
<igo-geolocate-button [map]="map" color="primary"></igo-geolocate-button>
<igo-rotation-button [map]="map" color="primary"></igo-rotation-button>
<igo-rotation-button [map]="map" [showIfNoRotation]="false" color="primary"></igo-rotation-button>
</igo-map-browser>

<igo-print [map]="map"></igo-print>
Expand Down
2 changes: 1 addition & 1 deletion demo/src/app/geo/simple-map/simple-map.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<igo-map-browser [map]="map" [view]="view">
<igo-zoom-button [map]="map" color="primary"></igo-zoom-button>
<igo-geolocate-button [map]="map" color="primary"></igo-geolocate-button>
<igo-rotation-button [map]="map" color="primary"></igo-rotation-button>
<igo-rotation-button [map]="map" [showIfNoRotation]="true" color="primary"></igo-rotation-button>
</igo-map-browser>

</mat-card>
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
<div class="igo-rotation-button-container">
<button
*ngIf="map.viewController.getRotation() !== 0"
mat-icon-button
[matTooltip]="'igo.geo.mapButtons.resetRotation' | translate"
matTooltipPosition="left"
[color]="color"
<div *ngIf="rotated && !showIfNoRotation" class="igo-rotation-button-container"
[matTooltip]="rotated ? ('igo.geo.mapButtons.resetRotation' | translate): ('igo.geo.mapButtons.tipRotation' | translate)"
matTooltipPosition="left">
<button mat-icon-button matTooltipPosition="left" [color]="color" [disabled]="!rotated"
(click)="map.viewController.resetRotation()">
<mat-icon [ngStyle]="rotationStyle(map.viewController.getRotation())" svgIcon="navigation">
</mat-icon>
</button>
</div>

<div *ngIf="showIfNoRotation" class="igo-rotation-button-container"
[matTooltip]="rotated ? ('igo.geo.mapButtons.resetRotation' | translate): ('igo.geo.mapButtons.tipRotation' | translate)"
matTooltipPosition="left">
<button mat-icon-button matTooltipPosition="left" [color]="color" [disabled]="!rotated"
(click)="map.viewController.resetRotation()">
<mat-icon [ngStyle]="rotationStyle(map.viewController.getRotation())" svgIcon="navigation">
</mat-icon>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@import '../../../../../core/src/style/partial/media';
@import '../../../../../core/src/style/partial/core.variables';

.igo-rotation-button-container {
Expand All @@ -11,4 +12,9 @@
button,
:host >>> button .mat-button-ripple-round {
border-radius: 0;
&:disabled {
@include mobile {
display: none;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ export class RotationButtonComponent {
}
private _map: IgoMap;

@Input()
get showIfNoRotation(): boolean {
return this._showIfNoRotation;
}
set showIfNoRotation(value: boolean) {
this._showIfNoRotation = value;
}
private _showIfNoRotation: boolean;

@Input()
get color(): string {
return this._color;
Expand All @@ -26,6 +35,10 @@ export class RotationButtonComponent {
}
private _color: string;

get rotated(): boolean {
return this.map.viewController.getRotation() !== 0;
}

constructor() {}

rotationStyle(radians): {} {
Expand Down
2 changes: 1 addition & 1 deletion packages/geo/src/lib/map/shared/controllers/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ export class MapViewController extends MapController {
* Reset the view rotation to 0
*/
resetRotation() {
this.olView.setRotation(0);
this.olView.animate({rotation: 0});
}

/**
Expand Down
3 changes: 2 additions & 1 deletion packages/geo/src/locale/en.geo.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@
"geolocate": "Geolocate",
"zoomIn": "Zoom in ({{zoom}})",
"zoomOut": "Zoom out ({{zoom}})",
"resetRotation": "Set map to north"
"resetRotation": "Set map to north",
"tipRotation": "Hold Alt and SHIFT while dragging on map to rotate the map."
},
"metadata": {
"show": "Show metadata"
Expand Down
3 changes: 2 additions & 1 deletion packages/geo/src/locale/fr.geo.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@
"geolocate": "Positionnement GPS",
"zoomIn": "Zoomer ({{zoom}})",
"zoomOut": "Dézoomer ({{zoom}})",
"resetRotation": "Réinitialiser la carte vers le nord"
"resetRotation": "Réinitialiser la carte vers le nord",
"tipRotation": "Maintenez les touches Alt et Majuscule (shift) tout en cliquant sur la carte pour faire pivoter la carte"
},
"metadata": {
"show": "Montrer les métadonnées"
Expand Down