Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Classes/FormEngine/FieldControl/LocationMapWizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public function render(): array
$resultArray['linkAttributes']['data-label-title'] = $this->getLanguageService()->sL('LLL:EXT:tt_address/Resources/Private/Language/locallang_db.xlf:tt_address.locationMapWizard');
$resultArray['linkAttributes']['data-label-close'] = $this->getLanguageService()->sL('LLL:EXT:tt_address/Resources/Private/Language/locallang_db.xlf:tt_address.locationMapWizard.close');
$resultArray['linkAttributes']['data-label-import'] = $this->getLanguageService()->sL('LLL:EXT:tt_address/Resources/Private/Language/locallang_db.xlf:tt_address.locationMapWizard.import');
$resultArray['linkAttributes']['data-label-search'] = $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:search');
$resultArray['linkAttributes']['data-lat'] = $lat;
$resultArray['linkAttributes']['data-lon'] = $lon;
$resultArray['linkAttributes']['data-glat'] = $gLat;
Expand Down
18 changes: 11 additions & 7 deletions Resources/Public/Backend/LocationMapWizard/leafletBackend.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#t3js-location-map-wrap {
background: #EDEDED;
position: absolute;
width: 80vw;
height: 80vh;
Expand All @@ -21,11 +22,6 @@
border: 1px solid #CCC;
}

.t3js-location-map-title>div.btn-group {
position: absolute;
left: 15px;
}

.t3js-location-map-title a {
font-weight: bold;
}
Expand All @@ -34,6 +30,14 @@
background: rgb(237, 237, 237);
font-family: Share, Verdana, Arial, Helvetica, sans-serif;
font-size: 20px;
padding: 5px 15px;
text-align: center;
text-align: left;
position: relative;
padding: 0 15px 10px;
}

#t3js-location-map-search {
margin-top: 10px;
}
.t3js-location-map-search-input {
max-width: 200px;
}
33 changes: 32 additions & 1 deletion Resources/Public/JavaScript/LeafletBackend.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,18 @@ define(['jquery', 'TYPO3/CMS/Backend/Icons', 'TYPO3/CMS/TtAddress/leaflet-core-1
$tilesUrl: null,
$tilesCopy: null,
$zoomLevel: 13,
$zoomLevelDetail: 13,
$marker: null,
$map: null
};

var geoCodeService = 'https://nominatim.openstreetmap.org/search/';

$(function () {
// basic variable initalisation
LeafBE.$element = $('#location-map-container-a');
LeafBE.$labelTitle = LeafBE.$element.attr('data-label-title');
LeafBE.$labelSearch = LeafBE.$element.attr('data-label-search');
LeafBE.$labelClose = LeafBE.$element.attr('data-label-close');
LeafBE.$labelImport = LeafBE.$element.attr('data-label-import');
LeafBE.$latitude = LeafBE.$element.attr('data-lat');
Expand All @@ -44,13 +48,19 @@ define(['jquery', 'TYPO3/CMS/Backend/Icons', 'TYPO3/CMS/TtAddress/leaflet-core-1
$('body').append(
'<div id="t3js-location-map-wrap">' +
'<div class="t3js-location-map-title">' +
'<h4>' + LeafBE.$labelTitle + '</h4>' +
'<div class="btn-group"><a href="#" class="btn btn-icon btn-default" title="' + LeafBE.$labelClose + '" id="t3js-ttaddress-close-map">' +
LeafBE.$iconClose +
'</a>' +
'<a class="btn btn-default" href="#" title="Import marker position to form" id="t3js-ttaddress-import-position">' +
LeafBE.$labelImport +
'</a></div>' +
LeafBE.$labelTitle +
'<form id="t3js-location-map-search" class="input-group">' +
'<input id="t3js-location-map-search-input" type="text" class="form-control" />' +
'<span class="input-group-btn">' +
'<button type="button" id="t3js-location-map-search-submit" class="btn btn-default">' + LeafBE.$labelSearch + '</button>' +
'</span>' +
'</form>' +
'</div>' +
'<div class="t3js-location-map-container" id="t3js-location-map-container">' +
'</div>' +
Expand Down Expand Up @@ -144,6 +154,27 @@ define(['jquery', 'TYPO3/CMS/Backend/Icons', 'TYPO3/CMS/TtAddress/leaflet-core-1
// close map after import of coordinates.
$('#t3js-location-map-wrap').removeClass('active');
});
$('#t3js-location-map-search').on('submit', function (e) {
e.preventDefault();
e.stopPropagation();

var params = {
q: $('#t3js-location-map-search-input').val(),
format: 'json',
addressdetails: true,
limit: 1
};
$.getJSON(geoCodeService, params, function (data) {
if (data.length > 0) {
var location = {lat: data[0].lat, lng: data[0].lon};
LeafBE.$marker.setLatLng(location);
LeafBE.$map.panTo(location);
LeafBE.$map.setZoom(LeafBE.$zoomLevelDetail);
}
});

return false;
});
// close overlay without any further action
$('#t3js-ttaddress-close-map').on('click', function () {
$('#t3js-location-map-wrap').removeClass('active');
Expand Down