|
1 |
| -# vue2-leaflet-heightgraph |
2 |
| -Leaflet.Heightgraph plugin extension for vue2-leaflet package |
| 1 | +# vue2-leaflet-height-graph |
| 2 | + |
| 3 | +This is a [Vue2Leaflet](https://github.com/KoRiGaN/Vue2Leaflet) plugin to provide the |
| 4 | +[Leaflet.Heightgraph](https://github.com/GIScience/Leaflet.Heightgraph) control |
| 5 | +on [Leaflet](https://leafletjs.com/) maps in [Vue](https://vuejs.org/) applications. |
| 6 | + |
| 7 | + |
| 8 | +## Installation |
| 9 | +```bash |
| 10 | +npm install --save vue2-leaflet-height-graph |
| 11 | +``` |
| 12 | + |
| 13 | +## Import |
| 14 | +You could either import the component locally where you need it or register it globally. |
| 15 | + |
| 16 | +### Local |
| 17 | +In a `.vue` file: |
| 18 | +```vue |
| 19 | +<script> |
| 20 | + import LControlHeightGraph from 'vue2-leaflet-height-graph' |
| 21 | + // ... |
| 22 | + export default { |
| 23 | + // ... |
| 24 | + components: { 'l-height-graph': LControlHeightGraph } |
| 25 | + // ... |
| 26 | + } |
| 27 | +</script> |
| 28 | +<style> |
| 29 | +@import "~vue2-leaflet-height-graph/dist/Vue2LeafletHeightGraph.css"; |
| 30 | +</style> |
| 31 | +// ... |
| 32 | +``` |
| 33 | + |
| 34 | +### Global |
| 35 | +In your `main.js`: |
| 36 | +```js |
| 37 | +import Vue from 'vue'; |
| 38 | +import Vue2LeafletHeightGraph from 'vue2-leaflet-height-graph'; |
| 39 | +import 'vue2-leaflet-heightgraph/dist/Vue2LeafletHeightGraph.css' |
| 40 | +// ... |
| 41 | +Vue.component('l-height-graph', Vue2LeafletHeightGraph); |
| 42 | +// ... |
| 43 | +``` |
| 44 | + |
| 45 | +## Usage |
| 46 | + |
| 47 | +With the `LControlHeightGraph` component loaded into Vue, add the |
| 48 | +`l-height-graph` element inside an `l-map`. |
| 49 | + |
| 50 | +```html |
| 51 | +<l-map> |
| 52 | + <l-height-graph |
| 53 | + :data="heightGraphData" |
| 54 | + :options="{ width: 1000, position: 'bottomleft'}"/> |
| 55 | + <!-- other map components --> |
| 56 | +</l-map> |
| 57 | +``` |
| 58 | + |
| 59 | +## Properties |
| 60 | +The following properties can be passed to the `LControlHeightGraph` component: |
| 61 | + |
| 62 | +### data |
| 63 | +Takes an array of GeoJSON FeatureCollections as described |
| 64 | +in the [Leaflet.Heigthgraph Readme](https://github.com/GIScience/Leaflet.Heightgraph/#supported-data) |
| 65 | +by default. |
| 66 | + |
| 67 | +Specify the `parser` property to use other Array or Object input formats. |
| 68 | + |
| 69 | +Currently supported formats for parser values: |
| 70 | +- `'ors'`: The response of the [openrouteservice directions endpoint](https://openrouteservice.org/dev/#/api-docs/v2/directions/{profile}/geojson/post) |
| 71 | +in geojson fromat. Don't forget to set `elevation=true`. |
| 72 | + |
| 73 | +Other relevant formats can be made available by contributing a parser. |
| 74 | + |
| 75 | +examples: see [data folder](./src/data) |
| 76 | + |
| 77 | +default: `[]` |
| 78 | +### options |
| 79 | +Use the `options` property to specify any of the |
| 80 | +[Leaflet.Heightgraph options](https://github.com/GIScience/Leaflet.Heightgraph#default-options) |
| 81 | +to be set when the control is created. |
| 82 | + |
| 83 | +If no options are specified the default options from Leaflet.Heightgraph are used. |
| 84 | + |
| 85 | +example: |
| 86 | +```js |
| 87 | +{ width: 1000, position: 'bottomleft'} |
| 88 | +``` |
| 89 | + |
| 90 | +### position |
| 91 | +String to set the position on the map. Values can be `'bottomleft'`, `'bottomright'`, `'topleft'`, `'topright'`. |
| 92 | +Fast setting for `options.position` (overwriting). |
| 93 | + |
| 94 | +### expand |
| 95 | +Boolean for expanding the heightgraph window on creation. Values are `true` and `false`. |
| 96 | +Fast setting for `options.expand` (overwriting). |
| 97 | + |
| 98 | +### parser |
| 99 | +Set the name of the parser function as String to support different `data` input. |
| 100 | + |
| 101 | +Available parsers: |
| 102 | +- `'normal'` |
| 103 | +- `'ors'` |
| 104 | + |
| 105 | +If you want to support relevant elevation data, consider contributing a parser function. |
| 106 | + |
| 107 | +default: `'normal'` |
0 commit comments