-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(layer): add click/mouseEnter/mouseLeave Output
add language switch example add center on symbol example
- Loading branch information
Wykks
committed
Oct 18, 2017
1 parent
9cc9abf
commit 2dbabf4
Showing
10 changed files
with
241 additions
and
31 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,5 +6,6 @@ | |
"**/CVS": true, | ||
"**/.DS_Store": true, | ||
".ng_build": true | ||
} | ||
}, | ||
"typescript.tsdk": "node_modules/typescript/lib" | ||
} |
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 { browser, element, by, ExpectedConditions as EC } from 'protractor'; | ||
const PixelDiff = require('pixel-diff'); | ||
const browserLogs = require('protractor-browser-logs'); | ||
|
||
describe('Language switch', () => { | ||
let logs: any; | ||
|
||
beforeEach(() => { | ||
logs = browserLogs(browser); | ||
}); | ||
|
||
afterEach(() => { | ||
return logs.verify(); | ||
}); | ||
|
||
it('should change language', async () => { | ||
await browser.get('/language-switch'); | ||
const elm = element(by.tagName('canvas')); | ||
await browser.wait(EC.presenceOf(elm), 2000); | ||
const buttons = await browser.findElements(by.tagName('button')); | ||
await browser.sleep(4000); | ||
await buttons[0].click(); | ||
await browser.sleep(2000); | ||
const screen1 = await browser.takeScreenshot(); | ||
await buttons[1].click(); | ||
await browser.sleep(2000); | ||
const screen2 = await browser.takeScreenshot(); | ||
const result = new PixelDiff({ | ||
imageA: new Buffer(screen1, 'base64'), | ||
imageB: new Buffer(screen2, 'base64') | ||
}).runSync(); | ||
expect(result.differences).toBeGreaterThan(0); | ||
await buttons[0].click(); | ||
await browser.sleep(2000); | ||
const screen1bis = await browser.takeScreenshot(); | ||
const result2 = new PixelDiff({ | ||
imageA: new Buffer(screen1, 'base64'), | ||
imageB: new Buffer(screen1bis, 'base64') | ||
}).runSync(); | ||
expect(result2.differences).toBe(0); | ||
}); | ||
}); |
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,78 @@ | ||
import { MapComponent } from '../../lib'; | ||
import { Component, ViewChild } from '@angular/core'; | ||
import { MapMouseEvent } from 'mapbox-gl'; | ||
|
||
@Component({ | ||
template: ` | ||
<mgl-map | ||
[style]="'mapbox://styles/mapbox/light-v9'" | ||
[zoom]="8" | ||
[center]="center" | ||
#map | ||
> | ||
<mgl-geojson-source | ||
id="symbols-source" | ||
> | ||
<mgl-feature | ||
*ngFor="let geometry of geometries" | ||
[geometry]="geometry" | ||
></mgl-feature> | ||
</mgl-geojson-source> | ||
<mgl-layer | ||
id="symbols" | ||
type="symbol" | ||
source="symbols-source" | ||
[layout]="{ | ||
'icon-image': 'rocket-15' | ||
}" | ||
(click)="centerMapTo($event)" | ||
(mouseEnter)="changeCursorToPointer()" | ||
(mouseLeave)="changeCursorToDefault()" | ||
> | ||
</mgl-layer> | ||
</mgl-map> | ||
`, | ||
styleUrls: ['./examples.css'] | ||
}) | ||
export class CenterOnSymbolComponent { | ||
@ViewChild('map') map: MapComponent; | ||
|
||
center = [-90.96, -0.47]; | ||
|
||
geometries = [ | ||
{ | ||
'type': 'Point', | ||
'coordinates': [ | ||
-91.395263671875, | ||
-0.9145729757782163 | ||
|
||
] | ||
}, | ||
{ | ||
'type': 'Point', | ||
'coordinates': [ | ||
-90.32958984375, | ||
-0.6344474832838974 | ||
] | ||
}, | ||
{ | ||
'type': 'Point', | ||
'coordinates': [ | ||
-91.34033203125, | ||
0.01647949196029245 | ||
] | ||
} | ||
]; | ||
|
||
centerMapTo(evt: MapMouseEvent) { | ||
this.center = (<any>evt).features[0].geometry.coordinates; | ||
} | ||
|
||
changeCursorToPointer() { | ||
this.map.mapInstance.getCanvas().style.cursor = 'pointer'; | ||
} | ||
|
||
changeCursorToDefault() { | ||
this.map.mapInstance.getCanvas().style.cursor = ''; | ||
} | ||
} |
File renamed without changes.
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,40 @@ | ||
import { Component, ViewChild } from '@angular/core'; | ||
import { MapComponent } from '../../lib'; | ||
|
||
@Component({ | ||
template: ` | ||
<mgl-map | ||
style="mapbox://styles/mapbox/light-v9" | ||
[zoom]="2.9" | ||
[center]="[16.05, 48]" | ||
#map | ||
> | ||
<mgl-control> | ||
<button | ||
mat-raised-button | ||
(click)="changeLangTo('fr')" | ||
>French</button> | ||
<button | ||
mat-raised-button | ||
(click)="changeLangTo('ru')" | ||
>Russian</button> | ||
<button | ||
mat-raised-button | ||
(click)="changeLangTo('de')" | ||
>German</button> | ||
<button | ||
mat-raised-button | ||
(click)="changeLangTo('es')" | ||
>Spanish</button> | ||
</mgl-control> | ||
</mgl-map> | ||
`, | ||
styleUrls: ['./examples.css', './toggle-layers.component.css'] | ||
}) | ||
export class LanguageSwitchComponent { | ||
@ViewChild('map') map: MapComponent; | ||
|
||
changeLangTo(language: string) { | ||
this.map.mapInstance.setLayoutProperty('country-label-lg', 'text-field', '{name_' + language + '}'); | ||
} | ||
} |
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
Oops, something went wrong.