Skip to content

Commit

Permalink
Upgraded Mapbox to use new Static Tiles API
Browse files Browse the repository at this point in the history
  • Loading branch information
Tam committed Jun 12, 2020
1 parent de32f22 commit 9ea2f6a
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 9 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
## [Unreleased] 3.8.4
## 3.8.4 - 2020-06-12
### Changed
- Allow zoom override on Google/Mapbox embeds
- Allow style override on Mapbox embeds (Fixes #256)

### Fixed
- Cast embed center coordinates to floats
- Upgraded Mapbox to use new Static Tiles API

## 3.8.3 - 2020-04-09
### Added
Expand Down
23 changes: 20 additions & 3 deletions resources/src/components/Map.vue
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,10 @@
} else if (this.tiles.indexOf('mapkit') > -1) {
this._mapKitMutant();
} else {
const opts = { attribution: this.tileLayer.attr };
const opts = {
attribution: this.tileLayer.attr,
...(this.tileLayer.opts || {}),
};
if (this.tileLayer.subdomains)
opts.subdomains = this.tileLayer.subdomains;
Expand Down Expand Up @@ -179,6 +182,7 @@
tileLayer () {
const scale = L.Browser.retina ? '@2x.png' : '.png'
, hereScale = L.Browser.retina ? '512' : '256'
, mbScale = L.Browser.retina ? '@2x' : ''
, style = this.tiles.split(/\.(.+)/)[1];
switch (this.tiles) {
Expand All @@ -202,11 +206,24 @@
case MapTiles.MapboxOutdoors:
case MapTiles.MapboxStreets:
case MapTiles.MapboxLight:
case MapTiles.MapboxDark:
case MapTiles.MapboxDark: {
let v = '-v11';
if (this.tiles === MapTiles.MapboxLight || this.tiles === MapTiles.MapboxDark)
v = '-v10';
return {
url: `https://api.tiles.mapbox.com/v4/mapbox.${style}/{z}/{x}/{y}${scale}?access_token=${this.token}`,
url: 'https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}{scale}?access_token={accessToken}',
attr: '&copy; <a href="http://www.openstreetmap.org/copyright" target="_blank" rel="noreferrer">OpenStreetMap</a>, &copy; <a href="https://www.mapbox.com/" target="_blank" rel="noreferrer">Mapbox</a>',
opts: {
accessToken: this.token,
id: `mapbox/${style}${v}`,
tileSize: 512,
zoomOffset: -1,
scale: mbScale,
},
};
}
case MapTiles.HereNormalDay:
case MapTiles.HereNormalDayGrey:
case MapTiles.HereNormalDayTransit:
Expand Down
2 changes: 1 addition & 1 deletion src/services/EmbedService.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ private function _embedMapbox (EmbedOptions $options, Settings $settings)
$type = 'outdoors-v11';
break;
case MapTiles::MapboxLight:
$type = 'light-v9';
$type = 'light-v10';
break;
case MapTiles::MapboxDark:
$type = 'dark-v10';
Expand Down
2 changes: 1 addition & 1 deletion src/services/StaticService.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ private function _generateMapbox ($options, $settings)
$url .= 'outdoors-v11';
break;
case MapTiles::MapboxLight:
$url .= 'light-v9';
$url .= 'light-v10';
break;
case MapTiles::MapboxDark:
$url .= 'dark-v10';
Expand Down
2 changes: 1 addition & 1 deletion src/web/assets/map/js/app.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/web/assets/map/js/app.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/web/assets/map/js/chunk-vendors.js.map

Large diffs are not rendered by default.

0 comments on commit 9ea2f6a

Please sign in to comment.