Home › Forums › MapPress Support › Map centering not working in 2.73.16
- This topic has 3 replies, 1 voice, and was last updated 10 months, 3 weeks ago by
Chris.
-
AuthorPosts
-
March 9, 2022 at 12:37 pm #19419
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.
March 9, 2022 at 12:38 pm #19420Thanks for reporting this! Can you please give me the shortcode, or an example? A URL for the map would also be helpful.
March 10, 2022 at 6:42 am #19421Sure – 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/
March 10, 2022 at 6:43 am #19423How are you generating the map? Are you using the Gutenberg post editor?
If not, could you please past the shortcode (or other code) here?
March 10, 2022 at 10:32 am #19424In 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.
March 10, 2022 at 10:34 am #19425Hi,
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.
March 11, 2022 at 3:47 am #19427Thanks – 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
-
AuthorPosts
- You must be logged in to reply to this topic.