Repository navigation
Expand file tree
/
Copy pathcode.js
More file actions
63 lines (58 loc) · 1.87 KB
/
Copy pathcode.js
File metadata and controls
63 lines (58 loc) · 1.87 KB
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
$(document).ready(function() {
var color = "#123456";
var toggle = "visible";
//I'm not sure if this is doing anything
csv2geojson.csv2geojson('https://raw.githubusercontent.com/cmtoomey/WorldWorld/master/Starbucks.csv', {
latfield: 'Latitude',
lonfield: 'Longitude',
delimiter: ','
}, function(err, data) {});
//END Do-Nothing Section
$("#globe").click(function() {
mapboxgl.accessToken = 'pk.eyJ1IjoiZGF2aWRvaDkxIiwiYSI6IjQxN2IyMzFkNzgwODEwZjdiZGEzNzEzMTE1MjQyMzc5In0.NJQwPueh-IOZ7V14d8NILA';
var map = new mapboxgl.Map({
container: 'map', // container id
style: 'mapbox://styles/mapbox/streets-v8', //stylesheet location
center: [-77.035346, 38.907757], // starting position
zoom: 12 // starting zoom
});
var url = 'http://api.tiles.mapbox.com/v3/examples.map-zr0njcqy/markers.geojson';
var source = new mapboxgl.GeoJSONSource({
data: url
});
map.on('style.load', function() {
map.addSource('drone', source);
map.addLayer({
"id": "drone",
"interactive": "true",
"type": "symbol",
"source": "drone",
"type": "circle",
// "layout": {
// "icon-image": "marker-15",
// },
"paint": {
"circle-color": color,
"circle-radius": "25",
}
});
});
map.on('click', function(e) {
map.featuresAt(e.point, {
layer: 'drone',
radius: 10,
includeGeometry: true
}, function(err, features) {
if (err) throw err;
if (features.length) {
map.flyTo({
center: features[0].geometry.coordinates
});
var tooltip = new mapboxgl.Popup()
.setHTML('<h1>' + features[0].properties.title + '</h1>' + '\n' + '<h2>' + features[0].properties.description + '</h2>')
.addTo(map);
}
});
});
});
})