From 7faa2b266b324a24edfc270dd571f7a80a52d87b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20de=20Metz?= Date: Sat, 2 Oct 2021 17:40:53 +0200 Subject: [PATCH] Add doc on sprite. --- README.md | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) 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