GSoC Week #9: Plotting heatmap response on a map

Plotting markers on a map is easy using the tooling that is readily available. However, what if you want to add a large number of markers to a map when building a search interface? The problem is that things start to clutter and it’s hard to view the results. The solution is to group results together into one marker. You can do that on the client using client-side scripting, but as the number of results grows, this might not be the best option from a performance perspective.

This blog post describes how to do server-side clustering of those markers, combining them into one marker (preferably with a counter indicating the number of grouped results). It provides a solution to the “too many markers” problem with an solr heatmap facet.

Since 1 week I have been trying to achieve to include the new faceted map feature with search_api_location module. I was getting no output from the facets. Finally a solution came to the hand. I needed to use "rpt" data type instead of lat/lon type. If you wondering why I shifted to "rpt" data type, then have a look on this apache solr doc. Well I got a nice blog by Jack Reed regarding this heatmap facets.  Here is the patch which adds the said features to the module. Now I am getting an imploded array output with some rows and columns as shown in the below image. 

imploded array

  

So in the next step, we need a parser that will help to represent this output  on a map.
If you see the below code snippet, the geom value is hard coded. But it should be dynamically changed by moving or panning the map. Widget should detect the top-left and bottom-right corner of the map viewport and set the geom's value accordingly. So that search query will be triggered only for the area that will be within the current map viewport. 

$options['search_api_rpt'][$field_identifier] = [

'field' => $field_identifier,

'geom' => '["-180 -70" TO "-179 -69"]',

'gridLevel' => '4',

'maxCells'=> '35554432',

'distErrPct' => '',

'distErr' => '',

'format' => $format ]; }

We have planned to use a leaflet heatmap layer plugin to plot those grids and visualize the clustered data on the map. Currently the work is on progress. Perhaps by the next week we can make a faceted map with some minimal options included. Interesting ?? Stay tuned for the next updates. Thank you.