From 2dbe4e6f88c4e5d93e5d2b00f310778c07062131 Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Thu, 10 Aug 2023 02:52:36 +0300 Subject: [PATCH] Set default home location zoom when centering the map --- app/assets/javascripts/user.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/user.js b/app/assets/javascripts/user.js index 68b399867..8f588cbfd 100644 --- a/app/assets/javascripts/user.js +++ b/app/assets/javascripts/user.js @@ -1,6 +1,7 @@ //= require leaflet.locatecontrol/src/L.Control.Locate $(document).ready(function () { + var defaultHomeZoom = 12; var map, marker, deleted_lat, deleted_lon; if ($("#map").length) { @@ -37,7 +38,7 @@ $(document).ready(function () { .addClass("control-button"); if (OSM.home) { - map.setView([OSM.home.lat, OSM.home.lon], 12); + map.setView([OSM.home.lat, OSM.home.lon], defaultHomeZoom); } else { map.setView([0, 0], 0); } @@ -75,7 +76,7 @@ $(document).ready(function () { var lat = $("#home_lat").val(), lon = $("#home_lon").val(); - map.panTo([lat, lon]); + map.setView([lat, lon], defaultHomeZoom); }); $("#home_delete").click(function () { -- 2.39.5