-
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.
+ add hover-styles example
- Loading branch information
Wykks
committed
Oct 30, 2017
1 parent
aaecc35
commit 45f99ff
Showing
5 changed files
with
87 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
template: ` | ||
<mgl-map | ||
style="mapbox://styles/mapbox/streets-v9" | ||
[zoom]="2" | ||
[center]="[-100.486052, 37.830348]" | ||
> | ||
<mgl-geojson-source | ||
id="states" | ||
data="https://d2ad6b4ur7yvpq.cloudfront.net/naturalearth-3.3.0/ne_110m_admin_1_states_provinces.geojson" | ||
> | ||
</mgl-geojson-source> | ||
<mgl-layer | ||
id="state-fills" | ||
type="fill" | ||
source="states" | ||
[paint]="{ | ||
'fill-color': '#627BC1', | ||
'fill-opacity': 0.5 | ||
}" | ||
(mouseMove)="activateHoverOn($event)" | ||
(mouseLeave)="disableHover()" | ||
> | ||
</mgl-layer> | ||
<mgl-layer | ||
id="state-borders" | ||
type="line" | ||
source="states" | ||
[paint]="{ | ||
'line-color': '#627BC1', | ||
'line-width': 2 | ||
}" | ||
> | ||
</mgl-layer> | ||
<mgl-layer | ||
id="state-fills-hover" | ||
type="fill" | ||
source="states" | ||
[paint]="{ | ||
'fill-color': '#627BC1', | ||
'fill-opacity': 1 | ||
}" | ||
[filter]="hoverFilter" | ||
> | ||
</mgl-layer> | ||
</mgl-map> | ||
`, | ||
styleUrls: ['./examples.css'] | ||
}) | ||
export class HoverStylesComponent { | ||
hoverFilter = ['==', 'name', '']; | ||
|
||
activateHoverOn(evt: any) { | ||
this.hoverFilter = ['==', 'name', evt.features[0].properties.name]; | ||
} | ||
|
||
disableHover() { | ||
this.hoverFilter = ['==', 'name', '']; | ||
} | ||
} |
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