From 3d6dc8434816f57e066ea2596254700a98b8b4f3 Mon Sep 17 00:00:00 2001 From: Roman Teitge <83205200+rteitge@users.noreply.github.com> Date: Mon, 9 Sep 2024 05:40:52 +0200 Subject: [PATCH 1/3] fix async geocode function (#577) Inside the nested async function of `geocode()` you have no access to `this`. So I removed the nested function and defined `geocode` as async itself. Then it works. --- .../Public/JavaScript/esm/leaflet-backend.js | 39 +++++++++---------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/Resources/Public/JavaScript/esm/leaflet-backend.js b/Resources/Public/JavaScript/esm/leaflet-backend.js index 595035f7..3e3913f8 100644 --- a/Resources/Public/JavaScript/esm/leaflet-backend.js +++ b/Resources/Public/JavaScript/esm/leaflet-backend.js @@ -200,31 +200,28 @@ class LeafletBackendModule { .classList.remove("active"); } - geocode() { - async function fetchGeoData() { - try { - let response = await fetch(this.geoCodeUrl); - let data = await response.json(); - - if (data.length === 0) { - response = await fetch(this.geoCodeUrlShort); - data = await response.json(); - } + async geocode() { + try { + let response = await fetch(this.geoCodeUrl); + let data = await response.json(); + + if (data.length === 0) { + response = await fetch(this.geoCodeUrlShort); + data = await response.json(); + } - if (data.length !== 0) { - const firstResult = data[0]; - if ("lat" in firstResult) { - this.latitude = firstResult.lat; - } - if ("lon" in firstResult) { - this.longitude = firstResult.lon; - } + if (data.length !== 0) { + const firstResult = data[0]; + if ("lat" in firstResult) { + this.latitude = firstResult.lat; + } + if ("lon" in firstResult) { + this.longitude = firstResult.lon; } - } catch (error) { - console.error("Error fetching geo data:", error); } + } catch (error) { + console.error("Error fetching geo data:", error); } - fetchGeoData(); } } From c6bad72ac99cfde8bd135fa9feafc731017d0026 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caroline=20L=C3=B6bhard?= <35564122+oracline@users.noreply.github.com> Date: Mon, 9 Sep 2024 05:41:28 +0200 Subject: [PATCH 2/3] Migrate deprecated google marker to google advanced marker (#576) * Google Advanced Markers need a map ID. Adjust documentation. * load marker library from google maps api, neccessary for AdvancedMarkers * get mapId from settings into javascript * include basic AdvancedMarkers, without InfoWindow (because it breaks in new version) * prepare new marker for InfoWindow * Fix some var/const javascript things * include InfoWindow again --------- Co-authored-by: Dr. Caroline Loebhard Co-authored-by: Georg Ringer --- .../Configuration/TypoScript/Index.rst | 9 +++++++ Resources/Private/Partials/Maps.html | 12 ++++++--- .../Public/JavaScript/Frontend/GoogleMaps.js | 26 +++++++++++-------- 3 files changed, 33 insertions(+), 14 deletions(-) diff --git a/Documentation/Configuration/TypoScript/Index.rst b/Documentation/Configuration/TypoScript/Index.rst index 0a01c6c3..20b489a5 100755 --- a/Documentation/Configuration/TypoScript/Index.rst +++ b/Documentation/Configuration/TypoScript/Index.rst @@ -168,6 +168,7 @@ Settings settings { map { googleMaps.key = ABCDEFG123 + googleMaps.mapId = DEMO_MAP_ID rendering = googleMaps } } @@ -180,6 +181,14 @@ Settings Key for variant **Google Maps** +.. confval:: settings.map.googleMaps.mapId + + :Path: plugin.tx_ttaddress + :type: string + + Map ID for **Google Maps** + See: `official docs `__ + .. confval:: map.staticGoogleMaps.parameters :Path: plugin.tx_ttaddress diff --git a/Resources/Private/Partials/Maps.html b/Resources/Private/Partials/Maps.html index 10c8cd8f..58cdb38c 100644 --- a/Resources/Private/Partials/Maps.html +++ b/Resources/Private/Partials/Maps.html @@ -15,9 +15,15 @@ - - + + +
{f:translate(key:'no_google_maps_key')}
diff --git a/Resources/Public/JavaScript/Frontend/GoogleMaps.js b/Resources/Public/JavaScript/Frontend/GoogleMaps.js index efa99bad..137c03a3 100644 --- a/Resources/Public/JavaScript/Frontend/GoogleMaps.js +++ b/Resources/Public/JavaScript/Frontend/GoogleMaps.js @@ -1,45 +1,49 @@ function ttAddressGoogleMaps() { var obj = {}; + var mapId = document.getElementById("ttaddress_google_maps").getAttribute("data-mapId"); obj.map = null; obj.markers = []; obj.run = function () { - const mapOptions = { + var mapOptions = { center: new google.maps.LatLng(48.3057664, 14.2873126), zoom: 11, maxZoom: 15, streetViewControl: false, - fullscreenControl: false + fullscreenControl: false, + mapId: mapId, // Map ID is required for advanced markers. }; obj.map = new google.maps.Map(document.getElementById('ttaddress__map'), mapOptions); - infoWindow = new google.maps.InfoWindow(); + var infoWindow = new google.maps.InfoWindow(); var bounds = new google.maps.LatLngBounds(); var records = document.getElementById("ttaddress__records").children; for (var i = 0; i < records.length; i++) { var item = records[i]; + var recordId = item.getAttribute('data-id'); + var position = new google.maps.LatLng(item.getAttribute('data-lat'), item.getAttribute('data-lng')); - var marker = new google.maps.Marker({ + const marker = new google.maps.marker.AdvancedMarkerElement({ map: obj.map, - position: new google.maps.LatLng(item.getAttribute('data-lat'), item.getAttribute('data-lng')), - infowindow: infoWindow, - recordId: item.getAttribute('data-id') + position: position, + gmpClickable: true, + title: recordId, }); google.maps.event.addListener(marker, 'click', function (e) { - infoWindow.setContent(document.getElementById('ttaddress__record-' + this.recordId).innerHTML); + infoWindow.setContent(document.getElementById('ttaddress__record-' + marker.title).innerHTML); infoWindow.open(obj.map, this); var allLabels = document.querySelectorAll('.ttaddress__label'); for (var i = 0; i < allLabels.length; i++) { allLabels[i].classList.remove('active') } - document.getElementById('ttaddress__label-' + this.recordId).classList.add('active'); - + document.getElementById('ttaddress__label-' + marker.title).classList.add('active'); }); - bounds.extend(marker.getPosition()); + + bounds.extend(position); obj.markers.push(marker); } obj.map.fitBounds(bounds); From dd0706a23f79e2f62df5163b313a9e391008760e Mon Sep 17 00:00:00 2001 From: Lina Wolf <48202465+linawolf@users.noreply.github.com> Date: Thu, 31 Oct 2024 07:52:37 +0100 Subject: [PATCH 3/3] [TASK] Update .editorconfig (#575) Use the same settings like the Core and tabs for makefiles to prevent errors. --- .editorconfig | 67 +++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 57 insertions(+), 10 deletions(-) diff --git a/.editorconfig b/.editorconfig index bb0a62f4..d91f59e1 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,20 +1,67 @@ +# EditorConfig is awesome: http://EditorConfig.org + +# top-most EditorConfig file root = true -[{*.rst,*.rst.txt}] +# Unix-style newlines with a newline ending every file +[*] charset = utf-8 end_of_line = lf +indent_style = space +indent_size = 4 insert_final_newline = true trim_trailing_whitespace = true -indent_style = space -indent_size = 3 + +# TS/JS-Files +[*.{ts,js,mjs}] +indent_size = 2 + +# JSON-Files +[*.json] +indent_style = tab + +# ReST-Files +[*.{rst,rst.txt}] +indent_size = 4 max_line_length = 80 -# MD-Files +# Markdown-Files [*.md] -charset = utf-8 -end_of_line = lf -insert_final_newline = true -trim_trailing_whitespace = true -indent_style = space -indent_size = 4 max_line_length = 80 + +# YAML-Files +[*.{yaml,yml}] +indent_size = 2 + +# NEON-Files +[*.neon] +indent_size = 2 +indent_style = tab + +# stylelint +[.stylelintrc] +indent_size = 2 + +# package.json +[package.json] +indent_size = 2 + +# TypoScript +[*.{typoscript,tsconfig}] +indent_size = 2 + +# XLF-Files +[*.xlf] +indent_style = tab + +# SQL-Files +[*.sql] +indent_style = tab +indent_size = 2 + +# .htaccess +[{_.htaccess,.htaccess}] +indent_style = tab + +[Makefile] +indent_style = tab