diff --git a/README.md b/README.md index 9650fc8..fbd3569 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,54 @@ const control = new LevelControl(indoorEqual); map.addControl(control); ``` +## Loading the default sprite + +The default style make uses of a sprite that has to be loaded manually and require an absolute path. The sprite is already builded and available in the `sprite` directory. + +To load the sprite, set the `spriteBaseUrl` property option on the constructor with the absolute path to the sprite and its name `/directory-to-change/indoorequal`. + +**Usage with [Parcel](https://parceljs.org/)** + +Install the +[parcel-plugin-static-files-copy](https://github.com/elwin013/parcel-plugin-static-files-copy) +package and add to your `package.json`: + + "staticFiles": { + "staticPath": "node_modules/openlayers-indoorequal/sprite" + }, + +Then load the sprite: + +```javascript +const indoorequal = new IndoorEqual(map, { apiKey: 'myKey', spriteBaseUrl: '/indoorequal' }); +``` + +**Usage with [webpack](https://webpack.js.org/)** + +Install the +[copy-webpack-plugin](https://github.com/webpack-contrib/copy-webpack-plugin) +package and add to your webpack config: + +```javascript +const CopyPlugin = require('copy-webpack-plugin'); + +module.exports = { + plugins: [ + new CopyPlugin({ + patterns: [ + { from: 'node_modules/openlayers-indoorequal/sprite' }, + ], + }), + ], +}; +``` + +Then load the sprite: + +```javascript +const indoorequal = new IndoorEqual(map, { apiKey: 'myKey', spriteBaseUrl: '/indoorequal' }); +``` + ## API