diff --git a/assets/javascripts/discourse/lib/map-utilities.js.es6 b/assets/javascripts/discourse/lib/map-utilities.js.es6 index 6e5124d0..bcc2c8d3 100644 --- a/assets/javascripts/discourse/lib/map-utilities.js.es6 +++ b/assets/javascripts/discourse/lib/map-utilities.js.es6 @@ -61,8 +61,25 @@ const setupMap = function ( [b[1], b[3]], ]); } else if (markers) { - const maxZoom = siteSettings.location_map_marker_zoom; - map.fitBounds(markers.getBounds().pad(0.1), { maxZoom }); + if (siteSettings.location_alternative_marker_map_padding_strategy) { + let bounds = markers.getBounds(); + let fitZoom = map.getBoundsZoom(bounds); + + map.setView( + bounds.getCenter(), + fitZoom - + siteSettings.location_alternative_marker_map_padding_zoom_out_extent + ); + } else { + const maxZoom = siteSettings.location_map_marker_zoom; + + map.fitBounds( + markers + .getBounds() + .pad(siteSettings.location_marker_map_padding_extent), + { maxZoom } + ); + } } else { const defaultLat = Number(siteSettings.location_map_center_lat); const defaultLon = Number(siteSettings.location_map_center_lon); diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index a8d0334f..bc7e9f73 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -28,6 +28,9 @@ en: location_map_marker_category_color: "Set marker color as the category color of the marker topic." location_map_maker_cluster_enabled: "Enable marker clustering" location_map_zoom: "Default zoom level for maps." + location_marker_map_padding_extent: "Amount of padding around markers" + location_alternative_marker_map_padding_strategy: "Alternative strategy for padding a view of markers by zooming out x levels" + location_alternative_marker_map_padding_zoom_out_extent: "Level of zoom out (x) for alternative marker padding strategy" location_map_expanded_zoom: "Default zoom level for expanded maps." location_map_center_lat: "Default center latitude for maps." location_map_center_lon: "Default center longitude for maps." diff --git a/config/settings.yml b/config/settings.yml index b8d0bbc8..d29e7088 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -81,6 +81,15 @@ plugins: location_map_marker_zoom: default: 16 client: true + location_marker_map_padding_extent: + default: 0.1 + client: true + location_alternative_marker_map_padding_strategy: + default: false + client: true + location_alternative_marker_map_padding_zoom_out_extent: + default: 0.5 + client: true location_map_marker_cluster_multiplier: default: 6 client: true diff --git a/plugin.rb b/plugin.rb index 8fd48487..1e077b43 100644 --- a/plugin.rb +++ b/plugin.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # name: discourse-locations # about: Tools for handling locations in Discourse -# version: 6.5.1 +# version: 6.5.2 # authors: Angus McLeod, Robert Barrow # contact_emails: development@pavilion.tech # url: https://github.com/angusmcleod/discourse-locations