From 539aa0fcf84b8ff3f82e092cc5d819bfb03c1c92 Mon Sep 17 00:00:00 2001 From: relikd Date: Thu, 27 Jun 2024 01:51:33 +0200 Subject: [PATCH] feat: add locate options --- README.md | 5 +++++ map_location/static/map-location.js | 1 + 2 files changed, 6 insertions(+) diff --git a/README.md b/README.md index 62c8c89..0f579d5 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,10 @@ class Place(models.Model): # 'tileOptions': { # attribution: '© OpenStreetMap', # }, + # 'locate': { + # 'returnToPrevBounds': True, + # 'showPopup': False, + # }, }) ``` @@ -44,6 +48,7 @@ class Place(models.Model): | markerZoom | Initial zoom scale (on load) – if a marker is set. (default: `18`) | tileLayer | [TileLayer](https://leafletjs.com/reference.html#tilelayer) urlTemplate (default: `"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"`) | tileOptions | [TileLayer Options](https://leafletjs.com/reference.html#tilelayer-option) (default: `{}`) +| locate | [Leaflet.Locate Options](https://github.com/domoritz/leaflet-locatecontrol#possible-options) (default: `{returnToPrevBounds: true, showPopup: false}`) ## Usage diff --git a/map_location/static/map-location.js b/map_location/static/map-location.js index 1ae9125..7b7bff5 100644 --- a/map_location/static/map-location.js +++ b/map_location/static/map-location.js @@ -17,6 +17,7 @@ function MapLocationInit(mapId, options = {}) { L.control.locate({ returnToPrevBounds: true, showPopup: false, + ...(options.locate || {}) }).addTo(map); function loadPos() {