Skip to content

Commit

Permalink
Merge pull request #784 from modos189/fix/mobile-view
Browse files Browse the repository at this point in the history
Positioning Leaflet elements using CSS Grid
  • Loading branch information
modos189 authored Dec 13, 2024
2 parents 738472d + 9e89dc0 commit 86900f9
Show file tree
Hide file tree
Showing 12 changed files with 171 additions and 156 deletions.
26 changes: 26 additions & 0 deletions core/code/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,32 @@ window.setupMap = function () {

map.attributionControl.setPrefix('');

/**
* Override default Google Maps attribution to use Leaflet's native attribution control
* instead of creating separate DOM elements. Extracts text content from Google's
* attribution container and adds it to Leaflet's control.
*/
L.GridLayer.GoogleMutant.prototype._setupAttribution = function (ev) {
if (!this._map?.attributionControl) {
return;
}
// eslint-disable-next-line
const pos = google.maps.ControlPosition;
const container = ev.positions.get(pos.BOTTOM_RIGHT);
const attribution = container?.querySelector('span')?.textContent;
if (attribution) {
this._attributionText = attribution; // Сохраняем текст атрибуции
this._map.attributionControl.addAttribution(attribution);
}
};
const originalGoogleMutantOnRemove = L.GridLayer.GoogleMutant.prototype.onRemove;
L.GridLayer.GoogleMutant.prototype.onRemove = function (map) {
originalGoogleMutantOnRemove.call(this, map);
if (this._attributionText && map.attributionControl) {
map.attributionControl.removeAttribution(this._attributionText);
}
};

window.map = map;

map.on('moveend', function () {
Expand Down
3 changes: 0 additions & 3 deletions core/code/portal_detail_display.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,6 @@ window.renderPortalDetails = function (guid, forceSelect) {
.text('X')
.click(function () {
window.renderPortalDetails(null);
if (window.isSmartphone()) {
window.show('map');
}
}),

// help cursor via ".imgpreview img"
Expand Down
4 changes: 1 addition & 3 deletions core/code/portal_highlighter.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,10 @@ window.updatePortalHighlighterControl = function () {

if (window._highlighters !== null) {
if ($('#portal_highlight_select').length === 0) {
$('body').append("<select id='portal_highlight_select'></select>");
$('.leaflet-top.leaflet-left').first().append("<select id='portal_highlight_select' class='leaflet-control'></select>");
$('#portal_highlight_select').change(function () {
window.changePortalHighlights($(this).val());
});
$('.leaflet-top.leaflet-left').css('padding-top', '20px');
$('.leaflet-control-scale-line').css('margin-top', '25px');
}
$('#portal_highlight_select').html('');
$('#portal_highlight_select').append($('<option>').attr('value', window._no_highlighter).text(window._no_highlighter));
Expand Down
159 changes: 68 additions & 91 deletions core/external/Leaflet.GoogleMutant.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions core/smartphone.css
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,6 @@ body {
margin-left: 4px;
}

.leaflet-top .leaflet-control {
margin-top: 5px !important;
margin-left: 5px !important;
}

#searchwrapper .ui-accordion-header {
padding: 0.3em 0;
}
Expand Down
Loading

0 comments on commit 86900f9

Please sign in to comment.