3

I use the codes below to make an ajax call requesting points and show it on the map:

var layer_kos = new L.GeoJSON.AJAX("<?php echo base_url('assets/GIS/layer/request_kos.php');?>",{
pointToLayer: function (feature,latlng) {
    addRowTable(feature,latlng);
    tablesaw(feature);

    buffer(feature,latlng);//this function is used to add points to my own array
    return L.marker (latlng, {
        icon: L.AwesomeMarkers.icon({
            icon:'bed',
            markerColor: 'cadetblue' ,
            prefix:'fa'
        }),
        title: feature.properties.nama,
        riseOnHover: true
    });
}, 
filter:filterkos,
onEachFeature:function(feature, layer){
        layer.bindPopup(
            "<h6><center>" + feature.properties.nama + "<center></h6>"+
            "<table> <tr> <td> <h6> HARGA  </h6> </td> <td> Rp. " +  feature.properties.harga + ",00" + 
            "</td></tr> <tr> <td> <h6> FASILITAS </h6> </td> <td> " + feature.properties.fasilitas + "</td> </tr> </table>"
            // "<left> HARGA : Rp" + feature.properties.harga + ",00<left> <br>"+ 
            // "<left> FASILITAS : " + feature.properties.fasilitas + "<left>"
            )   
}
}).addTo(map);

I need to works with the array obtained by buffer(feature, latlng), only when the ajax completed. I've tried on dataLoadComplete bellow but it doesn't seem to work.

layer_kos.on('dataLoadComplete',function(e){
        alert(buffers.length);
});

What is the callback function that I can use?

1 Answer 1

4

The following is the fallback function for data loading:

layer_kos.on('data:loaded', function() { })


More can be found in the doc

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.