Reply To: Append the data that is shown within the InfoWindow via Ajax

Home Forums MapPress Support Append the data that is shown within the InfoWindow via Ajax Reply To: Append the data that is shown within the InfoWindow via Ajax

#14210
Chris
Keymaster

    Hi,

    I don’t really know how to do that – it’s not something the plugin is set up to do – so I can only give you some ideas / suggestions:

    First, if possible, it would be much easier to just populate #bottom when you create the POI rather than using AJAX.

    If you do need AJAX, you might try catching the ‘domready’ event that occurs when an infoWindow is opened. The MapPress map ojbect has a name. By default the maps on a page are named ‘mapp0’, ‘mapp1’, etc. You can use ‘name=”myname”‘ in the shortcode to specify a name.

    With the map object, you can get the infowindow by calling getInfoWindow:
    mapp0.getInfoWindow()

    Then you can use the google event ‘domready’ to know when the window is opened. When that event occurs, you can make the AJAX call and replace the infoWindow contents. Below is some pseudo-code to illustrate the idea:

    var iw = mapp0.getInfoWindow();
    google.maps.event.addListenerOnce(iw, "domready", function() {
      .. your AJAX code here ..
      iw.setContent(newContent);
    });
    

    There is no event before the infoWindow is opened, so the infoWindow will show without the content and then resize with the new content after the AJAX call.