Japan train lines Mapbox+Leaflet
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
const map = ...; | |
const accessToken = "..."; | |
// Add train lines (Shinkansen, metro, JR, etc) to Mapbox using LeafLet for a more | |
// accurate representation of Japan and Tokyo | |
// Using the layer mapbox.transit-v2 for trains and some custom styles | |
const trains = | |
"https://api.mapbox.com/v4/mapbox.transit-v2/{z}/{x}/{y}.vector.pbf?access_token={accessToken}"; | |
const transit_line = (properties, zoom) => { | |
const isShinkansen = properties.mode === "high_speed_rail"; | |
const isYamanote = properties.name === "山手線"; | |
return { | |
color: (isYamanote ? "#00cc00" : properties.line_color) || "#666", | |
opacity: isShinkansen ? 0.75 : 0.5, | |
weight: isShinkansen || isYamanote ? 2 : 1.5 | |
}; | |
}; | |
var mapillaryLayer = L.vectorGrid | |
.protobuf(trains, { accessToken, vectorTileLayerStyles: { transit_line } }) | |
.addTo(map); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment