Created
November 2, 2018 21:53
-
-
Save samgehret/d67a4b82c9fcbc94c0bdfa5ac0c12111 to your computer and use it in GitHub Desktop.
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset='utf-8' /> | |
<title>Add a geocoder</title> | |
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' /> | |
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.50.0/mapbox-gl.js'></script> | |
<script src="https://unpkg.com/axios/dist/axios.min.js"></script> | |
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.50.0/mapbox-gl.css' rel='stylesheet' /> | |
<style> | |
body { | |
margin: 0; | |
padding: 0; | |
} | |
#map { | |
position: absolute; | |
top: 0; | |
bottom: 0; | |
width: 100%; | |
} | |
</style> | |
</head> | |
<body> | |
<script src='https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-geocoder/v2.3.0/mapbox-gl-geocoder.min.js'></script> | |
<link rel='stylesheet' href='https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-geocoder/v2.3.0/mapbox-gl-geocoder.css' | |
type='text/css' /> | |
<div id='map'></div> | |
<script> | |
mapboxgl.accessToken = | |
'pk.eyJ1Ijoic2FtZ2VocmV0IiwiYSI6ImNqZWExcDdwNTAxYnEyeG1tZnQ4MTNsODkifQ.68r_UjBeRkubf5eUs4uw-g'; | |
var map = new mapboxgl.Map({ | |
container: 'map', | |
style: 'mapbox://styles/mapbox/streets-v9', | |
center: [-74.0060, 40.7128], | |
pitch: 40, | |
zoom: 16 | |
}); | |
map.on('load', function () { | |
map.addSource("blockgroups", { | |
type: "vector", | |
url: "mapbox://mapbox.3d-buildings" | |
}); | |
map.addLayer({ | |
"id": "3d-buildings", | |
"type": "fill-extrusion", | |
"source": "blockgroups", | |
"source-layer": "building", | |
'minzoom': 15, | |
"paint": { | |
'fill-extrusion-height': [ | |
"interpolate", ["linear"], | |
["zoom"], | |
15, 0, | |
15.05, ["get", "height"] | |
], | |
'fill-extrusion-color': '#aaa', | |
} | |
}, 'waterway-label'); | |
map.on('click', function (e) { | |
// console.log('hello world') | |
var features = map.queryRenderedFeatures(e.point, { layers: ['3d-buildings'] }); | |
console.log(features) | |
}); | |
}) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment