Skip to content

Instantly share code, notes, and snippets.

@mastersigat
Last active February 4, 2018 21:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mastersigat/c230a89f909b1b17f5881520e7b5590f to your computer and use it in GitHub Desktop.
Save mastersigat/c230a89f909b1b17f5881520e7b5590f to your computer and use it in GitHub Desktop.
#MapboxGL / Ajouter des données personnelles
license: mit
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title>Display a map</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.44.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.44.0/mapbox-gl.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
</style>
</head>
<body>
<div id='map'></div>
<script>
// AccesToken
mapboxgl.accessToken = 'pk.eyJ1IjoibmluYW5vdW4iLCJhIjoiY2pjdHBoZGlzMnV4dDJxcGc5azJkbWRiYSJ9.o4dZRrdHcgVEKCveOXG1YQ';
// Configuration de la carte
var map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/ninanoun/ciyo7h3mc001q2rpngdsa9zwh', // fond de carte
center: [-1.67, 48.13], // lat/long
zoom: 15, // zoom
pitch: 50, // Inclinaison
bearing: -10 // Rotation
});
// Ajout de données personelles
map.on('load', function () {
// Ajout des arbres
map.addSource('Arbres', {
type: 'vector',
url: 'mapbox://ninanoun.dx1cg9bg'});
map.addLayer({
'id': 'Arbres',
'type': 'circle',
'source': 'Arbres',
'source-layer': 'arbres-d-alignement-rennes-a5jtaq',
'layout': {'visibility': 'visible'},
'paint': {'circle-radius': 3, 'circle-color': '#0df634',}
});
// Ajout des limites de prorpiétés
map.addSource('Proprietes', {
type: 'vector',
url: 'mapbox://ninanoun.a4kdgiot'
});
map.addLayer({
'id': 'Proprietes',
'type': 'line',
'source': 'Proprietes',
'source-layer': 'limites_proprietes',
'layout': {'visibility': 'visible',
'line-join': 'round','line-cap': 'round'},
'paint': {'line-color': '#FFFFFF', 'line-width': 1.5}
});
map.addLayer({
'id': '3d-buildings',
'source': 'composite',
'source-layer': 'building',
'filter': ['==', 'extrude', 'true'],
'type': 'fill-extrusion',
'minzoom': 15,
'paint': {
'fill-extrusion-color': '#aaa',
// use an 'interpolate' expression to add a smooth transition effect to the
// buildings as the user zooms in
'fill-extrusion-height': [
"interpolate", ["linear"], ["zoom"],
15, 0,
15.05, ["get", "height"]
],
'fill-extrusion-base': [
"interpolate", ["linear"], ["zoom"],
15, 0,
15.05, ["get", "min_height"]
],
'fill-extrusion-opacity': .6
}
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment