Google Maps API Key issue when displaying maps via php

Home Forums MapPress Support Google Maps API Key issue when displaying maps via php

Tagged: , ,

This topic contains 4 replies, has 2 voices, and was last updated by  Chris 1 year, 1 month ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #16946

    egm1971
    Participant

    On my website I am displaying a custom map with lots of POIs via php, as described at http://wphostreviews.com/mappress-documentation#toc-displaying-maps-using-php – it worked great, until the new version of Mappress Pro asked for an API Key.
    I followed the instructions on http://wphostreviews.com/mappress-faq to get an API Key and enable the APIs, but Mappress Pro 2.44 won´t store the key longer than one map request. I paste the key to Mappress Settings, save settings, then loading the map page in frontend – works, without any console messages. Reloading the map page – error “Google Maps API key is required” in frontend. Reloading settings page in backend: API key is gone, error “Google Maps API key is required” in backend, too.
    Are there new parameters or functions to call when displaying maps via php? Or is it a bug?
    Please help…I´m stuck :-/

    #16947

    Chris
    Keymaster

    Hi,

    Try clearing your browser’s cache, it sounds like the javascript may be cached. You can also press F12 in your browser to see if there are any javascript messages.

    If that doesn’t help, please send a URL so I can see the problem.

    #16948

    egm1971
    Participant

    That was my first thought, too. But clearing the cache did not solve the issue – the first map call works great, on second call the API key is cleared and the error message pops up.
    http://pano.egm.at/panoramen/karte/

    #16985

    egm1971
    Participant

    I found out what caused the problem: in my script I used the class Mappress_Options for temporary overwriting the settings from the options page – but Mappress_Options->save() also deletes the API key, if not set in the options array! Commented out these two lines – and the API key stays in the database:

    $myOptions = new Mappress_Options(array(“initialOpenInfo” => false, “tooltips” => false, “autoCenter” => true));
    $myOptions->save();

    For my project – solved. Nonetheless an unexpected behaviour.

    #16986

    Chris
    Keymaster

    Hi,

    I’m glad you solved that, from the description I never would’ve guessed you were reading & saving the options in custom code.

    Normally I would suggest making settings changes in the map object’s constructor or display() method, as shown in the documentation examples. But if you need to use the internal ‘options’ object, try calling the get() method first, to get the existing settings before calling the save() method to save them.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.