misc: adjust map behaviours and controls (#41466) #681

Merged
fpeters merged 1 commits from wip/41466-map-zoom-gestures into main 2023-09-19 16:54:09 +02:00
2 changed files with 8 additions and 16 deletions

View File

@ -24,20 +24,16 @@ $(window).on('wcs:maps-init', function() {
L.latLng($map_widget.data('max-bounds-lat1'), $map_widget.data('max-bounds-lng1')),
L.latLng($map_widget.data('max-bounds-lat2'), $map_widget.data('max-bounds-lng2')));
}
if ($map_widget.data('readonly') && $map_widget.attr('id') != 'backoffice-map') {
map_options.scrollWheelZoom = 'center';
map_options.doubleClickZoom = 'center';
map_options.maxBounds = null;
} else {
map_options.gestureHandling = true;
}
map_options.gestureHandling = true;
var map = L.map($(this).attr('id'), map_options);
var map_controls_position = $('body').data('map-controls-position') || 'topleft';
new L.Control.Zoom({
if (! ($map_widget.parents('#sidebar').length || $map_widget.parents('td').length)) {
new L.Control.Zoom({
position: map_controls_position,
zoomInTitle: WCS_I18N.map_zoom_in,
zoomOutTitle: WCS_I18N.map_zoom_out
}).addTo(map);
}).addTo(map);
}
$map_widget[0].leaflet_map = map;
var gps_control = new L.Control.Gps({
position: map_controls_position,
@ -64,11 +60,7 @@ $(window).on('wcs:maps-init', function() {
attribution: map_attribution,
maxZoom: map_options.maxZoom
}).addTo(map);
if ($map_widget.data('readonly') && $map_widget.attr('id') != 'backoffice-map') {
map.dragging.disable();
map.boxZoom.disable();
map.keyboard.disable();
} else {
if (! $map_widget.data('readonly')) {
map.addControl(gps_control);
}
if ($map_widget.data('markers-url')) {
@ -198,7 +190,7 @@ $(window).on('wcs:maps-init', function() {
});
}
if (typeof L.Control.Search != 'undefined') {
if (typeof L.Control.Search != 'undefined' && $map_widget.data('search-url')) {
var search_control = new L.Control.Search({
labels: {
hint: WCS_I18N.map_search_hint,

View File

@ -10,7 +10,7 @@
data-init-lat="{{ widget.initial_position.lat }}"
data-init-lng="{{ widget.initial_position.lng }}"
{% endif %}
data-search-url="{% url 'api-geocoding' %}"
{% if not widget.readonly %}data-search-url="{% url 'api-geocoding' %}"{% endif %}
{% block widget-control-attributes %}{% endblock %}
></div>
{% endblock %}