Forum

Thread tagged as: Problem, Events

Map in event displaying as static image

I've added a google map to the events template, which works fine in the cms pages but displays as a static image on the public facing pages.

I have "define('PERCH_RWD', true); " in my config file and .cmsmap with width and height specified in css. I have tried both with and without specifying widths and heights in the templates with the same results. Javascript console in Chrome dev tools doesn't throw any errors.

Where should I look next?

Thanks

Peter

event.html template:

<div class="vevent">
    <h2 class="summary"><perch:events id="eventTitle" /></h2>

    <p class="dtstart"><span class="value-title" title="<perch:events id="eventDateTime" format="c" />"><perch:events id="eventDateTime" format="%c" /></span></p>

    <div class="description"><perch:events id="eventDescHTML" type="textarea" html="true" editor="redactor" size="m" encode="false" /></div>
    <div class="description"><perch:events id="eventDescHTML_es" type="textarea" html="true" editor="redactor" size="m" encode="false" suppress="true" label="Descripció castellà" /></div>
    <p>
        <strong><perch:events id="eventPlace" type="text" label="Lloc" /></strong><br>
        <perch:events id="eventTown" type="text" label="Població" /><br>
        <perch:events id="eventPrice" type="text" label="Preu" />
    </p>
    <div>
        <perch:events id="map" type="map" label="Ubicació" width="600" height="400" zoom="18">
    </div>

    <p class="category"><perch:events id="category_names" encode="false" /></p>

    <perch:if exists="image">
        <img src="<perch:events id="image" type="image" label="Image" width="640" crop="true" />" alt="<perch:events id="eventTitle" />" />
    </perch:if>
</div>

On the individual event page:

<?php
    setlocale(LC_TIME, 'ca_ES', 'Catalan_Spain', 'Catalan'); 
    perch_events_custom(array(
        'filter'=>'eventSlug',
        'match'=>'eq',
        'value'=>perch_get('s'),
        'template'=>'events/event.html'
    ));
?>  

map.html template:

<div>
    <perch:content id="map" type="map" label="Address" width="600" height="400" zoom="15">
</div>

Diagnostics:

Perch: 3.1.1, PHP: 7.0.6, MySQL: 5.5.59, with PDO
Server OS: Linux, cgi-fcgi
Installed apps: content (3.1.1), categories (3.1.1), assets (3.1.1), perch_blog (5.6.1), perch_events (1.9.5)
App runtimes: <?php $apps_list = [ 'perch_blog', 'perch_events' ];
PERCH_LOGINPATH: /admin
PERCH_PATH: /nfs/c04/h07/mnt/80204/domains/2018.dotarragona.cat/html/admin
PERCH_CORE: /nfs/c04/h07/mnt/80204/domains/2018.dotarragona.cat/html/admin/core
PERCH_RESFILEPATH: /nfs/c04/h07/mnt/80204/domains/2018.dotarragona.cat/html/admin/resources
Image manipulation: GD
PHP limits: Max upload 40M, Max POST 40M, Memory: 64M, Total max file upload: 40M
F1: 3b606135b33e6a102526838f4152a807
Resource folder writeable: Yes
HTTP_HOST: 2018.dotarragona.cat
DOCUMENT_ROOT: /home/80204/domains/2018.dotarragona.cat/html
REQUEST_URI: /admin/core/settings/diagnostics/
SCRIPT_NAME: /admin/core/settings/diagnostics/index.php
Peter Hodder-Williams

Peter Hodder-Williams 0 points

  • 3 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Which services have you enabled for your Google API key?

Geocoding API, Maps Embed API, Maps JavaScript API, Maps Static API, Street View API

are all enabled.

Drew McLellan

Drew McLellan 2638 points
Perch Support

That should work fine. Do you get any errors in your browser dev tools?

Drew McLellan said:

That should work fine. Do you get any errors in your browser dev tools?

Only one "verbose" message: "Added non-passive event listener to a scroll-blocking 'mousewheel' event. Consider marking event handler as 'passive' to make the page more responsive."

I'm using a custom version of maps.js (just added in a few lines of map styling and to reposition the centre of the map) which I've saved to perch/templates/maps/maps.js and referenced in config.php. I have checked with the default map.js too and no joy.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Is the page online somewhere?

Drew McLellan

Drew McLellan 2638 points
Perch Support

That's odd. For some reason it's trying to load Perch's maps.js instead of the correct public_maps.js file. I'm not sure what would cause that.

Sorry, my bad. I'd specified in config.php:

define('PERCH_MAP_JS', PERCH_LOGINPATH . '/templates/maps/maps.js');

but that map.js was my personalisation of perch/core/assets/js/maps.js not public_maps.js

I've removed the line from config.php and it's working fine now. However, how should I personalise maps.js (for example so that the map isn't centred on London by default)? Or do I just do that in core and try to remember to re-modify it when it gets overwritten?

Thanks for your help - and sorry for wasting your time.

Drew McLellan

Drew McLellan 2638 points
Perch Support

maps.js is for the control panel editing process. public_maps.js is for rendering in your page.