-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathgeojson-url.component.ts
42 lines (34 loc) · 1.15 KB
/
geojson-url.component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { Component, OnInit ,Inject } from '@angular/core';
import { RouterExtensions } from '@nativescript/angular';
import { MAPBOX_API_KEY } from '../common';
@Component({
selector: 'ns-geojson-url',
templateUrl: './geojson-url.component.html'
})
export class GeoJSONURLComponent implements OnInit {
constructor(@Inject(MAPBOX_API_KEY) public accessToken: string, private router: RouterExtensions) {}
ngOnInit(): void {}
goBack(): void {
this.router.back();
}
onMapReady(args): void {
console.log('map is ready');
const map = args.map;
map.addSource('earthquakes', {
type: 'geojson',
// Use a URL for the value for the `data` property.
data: 'https://docs.mapbox.com/mapbox-gl-js/assets/earthquakes.geojson'
});
map.addLayer({
'id': 'earthquakes-layer',
'type': 'circle',
'source': 'earthquakes',
'paint': {
'circle-radius': 8,
'circle-stroke-width': 2,
'circle-color': 'red',
'circle-stroke-color': 'white'
}
});
}
}