Switch to the ol package
With version 2.x, ol-mapbox-style switched to the ol
npm package for the OpenLayers dependency. Users of dist/olms.js
will not notice this change. Applications that have been using the openlayers
npm package should be migrated to the ol
package too.
If switching to ol
is not yet desired, it is still possible to use ol-mapbox-style with the openlayers
package, with the help of standalonify
. You have to require OpenLayers as global.ol = require('openlayers');
. To build the bundle, use a command like the following:
$ node_modules/.bin/browserify -g [ babelify --plugins [ transform-es2015-modules-commonjs ] ] -p [ standalonify --name null --deps [ null --ol/style/style ol.style.Style --ol/style/fill ol.style.Fill --ol/style/stroke ol.style.Stroke --ol/style/circle ol.style.Circle --ol/style/icon ol.style.Icon --ol/style/text ol.style.Text ] ] example/index.js > example/bundle.js
getStyleFunction
moved to separate mapbox-to-ol-style package
For applications that do not need sprites and web fonts for their styles, a separate mapbox-to-ol-style
package with focus on small build size and minimal dependencies has been created. ol-mapbox-style depends on that package.
If you have previously been using the getStyleFunction
function, you now have to import it from mapbox-to-ol-style
. If you have not used anything else from ol-mapbox-style, you can uninstall it.
Google fonts no longer need to be included in the html
ol-mapbox-style now automatically loads web fonts from Google. So in most cases, it is no longer necessary to scan the Mapbox Style for fonts and include them manually in the html of the application.