GSoC Week #8: Porting facets_map_widget

If you have read my last post, you can remember I had discussed about the faceted map search. So this post is about how I tried to achieve the same. I have tried to port a completely new module i.e facets_map_widget. It works as a sub-module of Search_api_location and an extension plugin of facets module to provide a map interface that can be used to narrow down Geo-Spatial search results. 

As it is a new feature to facets functionalities, Initially I tried to submit a patch with a location array widget only. When a location field will be set as a facet, a location query type plugin will be instantiated automatically. As you know facets is tightly coupled with some particular plugin type like date query, string query etc with particular data type like date, string, int etc. but facets_map_widget is only concerned with location or lat/lon data type. So I needed to implement hook_facets_search_api_query_type_mapping_alter(). You can see some snippets below, when a location data type comes to the concern, the SearchApiLocation is called. search_api_location is the plugin id of SearchApiLocation plugin. This is an extension plugin of facets query_type  plugin type. I have extended the QueryTypePluginBase to access the backend's native query object and methodologies.

function facets_map_widget_facets_search_api_query_type_mapping_alter($backend_plugin_id, array &$query_types) {

if ($backend_plugin_id == 'search_api_solr') {

$query_types['location'] = 'search_api_location';



And for widget I have extended  ArrayWidget class with overloading getQueryType method as shown as below. 

public function getQueryType(array $query_types) {

 return $query_types['location'];



Well the plugins are getting instantiated as per our requirements. Now the concern is all about to display those location data as facets. Currently I am facing some problem for it. You can have a look on the issue itself. Soon I will come to an end result of displaying the raw location data as array. Stay tuned for next updates. Thank you.