GSoC Week #10: Map facets widget

If you can remember in the last post I had discussed about representing the imploded heat map array on a map. I ended up with a solution to use SolrHeatMapLayer library extensively with my module. I had to  hack the library up to some extent as  it was explicitly coupled to solr server. And my module depends on Solr via search api and Search api location plugin.  Not only representing those data on a Map is enough for a great geo spatial search experience but it should search by panning or zooming the map. It means "geom" value should dynamically updated by Javascript. 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. Some code snippet given below for to have an idea of geom value. 

$new_geom_value = NULL;

+ if (!empty($this->facet->getActiveItems())) {

+ $new_geom_value = reset($this->facet->getActiveItems());

+ $new_geom_value = str_replace('(geom:', '', $new_geom_value);

+ $new_geom_value = str_replace(')', '', $new_geom_value);

+ }

+

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

+ 'field' => $field_identifier,

+ 'geom' => $new_geom_value !== NULL ? $new_geom_value: '["-180 -90" TO "180 90"]',

+ 'gridLevel' => '2',

+ 'maxCells'=> '35554432',

+ 'distErrPct' => '',

+ 'distErr' => '',

+ 'format' => $format,

+ ];

To make it  possible, means to pass a variable from js to php class in Drupal way was really hard for me to understand. After a lot of discussion with Borisoon in IRC #drupal-search-api helped me lot to achieve the same functionality. I had to use facets URL processor which helps passing a variable from js to php via URl. In general you can say it via a $_SERVER(REQUEST_URI). For more details you can have look on this issue. Well here is the screenshot of how the facets_map_widget looks like.

dibyajyoti

90% of the module has been completed yet. Now I just need to set a filter query like fq=field:[geom_value] with the same geom value to filter the results out as well as center the map at the geom co-ordinates. I hope by the end of last week, the module will be ready to use. Stay tuned for next updates. Thank you.