diff --git a/docs/config.md b/docs/config.md index d7d450c..243df23 100644 --- a/docs/config.md +++ b/docs/config.md @@ -60,6 +60,7 @@ window.owntracks.config = {}; - [`polyline`](#mappolyline) - [`url`](#mapurl) - `onLocationChange` + - [`fitView`](#onlocationchangefitview) - [`reloadHistory`](#onlocationchangereloadhistory) - [`primaryColor`](#primarycolor) - [`selectedDevice`](#selecteddevice) @@ -403,6 +404,15 @@ and [this Wikipedia article](https://en.wikipedia.org/wiki/Tiled_web_map). }; ``` +### `onLocationChange.fitView` + +Whether to re-fit the map's content into view or not when a location update is received. + +This can be useful if you're showing live locations and don't want them to "leave" the map. + +- Type: [`Boolean`] +- Default: `false` + ### `onLocationChange.reloadHistory` Whether to reload the location history (of selected date range) or not when a location diff --git a/src/config.js b/src/config.js index fe065df..aa71e5b 100644 --- a/src/config.js +++ b/src/config.js @@ -67,6 +67,7 @@ const DEFAULT_CONFIG = { url: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", }, onLocationChange: { + fitView: false, reloadHistory: false, }, primaryColor: "#3f51b5", diff --git a/src/views/Map.vue b/src/views/Map.vue index 07717fd..44f5565 100644 --- a/src/views/Map.vue +++ b/src/views/Map.vue @@ -232,7 +232,9 @@ export default { }, watch: { lastLocations() { - this.fitView(); + if (this.$config.onLocationChange.fitView) { + this.fitView(); + } }, filteredLocationHistory() { this.fitView();