-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Marker): add pitch/rotation alignment options to the Marker comp…
…onent. (#226)
- Loading branch information
Showing
5 changed files
with
72 additions
and
3 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
5 changes: 5 additions & 0 deletions
5
projects/showcase/src/app/demo/examples/marker-alignment.component.css
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,5 @@ | ||
.arrow { | ||
width: 50px; | ||
height: 50px; | ||
transform: rotate(-97deg); | ||
} |
42 changes: 42 additions & 0 deletions
42
projects/showcase/src/app/demo/examples/marker-alignment.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,42 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'showcase-demo', | ||
template: ` | ||
<mgl-map | ||
[interactive]="false" | ||
movingMethod="jumpTo" | ||
[style]="'mapbox://styles/mapbox/streets-v9'" | ||
[pitch]="[pitch]" | ||
[bearing]="[bearing]" | ||
[zoom]="[17]" | ||
[center]="[4.577979, 51.038189]" | ||
> | ||
<mgl-marker [lngLat]="[4.577979, 51.03816]" rotationAlignment="map" pitchAlignment="map"> | ||
<div class="arrow"> | ||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 434 437"> | ||
<polygon points="37.5 437.18 218 350.75 217.49 -0.37 37.5 437.18" style="fill:#579120" /> | ||
<polygon points="397.55 437.13 218 350.75 217.49 -0.37 397.55 437.13" style="fill:#6fad2d" /> | ||
<polygon points="217.22 391.46 397.55 437.13 218 350.75 37.5 437.18 217.22 391.46" style="fill:#315112" /> | ||
</svg> | ||
</div> | ||
</mgl-marker> | ||
</mgl-map> | ||
`, | ||
styleUrls: ['./examples.css', './marker-alignment.component.css'] | ||
}) | ||
export class MarkerAlignmentComponent implements OnInit { | ||
pitch = 50; | ||
bearing = -97; | ||
ngOnInit(): void { | ||
let angle = 0; | ||
setInterval(() => { | ||
angle += 0.01; | ||
if (angle === 1) { | ||
angle = 0; | ||
} | ||
this.pitch = 45 + 15 * Math.cos(angle); | ||
this.bearing = -103 + 20 * Math.sin(angle); | ||
}, 20); | ||
} | ||
} |