Built with blockbuilder.org
Created
February 11, 2018 11:41
-
-
Save anonymous/f2c04bc06e759c2da1c3c9767fe572fa to your computer and use it in GitHub Desktop.
#MapboxGL / Ajout de données personelles
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
license: mit |
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>MapboxGL</title> | |
<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> | |
#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/mapbox/dark-v9', | |
center: [-1.68, 48.12], // lat/long | |
zoom: 17, // zoom | |
pitch: 50, // Inclinaison | |
bearing: -10 // Rotation | |
}); | |
map.on('load', function () { | |
// Ajout routes OSM | |
map.addSource('mapbox-streets-v7', { | |
type: 'vector', | |
url: 'mapbox://mapbox.mapbox-streets-v7'}); | |
map.addLayer({ | |
"id": "routes", | |
"type": "line", | |
"source": "mapbox-streets-v7", | |
"layout": {'visibility': 'visible'}, | |
"source-layer": "road", | |
"paint": {"line-color": "#FF7F50", "line-width": 1} | |
}); | |
// Ajout arrets de bus | |
map.addSource('Arrets', { | |
type: 'vector', | |
url: 'mapbox://ninanoun.58widelk'}); | |
map.addLayer({ | |
'id': 'Arrets', | |
'type': 'circle', | |
'source': 'Arrets', | |
'source-layer': 'Bus-5ypx1k', | |
'layout': {'visibility': 'visible'}, | |
'paint': {'circle-radius': 7, 'circle-color': '#f5f60d'} | |
}); | |
// Ajout couche équipements | |
map.addSource('Equipements', { | |
type: 'vector', | |
url: 'mapbox://ninanoun.4xcn5ude'}); | |
map.addLayer({ | |
'id': 'Equipements', | |
'type': 'circle', | |
'source': 'Equipements', | |
'source-layer': 'base-orga-var-6k0zky', | |
'layout': {'visibility': 'visible'}, | |
'paint': {'circle-radius': 6, 'circle-color': '#3399ff'} | |
}); | |
//Limites de proprietes | |
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} | |
}); | |
// Ajout batiments 3D | |
map.addLayer({ | |
'id': 'Batimenst_3D', | |
'source': 'composite', | |
'source-layer': 'building', | |
'filter': ['==', 'extrude', 'true'], | |
'type': 'fill-extrusion', | |
'minzoom': 15, | |
'paint': {'fill-extrusion-color': '#FFFFFF', 'fill-extrusion-height': | |
{'type': 'identity','property': 'height'}, | |
'fill-extrusion-base': {'type': 'identity','property': 'min_height'}, | |
'fill-extrusion-opacity': 0.9 | |
} | |
}); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment