Reply To: Redraw map POIs with AJAX or JS method

Home Forums MapPress Support Redraw map POIs with AJAX or JS method Reply To: Redraw map POIs with AJAX or JS method

#9948
boxcarpress
Participant

    After some more investigation, this seems to work in 2.38.4:

    // find the index of the next POI item in mapp0
    var poiIndex = mapp0.getPois().length;

    // build the POI in JSON serverside along these lines
    var mypoiJSON = {
    address: "3819 Beecher St. NW",
    body: "Dischord Records",
    correctedAddress: null,
    html: "<div class="mapp-iw"><div class="mapp-title">Dischord Records</div><div>3819 Beecher St. NW Washington, DC 20007-1802</div><div style="clear: both;"></div><div class="mapp-links"><a onclick="mapp0.getPoi(poiIndex).zoomIn(); return false;" href="#">Zoom</a></div></div>",
    iconid: null,
    point: {lat:38.921939,lng:-77.075191},
    poly: null,
    title: "3819 Beecher St. NW",
    type: null,
    viewport: null
    }

    // create a POI object and insert into mapp0
    var mypoi = new mapp.Poi();
    mypoi.fromJSON( mypoiJSON );
    mapp0.addPoi( mypoi );

    So I believe I’ll be set. I can call mapp0.removePois() to clear all the existing POIs. Then I  will receive similarly formatted JSON for each POI in an array from the server, iterate over the array, and insert them individually into mapp0.