Built with blockbuilder.org
Created
February 1, 2021 20:06
-
-
Save mastersigat/51b0b5d0ce4235103d4890ef6816d1a4 to your computer and use it in GitHub Desktop.
#MapboxGL / Ajouter des Geojson - hébergés sur Github
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>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/v1.1.0/mapbox-gl.js'></script> | |
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v1.1.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/mapbox/dark-v10', // fond de carte | |
zoom: 12.2, | |
center: [-1.67, 48.11], | |
pitch: 50, // Inclinaison | |
bearing: 0 // Rotation | |
}); | |
map.on('load', function () { | |
// Ajout lignes de metros | |
map.addSource('lignes', { | |
type: 'geojson', | |
data: 'https://raw.githubusercontent.com/mastersigat/data/main/metro-du-reseau-star-traces-de-laxe-des-lignes.geojson' | |
}); | |
map.addLayer({ | |
'id': 'region', | |
'type': 'line', | |
'source': 'lignes', | |
'paint': {'line-opacity': 0.7, 'line-width': 3.5, | |
'line-color': 'red'} | |
}); | |
// Ajout stations de metros | |
map.addSource('Stations', { | |
type: 'geojson', | |
data: 'https://raw.githubusercontent.com/mastersigat/data/main/metro-du-reseau-star-localisation-des-stations.geojson' | |
}); | |
map.addLayer({ | |
'id': 'Stations', | |
'type': 'circle', | |
'source': 'Stations', | |
'paint': { | |
'circle-color': 'blue' , 'circle-stroke-color': 'white' , 'circle-stroke-width': 2 , 'circle-radius' : 4}} | |
); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment