Reply To: How to read and save map view (lat/lng/zoom)

Home Forums MapPress Support How to read and save map view (lat/lng/zoom) Reply To: How to read and save map view (lat/lng/zoom)

#15683
BradSiegfried
Participant

Hi Chris,

I was able to learn enough to get and save the map information to user meta successfully. Thank you!

My last hurdle is getting the actual map to redisplay via AJAX. When I initially create and display the map in my shortcode, I do something along the lines of
$result = $mymap->display();
return($result);

This works fine as anticipated on the initial display. However, when the user subsequently changes a map setting and initiates the AJAX request I am having trouble returning the new $result. My AJAX callback function calls my shortcode function directly and appears to receive the map display returned as above. The AJAX callback function then returns the map display along with some other data via JSON to my jQuery success function like this:

$mydata = json_encode($mydata);
header(“Content-type: application/json”);
wp_die($mydata);

I then try to replace the old map with the new map like this:

success: function(data) {
jQuery(“#mymap”).html(data.mymap);

This is where I see the problem. The resulting map is blank. mapp0_layout is there along with associated child divs, but the mapp0 map canvas is empty.

Can you suggest where I may be going wrong?

Brad