Built with blockbuilder.org
Last active
February 6, 2018 21:13
-
-
Save mastersigat/61e32b4a17213a0cec47fe7fb8b2275b to your computer and use it in GitHub Desktop.
#MapboxGL / Catégorisation
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/ninanoun/ciytbjeef002u2sppd5xvl0q2', | |
center: [2.34, 48.9], // lat/long | |
zoom: 15, // zoom | |
pitch: 50, // Inclinaison | |
bearing: -10 // Rotation | |
}); | |
// Ajout de données OSM | |
map.on('load', function () { | |
map.addSource('Arrets', { | |
type: 'vector', | |
url: 'mapbox://ninanoun.6f7y97sy'}); | |
map.addLayer({ | |
'id': 'Arrets', | |
'type': 'circle', | |
'source': 'Arrets', | |
'source-layer': 'arbres-aqwrsg', | |
'layout': {'visibility': 'visible'}, | |
'paint': { | |
'circle-radius': { | |
'base': 1.15, | |
'stops': [[13, 1], [22, 18]]}, | |
'circle-color': [ | |
'match', | |
['get', 'domanialite'], | |
'Alignement', '#fbb03b', | |
'Jardin', '#223b53', | |
'CIMETIERE', '#e55e5e', | |
'DASCO', '#3bb2d0', | |
/* other */ '#ccc' | |
] | |
} | |
}); | |
// Cercle gradués | |
map.addSource('Centroides', { | |
'type': 'geojson', | |
'data': './communesBZH3.geojson' | |
}); | |
map.addLayer({ | |
id: 'propcircle', | |
type: 'circle', | |
source: 'Centroides', | |
'layout': { | |
'visibility': 'none' | |
}, | |
paint: { | |
'circle-color': '#D49A66', | |
// Add data-driven styles for circle radius | |
'circle-radius': { | |
property: 'Residences', | |
type: 'exponential', | |
stops: [ | |
[10, 2], | |
[2000, 20] | |
] | |
}, | |
'circle-opacity': 0.8 | |
} | |
}); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment