Map centering not working in 2.73.16

Home Forums MapPress Support Map centering not working in 2.73.16

Tagged: ,

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #19419
    lesteph
    Participant

    I’m using MapPress to render a map using PHP, and centering the map over the UK using the Zoom and Center attributes.

    This was working OK using version 2.73.12 but the values specified for centering the map no longer seem to be applied in 2.73.15 and 2.73.16. Rolling my plugin version back to 2.73.12 has resolved the issue for me.

     

    #19420
    Chris
    Keymaster

    Thanks for reporting this!   Can you please give me the shortcode, or an example?  A URL for the map would also be helpful.

     

    #19421
    lesteph
    Participant

    Sure – here’s the production URL (rolled back to 2.73.12 so the map works OK):

    https://platinumjubilee.gov.uk/events/

    And on a test server (running 2.73.16), where map should be centred on UK lat/lng but isn’t:

    https://platinumjubilee-staging.pentri.com/events/

     

    #19423
    Chris
    Keymaster

    How are you generating the map?  Are you using the Gutenberg post editor?

    If not, could you please past the shortcode (or other code) here?

    #19424
    lesteph
    Participant

    In a custom page template:

    $mymap = new Mappress_Map([
    "width" => "100%",
    "height" => "700",
    "center" => ["lat" => 54.5,"lng" => -4.5],
    "zoom" => 6,
    "poiList" => false,
    ]);
    

    various loops to add POIs to an array ($loc_array is a geocoded array of lat/lng per POI):

    $mypoi_tmp = new Mappress_Poi(array(
    "title" => esc_attr(get_the_title()),
    "body" => "<p class='meta'>".esc_attr(wp_trim_words(get_the_excerpt(),30))."</p><p>More details</p>",
    "point" => $loc_array,
    ));
    
    ...
    
    $mypois[] = $mypoi_tmp;
    

    then rendered using:

    $mymap->pois = $mypois;
    echo $mymap->display(array("directions"=>"none"));
    

    I wondered if there might be a problem with a POI (as I have hundreds) causing some kind of hidden JS error but even rendering the map with no POIs, setting center/zoom is still ignored.

    #19425
    Chris
    Keymaster

    Hi,

    What happens if you write the center like this?

    "center" => "54.5,-4.5"
    

    This was changed at some point – the plugin will process the center this way, rather than as a lat/lng array.

    Also, please use version 2.73.17 or higher – there was a bug in 2.73.16 where some lat,lng entries weren’t handled properly.

    #19427
    lesteph
    Participant

    Thanks – changing the format of the center value didn’t seem to fix it in 2.73.16 but upgrading to 2.73.17 does seem to have solved it.

    Could you update the documentation here at some point to help others, as this still shows center values being set using a lat/lng array?

    https://mappresspro.com/mappress-documentation/#toc-displaying-maps-using-php

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.