Skip to content

Commit

Permalink
Changes for v10.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ahocevar committed Apr 5, 2023
1 parent e7f11f7 commit 7ed1fba
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 4 deletions.
41 changes: 41 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,47 @@

## Next version

## 10.4.0

### Changes that require attention

#### Font handling and loading

ol-mapbox-style no longer defaults to loading Google fonts when a required font is not available. Instead, it respects the new `metadata.ol:webfonts` field in the Mapbox Style document. Example:
```js
{
"version": 8,
"metadata": {
"ol:webfonts": "https://mytileservergl.com/fonts/{font-family}/{fontweight}{-fontstyle}.css"
}
// ...
}
```
The supported template placeholders are
* {font-family}: CSS font family converted to lowercase, blanks replaced with `-`, e.g. `noto-sans`
* {Font+Family}: CSS font family in original case, blanks replaced with `+`, e.g. `Noto+Sans`
* {fontweight}: CSS font weight (numeric), e.g. `400`, `700`
* {fontstyle}: CSS font style, e.g. `normal`, `italic`
* {-fontstyle}: CSS font style other than normal, e.g. `-italic` or empty string for normal

In addition to providing fonts along with the style, this can be used to retrieve fonts from a CDN (e.g. `@fontsource`) or Google fonts. If this metadata field is not set to the style, the following default template will be used:

https://cdn.jsdelivr.net/npm/@fontsource/{font-family}/{fontweight}{-fontstyle}.css

To retain the current behavior (i.e. use Google Fonts), the template URL will have to be

https://fonts.googleapis.com/css?family={Font+Family}:{fontweight}{fontstyle}

### Other changes

* Fix a potential tile cache issue
* Fix problem caused by `getUid` function missing in the full build
* Make `updateMapboxStyle()` work with objects that are not a reference to the original one
* Add support for the `tms` tile scheme for `raster` and `vector` layers
* Add support for the `terrarium` encoding for `raster-dem` sources
* Fix an issue where the `icon-offset` layout property modifies the underlying Mapbox Style object
* Set the correct input projection for `geojson` sources when the `projection` option is used

## 10.3.4

* Fix addMapboxLayer - updateMapboxLayer - removeMapboxLayer sequence
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -558,7 +558,7 @@ sure that sprite image loading works:
| `spriteImageUrl` | `string` | `undefined` | Sprite image url for the sprite specified in the Mapbox Style object's `sprite` property. Only required if a `sprite` property is specified in the Mapbox Style object. |
| `getFonts` | (`arg0`: `string`\[], `arg1`: `string`) => `string`\[] | `undefined` | Function that receives a font stack and the url template from the GL style's `metadata['ol:webfonts']` property (if set) as arguments, and returns a (modified) font stack that is available. Font names are the names used in the Mapbox Style object. If not provided, the font stack will be used as-is. This function can also be used for loading web fonts. |
| `getImage?` | (`arg0`: `VectorLayer`<`any`> \| `VectorTileLayer`, `arg1`: `string`) => `string` \| `HTMLCanvasElement` \| `HTMLImageElement` | `undefined` | Function that returns an image or a URL for an image name. If the result is an HTMLImageElement, it must already be loaded. The layer can be used to call layer.changed() when the loading and processing of the image has finished. This function can be used for icons not in the sprite or to override sprite icons. |
| `...args` | `any`\[] | `undefined` | - |
| `...args` | `any` | `undefined` | - |

##### Returns

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "ol-mapbox-style",
"version": "10.3.4",
"version": "10.4.0",
"description": "Create OpenLayers maps from Mapbox Style objects",
"type": "module",
"browser": "dist/index.js",
Expand Down

0 comments on commit 7ed1fba

Please sign in to comment.