customGeoSearch refine crash

Hi there,

I’m trying to apply the geoSearch example right there : https://www.algolia.com/doc/api-reference/widgets/geo-search/js/#full-example

I’d like see the markers on the map when i move it. But when i do that my browser crashed. Everything works fine with all my widgets, searchBox, refinement, pagination etc… But not the loading of my data when i move the map.

Maybe there is to much data ? If yes how can i limit them ? I configured the hitsPerPage at 25 (by the configure widget).
I didnt see any configuration of the refine function…

There is a sample of my code, if it can help

*edit : i tried with a new indices and only 50 records… It crashed anyway :frowning:

Thanks a lot !

Ok i found… I binded popup for each markers on the map, it seems little bit too much :smiley:
So if i disable this feature it works fine.

Wrong alert, sorry

Thanks for posting how you resolved this!

Yes sure,

I use leaflet and i binded popups via this function :

    var markersOnMap = [];
    function onEachFeature(marker, layer) {
        var popup = '<div class="media p-2">' + layer.marker.properties.name + '</div>';

        var lng = layer.marker.geometry.coordinates[0];
        var lat = layer.marker.geometry.coordinates[1];
        markersOnMap[lng + '_' + lat] = layer.bindPopup(popup, {
            closeButton: true,
        });
    }

My mistake was getting the properties from the layer. Pretty obvious, it’s better to get properties from the marker instead of the layer.
So no matter with Algolia, but writing the “bug” showed how to fix it :smiley:

Finally the right function is :

    var markersOnMap = [];
    function onEachFeature(marker, layer) {
        var popup = '<div class="media p-2">' + marker.properties.name + '</div>';

        var lng = marker.geometry.coordinates[0];
        var lat = marker.geometry.coordinates[1];
        markersOnMap[lng + '_' + lat] = layer.bindPopup(popup, {
            closeButton: true,
        });
    }