• Resolved plebster

    (@plebster)


    Hi,

    We’re developing a site, behind a firewall unfortunately, and events manager is working really well. However if we us the shortcodes [locations_map] or [events_map] we get a loading maps page, see the first image:

    https://ibb.co/yf9hKg4

    This also appears after an expected map when selecting the map option from the locations/ events search bar on the locations archive page:

    https://ibb.co/JnGfPLF

    I have recreated my google api as per the instructions and tried embedded and dynamic maps all with the same results.

    This is a fresh install of WP6.3 with no other plugins, I have tried this on the following themes 2023, 2022, 2021 and our own block theme. 2021 will show the shortcodes only, the rest show the “Loading Maps” page. Would love to get this working with 2023. Any help would be greatly appreciated.

    Thanks

Viewing 9 replies - 1 through 9 (of 9 total)
  • These shortcodes work fine on my website: https://mafw.org/events-map/

    Could the problem be related to your firewall?

    Thread Starter plebster

    (@plebster)

    that’s really interesting, I might explore the firewall issue, although I can’t under stand why that would be. I see you’re on 6.3.1, what theme are you using and I’ll try and recreate that here.

    Thanks again

    I’m using the GeneratePress theme.

    I see the javascript for Events Manager is trying to access the following URL (where xxxxx is the Google Maps API key):

    https://maps.google.com/maps/api/js?v=quarterly&libraries=places&callback=em_maps&key=xxxxx

    Maybe the firewall is blocking this?

    Thread Starter plebster

    (@plebster)

    I have done some more testing with this, I can get this to work on the older ‘classic’ themes but this fails every time I use newer block theme.

    I’m assuming that mawf.org is not using a block theme.

    I hope there is a work around.

    GeneratePress is a classic theme. Here’s more information on this: https://generatepress.com/full-site-editing/

    I switched to Twenty Twenty-Three and I see the same problem. Looking in the Developer Console I see the following Javascript error.

    This is a bug in the Events Manager javascript file (wp-content/plugins/events-manager/includes/js/src/parts/maps.js).

    Thread Starter plebster

    (@plebster)

    I can now see this error too, Hopefully we’ll have a fix fairly soon

    Thread Starter plebster

    (@plebster)

    The issue is about badly formed JSON data that cannot be parsed. (The data is the data that will be sent to the google API)

    The template file that generates the JSON is: templates/map-global.php

    This template is called when a shortcode is used and is defined in em-shortcode.php

    I believe that the arguments passed to the template file, and the construction of the JSON string are all working fine.
    The problem occurs when the string is rendered by the site into an HTML page.

    When I view the source of the page I see the JSON string like:
    {“0″:””,”em_ajax”:true,”query”:”GlobalMapData”,”width”:”400px”,”height”:”300px”,”id”:1016433076}

    My console shows:
    {“0″:””,”em_ajax”:true,”query”:”GlobalMapData”,”width”:”400px”,”height”:”300px”,”id”:1328304383}

    The maps.js (although I worked in events-manager.js) picks that string from the HTML, tries to parse it and fails because of the badly formed string. i.e. it has curly quotes in it.

    We managed to clean up the JSON string with a find a replace script in the javascript, and then the map loads fine.

    I’ve no idea if there’s a better way to fix this before the javascript file tries to read the data from the page.

    We tried and failed with
    1) Adding flags to json_decode in templates/map-global.php – see: https://www.php.net/manual/en/function.json-encode.php
    2) Trying to sanatize the json with PHP before it is rendered in HTML
    3) Trying to turn off wptexturize site wide – see: https://developer.ww.wp.xz.cn/reference/functions/wptexturize/#more-information

    Thread Starter plebster

    (@plebster)

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Loading Maps displayed instead of map’ is closed to new replies.