Comments (10)
Hey @mhirdes, thanks for your feedback!
I am aware of the preview functionality, but IMO the extension (or extensions in general) should not each include an individual opt-in mechanism as this should be primarily the task of a cookie consent tool. If each extension handles this on its own, configuration for those consent tools is more complex than it should be.
In my world, a cookie consent tool:
- stores the necessary cookie to decide if a service (in this case Google Maps) is accepted
- evaluates the state of a service and triggers the loading of scripts or necessary methods
- shows an opt-in-banner in case consent was not given (including option to accept once or permanently)
Basically each functionality described above is more or less already integrated into the extension. In general, I would recommend to remove the functionality and refer to the use of a cookie consent tool. However, this simple preview might be sufficient for many smaller projects without many cookies and services.
In order to make the integration for cookie consent tools easier, I would propose to:
- Add a new TypoScript constant:
plugin.tx_gomapsext.settings.enableOptInMode
:- This mode changes all scripts to
<script data-src="{src}" data-name="{serviceName}" type="text/plain"></script>
so they are not loaded anymore at all. - This constant could be set automatically by cookie consent extensions, which "officially" support this extension.
- Using this mode, the initialization of the map must be triggered manually (e.g. by cookie consent tool).
- This mode changes all scripts to
- Add a method to initialize a map (e.g. by providing the id of the element "#gme-1"). This method could alternatively also fetch all necessary scripts instead of adding
data
attributes. This method should be as simple as possible and will be called by the consent tool.
Looking forward to your feedback! (Slack: dahaupt)
from go_maps_ext.
If somebody got the same issue, I want to quickly describe a workaround for you to get GoMapsExt working in preview mode running together with a cookie consent tool. In my case it was Cookieman.
-
You need to overwrite the ScriptViewHelper, because you need to change the following things for the script tag generation. (Done it via registration of an XClass)
src
attribute should be changed todata-src
type="text/javascript"
totype="text/plain"
- Add
data-name
attribute with the value "googleMapCE"
Dahaupt's solution looks like this:
$tempJavaScriptFile = GeneralUtility::writeJavaScriptContentToTemporaryFile($this->renderChildren()); GeneralUtility::makeInstance(PageRenderer::class) ->addFooterData('<script data-src="' . $tempJavaScriptFile . '" type="text/plain" data-name="googleMapCE"></script>');
-
Enable the
include_google_api_manually
setting, because it will get injected later throughshowMap()
function inside jquery.gomapsext.preview.js
(showMap()
will be called when you click the preview link) -
Inject the following JS snipped when consent, it will load the GoMapsExt scripts and you're ready to go!
<script>
const $element = $('.tx-go-maps-ext');
if ($element) {
$.when($.getScript('/typo3conf/ext/go_maps_ext/Resources/Public/Scripts/markerclusterer_compiled.js'),
$.getScript('/typo3conf/ext/go_maps_ext/Resources/Public/Scripts/jquery.gomapsext.js'),
$.Deferred(function (deferred) {
$(deferred.resolve);
})).done(function () {
$('script[data-name="googleMapCE"]').each(function () {
$.getScript($(this).data('src'));
});
});
}
</script>
Now your preview link will show the maps after clicked.
from go_maps_ext.
Hi, you can use the TypoScript Setting plugin.tx_gomapsext.preview.enabled = 1. So the Api is not included directly. Then override the partial Resources/Private/Partials/Preview.html. Otherwise how would a good solution for you look like? You can also write on slack.
from go_maps_ext.
Hi @dahaupt,
sry for the late response. I checked again the current preview mode. To overwrite the partial and take a look at the jquery.gomapsext.preview.js it's a good example how to initialize the map. Of course costumization is needed.
But I wrote you an slack today. May we can write there to find a good solution.
from go_maps_ext.
May I ask if you two have found a solution in your Slack discussion?
from go_maps_ext.
@deadmanIsARabbit Unfortunately, I have not responded back to @mhirdes, yet. Will try to find the time to look into this topic again!
from go_maps_ext.
Hey @mhirdes and @dahaupt, I got the same question as @deadmanIsARabbit, ran into the same issue some days ago and it would be great to see a solution coming. Until this will happen I have to find a workaround for this issue.
Currently this appears in combination with the cookieman extension.
from go_maps_ext.
- ScriptViewHelper
Can you descripe it more detailed, were can i find the "ScriptViewHelper" on filesystem and how to override it? Copy code on a special place in this file? Or is there another way, to keep cookieman ready for future updates without override you workaround.
from go_maps_ext.
You don't need to overwrite the script ViewHelper. The tempJavaScriptFile dosen't load any external function.
You can set in the extension manager config, that you load the JS by your own, if the preview function as it self works not for you.
from go_maps_ext.
If any other help is needed for this topic, please contact me on slack
from go_maps_ext.
Related Issues (20)
- Loading the Google Maps JavaScript API without a callback is not supported HOT 4
- Map doesn't show the configured locations on frontend HOT 1
- Error message when custom marker image is set TYPO3 11.5.26, go_maps_ext >=5 HOT 1
- Several maps on one page does not work anymore (since 6.0.0)
- [FEATURE] Make ScriptViewHelper placement configurable with Extension Configuration basic.footerJS HOT 6
- Uncaught (in promise) TypeError: el.gomapsext.controller is undefined HOT 10
- goMapsExtController cached in goMapsExtControllerStorage, when goMapsExtLoaded is called. HOT 3
- Map width / height in % HOT 1
- InfoWindow - close_by_click - dont work - V11.5 - 5.0.0 HOT 1
- T3 11.5 - go_maps_ext 5.0.0 - Marker layout Error HOT 2
- No Plugin available HOT 1
- Route Issue HOT 2
- Not compatible with new composer-structure HOT 1
- scroll_zoom off does have any effect HOT 2
- [FEATURE] 2-click solution for GDPR HOT 1
- Map is not draggable HOT 2
- Request: what3words HOT 1
- Not GDPR compliant HOT 11
- PHP Warning: Undefined array key "ff" in MapController.php line 246 HOT 3
- Package clickstorm/go_maps_ext is abandoned, you should avoid using it. Use clickstorm/go-maps-ext instead HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go_maps_ext.