-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.js
72 lines (59 loc) · 1.67 KB
/
main.js
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*global mapboxgl*/
mapboxgl.accessToken =
'pk.eyJ1IjoiYm5qbW5zYmwiLCJhIjoiY2luc3Qxajk4MDBsY3Zza2x1MWg1b2xzeCJ9.BK1MmHruCVZvMFnL_uTC1w';
var map = new mapboxgl.Map({
container: 'map', // container id
style: 'mapbox://styles/mapbox/light-v9', // stylesheet location
center: [13.404954, 52.520008], // starting position [lng, lat]
zoom: 12, // starting zoom
minZoom: 9,
maxZoom: 18,
pitch: 45, //angle from plane view
trackResize: true,
});
map.on('load', function() {
var url = '/data/result.geojson';
map.addLayer({
id: 'datapoints',
source: {
type: 'geojson',
data: url
},
type: 'circle',
paint: {
'circle-color': '#253276'
},
'circle-radius': {
property: 'size',
'base': 1.7,
stops: [[8, 1], [11, 6], [16, 40]]
},
'circle-color': {
property: 'color',
type: 'categorical',
stops: [
['normal', 'transparent'],
['focussed', '#E60433'],
['inactive', 'transparent']]
}
});
});
map.on('mouseenter', 'datapoints', function () {
map.getCanvas().style.cursor = 'pointer';
});
map.on('mouseleave', 'datapoints', function () {
map.getCanvas().style.cursor = '';
});
map.on('click', function(e) {
var features = map.queryRenderedFeatures(e.point, {
layers: ['datapoints'] // replace this with the name of the layer
});
if (!features.length) {
return;
}
var feature = features[0];
var popup = new mapboxgl.Popup({ offset: [0, -15] })
.setLngLat(feature.geometry.coordinates)
.setHTML('<h3>' + feature.properties['Einrichtung Name'] + '</h3><p>Plätze: ' + feature.properties['Einrichtung Platzzahl'] + '</p>')
.addTo(map);
});