Skip to content

Commit

Permalink
Merge pull request #95 from conveyal/mapbox-update
Browse files Browse the repository at this point in the history
Upgrade Mapbox to use v4 URL path and tokens
  • Loading branch information
landonreed authored Jul 17, 2019
2 parents 4a04b8e + d05ba5a commit bbb8c09
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
25 changes: 18 additions & 7 deletions client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,29 @@ $(document).ready(function () {
map.attributionControl.setPrefix('')

// create OpenStreetMap tile layers for streets and aerial imagery
var osmLayer = L.tileLayer('//{s}.tiles.mapbox.com/v3/' + window.OTP_config
.osmMapKey + '/{z}/{x}/{y}{scale}.png', {
subdomains: ['a', 'b', 'c', 'd'],
var osmLayer = L.tileLayer('https://api.tiles.mapbox.com/v4/' +
window.OTP_config.osmMapKey +
'/{z}/{x}/{y}{scale}.png?access_token=' +
window.OTP_config.mapToken,
{
attribution: 'Street Map <a href="//mapbox.com/about/maps">Terms & Feedback</a>',
scale: L.Browser.retina ? '@2x' : '',
// Zoom offset and tile size adjust for retina-sized tiles.
zoomOffset: -1,
tileSize: L.Browser.retina ? 512 : 256,
detectRetina: true
})
var aerialLayer = L.tileLayer('//{s}.tiles.mapbox.com/v3/' + window.OTP_config
.aerialMapKey + '/{z}/{x}/{y}{scale}.png', {
subdomains: ['a', 'b', 'c', 'd'],
}
)
var aerialLayer = L.tileLayer('https://api.tiles.mapbox.com/v4/' +
window.OTP_config.aerialMapKey +
'/{z}/{x}/{y}{scale}.png?access_token=' +
window.OTP_config.mapToken,
{
attribution: 'Satellite Map <a href="//mapbox.com/about/maps">Terms & Feedback</a>',
scale: L.Browser.retina ? '@2x' : '',
// Zoom offset and tile size adjust for retina-sized tiles.
zoomOffset: -1,
tileSize: L.Browser.retina ? 512 : 256,
detectRetina: true
})

Expand Down
3 changes: 2 additions & 1 deletion client/config.js.template
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ window.OTP_config = {
initLatLng: [45.52, -122.681944],

osmMapKey: 'your-mapbox-osm-key',
aerialMapKey: 'your-mapbox-aerial-key'
aerialMapKey: 'your-mapbox-aerial-key',
mapToken: 'your-mapbox-access-token',

// mapzenApiKey: "your-key", // your Mapzen Search API key
// geocoderSearchRadius : 25, // search radius in km for mapzen geocoder from initLatLng (defaults to 50 if not specified)
Expand Down

0 comments on commit bbb8c09

Please sign in to comment.