Skip to content

Go Maps Ext

Dirk Persky edited this page Nov 21, 2022 · 2 revisions

Overwrite Partials from Extension

go_maps_ext/Partials/Maps/Assign.html

<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true"
      xmlns:gomapsext="http://typo3.org/ns/Clickstorm/GoMapsExt/ViewHelpers">

<script data-cookieconsent="marketing" type="text/plain">
    (function ($, window, document, undefined) {
        $(function () {
        var gme = new Object();
    
        gme.zoomTypes = new Array(0,1,2);
        gme.defaultMapTypes = new Array("roadmap", "satellite", "hybrid", "terrain", "{map.styledMapName}");
    
        gme.mapSettings = <f:format.raw>{</f:format.raw>
        id: 'gme-' + {map.uid},
        title: '<gomapsext:escape>{map.title}</gomapsext:escape>',
        width: '{map.width}',
        height: '{map.height}',
        zoom: {f:if(condition:"{map.zoom}", then:"{map.zoom}", else:"0")},
        minZoom: {f:if(condition:"{map.zoomMin}", then:"{map.zoomMin}", else:"0")},
        maxZoom: {f:if(condition:"{map.zoomMax}", then:"{map.zoomMax}", else:"0")},
        lat: {f:if(condition:"{map.latitude} != 0", then: "{map.latitude}", else:"0")},
        lng: {f:if(condition:"{map.longitude} != 0", then: "{map.longitude}", else:"0")},
        geolocation: {f:if(condition:"{map.geolocation} != 0", then: "1", else:"0")},
        kmlUrl: '{map.kmlUrl}',
        kmlPreserveViewport: {f:if(condition:"{map.kmlPreserveViewport}", then:"true", else:"false")},
        kmlLocal: {f:if(condition:"{map.kmlLocal}", then:"1", else:"0")},
        scrollZoom: {f:if(condition:"{map.scrollZoom}", then:"1", else:"0")},
        draggable: {f:if(condition:"{map.draggable}", then:"1", else:"0")},
        doubleClickZoom: {f:if(condition:"{map.doubleClickZoom}", then:"0", else:"1")},
        markerCluster: {f:if(condition:"{map.markerCluster}", then:"1", else:"0")},
        markerClusterZoom: {f:if(condition:"{map.markerClusterZoom} > 0", then:"{map.markerClusterZoom}", else:"null")},
        markerClusterSize: {f:if(condition:"{map.markerClusterSize} > 0", then:"{map.markerClusterSize}", else:"null")},
        <f:if condition="{map.markerClusterStyle}">
            <f:then>
                markerClusterStyle: <f:format.html parseFuncTSPath="">{map.markerClusterStyle}</f:format.html>,
            </f:then>
            <f:else>
                markerClusterStyle: '',
            </f:else>
        </f:if>
        markerSearch: {f:if(condition:"{map.markerSearch}", then:"1", else:"0")},
        defaultType: {map.defaultType},
        scaleControl: {f:if(condition:"{map.scaleControl}", then:"1", else:"0")},
        streetviewControl: {f:if(condition:"{map.streetviewControl}", then:"1", else:"0")},
        fullscreenControl: {f:if(condition:"{map.fullscreenControl}", then:"1", else:"0")},
        zoomControl: {f:if(condition:"{map.zoomControl}", then:"1", else:"0")},
        mapTypeControl: {f:if(condition:"{map.mapTypeControl}", then:"1", else:"0")},
        showRoute: {f:if(condition:"{map.showRoute}", then:"1", else:"0")},
        calcRoute: {f:if(condition:"{map.calcRoute}", then:"1", else:"0")},
        travelMode: {map.travelMode},
        unitSystem: {map.unitSystem},
        showForm: {f:if(condition:"{map.showForm}", then:"1", else:"0")},
        showCategories: {f:if(condition:"{map.showCategories}", then:"1", else:"0")},
        logicalAnd: {f:if(condition:"{settings.logicalAnd}", then:"1", else:"0")},
        styledMapName: '{map.styledMapName}',
        <f:if condition="{map.styledMapCode}">
            <f:then>
                styledMapCode: <f:format.html parseFuncTSPath="">{map.styledMapCode}</f:format.html>,
            </f:then>
            <f:else>
                styledMapCode: '',
            </f:else>
        </f:if>
        defaultZoom: 11
        <f:format.raw>}</f:format.raw>
    
        gme.mapSettings.mapTypes = new Array();
        <f:for each="{map.mapTypes}" as="type" iteration="i">
            gme.mapSettings.mapTypes[{i.index}] = gme.defaultMapTypes[{type}];
        </f:for>
    
        gme.request = new Array();
    
        <f:for each="{request}" as="item" iteration="i" key="k">
            gme.request['{k}'] = '{item}';
        </f:for>
    
        gme.addresses = new Array();
        <f:for each="{addresses}" as="address" iteration="i">
            gme.addresses[{i.index}]  = <f:format.raw>{</f:format.raw>
            uid: {address.uid},
            title: '<gomapsext:escape>{address.title}</gomapsext:escape>',
            latitude: {address.latitude -> f:format.number(decimals:6, thousandsSeparator:'')},
            longitude: {address.longitude -> f:format.number(decimals:6, thousandsSeparator:'')},
            address: '<gomapsext:escape>{address.address}</gomapsext:escape>',
            <f:if condition="{address.marker}">
                <f:then>
                    <f:if condition="{address.imageSize}">
                        <f:then>
                            marker: '{f:uri.image(src:address.marker.uid,absolute:1,treatIdAsReference:1,width:address.imageWidth,height:'{address.imageHeight}c')}',
                            imageSize: 1,
                        </f:then>
                        <f:else>
                            marker: '{f:uri.image(src:address.marker.originalResource.publicUrl,absolute:1)}',
                            imageSize: 0,
                        </f:else>
                    </f:if>
                </f:then>
                <f:else>
                    <f:for each="{address.categories}" as="category" iteration="icat">
                        <f:if condition="{category.gmeMarker}">
                            <f:if condition="{category.gmeImageSize}">
                                <f:then>
                                    marker: '{f:uri.image(src:category.gmeMarker.uid,absolute:1,treatIdAsReference:1,width:category.gmeImageWidth,height:'{category.gmeImageHeight}c')}',
                                    imageSize: 1,
                                </f:then>
                                <f:else>
                                    marker: '{f:uri.image(src:category.gmeMarker.originalResource.publicUrl,absolute:1)}',
                                    imageSize: 0,
                                </f:else>
                            </f:if>
                        </f:if>
                    </f:for>
                </f:else>
            </f:if>
    
            imageWidth: '{address.imageWidth}',
            imageHeight: '{address.imageHeight}',
            infoWindowContent: '<f:format.raw><gomapsext:escape><f:render partial="Map/InfoWindow" arguments="{_all}" /></gomapsext:escape></f:format.raw>',
            infoWindowLink: '{address.infoWindowLink}',
            <f:if condition="{settings.infoWindow.openByClick}">
                <f:then>
                    openByClick: 1,
                </f:then>
                <f:else>
                    openByClick: {f:if(condition:"{address.openByClick}", then:"1", else:"0")},
                </f:else>
            </f:if>
            <f:if condition="{settings.infoWindow.closeByClick}">
                <f:then>
                    closeByClick: 1,
                </f:then>
                <f:else>
                    closeByClick: {f:if(condition:"{address.closeByClick}", then:"1", else:"0")},
                </f:else>
            </f:if>
            opened: {f:if(condition:"{address.opened}", then:"1", else:"0")},
            categories: '<f:for each="{address.categories}" as="category" iteration="icat">{category.uid}{f:if(condition:icat.isLast,then:'',else:',')}</f:for>'
            <f:format.raw>}</f:format.raw>
        </f:for>
    
        gme.ll = {};
        gme.ll.alert = "<f:translate key="LLL:EXT:go_maps_ext/Resources/Private/Language/locallang.xlf:tx_gomapsext_partials_map_assign.alert" />";
        gme.ll.submit = "<f:translate key="LLL:EXT:go_maps_ext/Resources/Private/Language/locallang.xlf:tx_gomapsext_partials_map_assign.submit" />";
        gme.ll.noSearchResults = "<f:translate key="LLL:EXT:go_maps_ext/Resources/Private/Language/locallang.xlf:tx_gomapsext_partials_map_assign.noSearchResults" />";
        gme.ll.infoWindowLinkText = "<f:translate key="LLL:EXT:go_maps_ext/Resources/Private/Language/locallang.xlf:tx_gomapsext_partials_map_assign.infoWindowLinkText" />";
        var $element = $("#" + gme.mapSettings.id);
        /**
         * load Google Map & Init Scripts
         * Dirk Persky Overwrite
         */
        jQuery.getScript('{googleMapsLibrary ->f:format.raw()}', function(){
            $element.gomapsext(gme);
        });
        /**
         * END Dirk Persky Overwrite
         */
        
        if(gme.mapSettings.width.indexOf('%') != -1) {
            $(window).resize(function() {
                $element.trigger('mapresize');
            });
        }
    
        }); // end of closure
    })(jQuery || $, window, document);
</script>
</html>

go_maps_ext/Partials/Templates/Show.html

<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">
<f:layout name="Default"/>
<!-- Keep the id and the js-classes -->
<f:section name="Main">
    <f:if condition="{settings.preview.enabled}">
        <f:render partial="Preview" arguments="{_all}"/>
    </f:if>
    <dp-content data-cookieconsent="marketing" class="dp--iframe" >
        <div class="js-gme-container">
            <f:if condition="{map.showForm}">
                <f:render partial="Map/Form" arguments="{_all}"/>
            </f:if>
            <div class="js-map" id="gme-{map.uid}"></div>
            <f:render partial="Map/Assign" arguments="{_all}"/>
            <f:if condition="{map.showCategories}">
                <f:render partial="Map/Categories" arguments="{_all}"/>
            </f:if>
            <f:if condition="{map.showAddresses}">
                <f:render partial="Map/Addresses" arguments="{_all}"/>
            </f:if>
        </div>
    </dp-content>
</f:section>
</html>

Change Plugin Settings:
image

Clone this wiki locally