Creating custom facet block for Search Api Location module

Facets work fine and by design they narrow down the search results with each facet option you click. But what happens when you want to make them work differently. Some of that can be achived with changing opearator to OR in facet settings. But in this case with search api location module this doesn't work, not sure is it a bug or by design but I solved that with creating my own facet block.

There is some info in one of readme files in facet module how to make custom urls that work with facets. Facet use get parametars so all you need to do is make url with some get variables. So what I did is made a custom block in a module and added this code to its content.

 case 'custom_facet_distance':
     $block['subject'] = t('Distance');
     $distances    = ['5', '10', '15', '20', '50'];               

     for ($i=0; $i < count( $distances ); $i++ ){
      $options['query'] = drupal_get_query_parameters();
      $options['query']['f'][0] = 'field_ol_locator_geofield%3Alatlon:[* TO '.$distances[$i] .']';
      $items['items'][] = l(t($distances[$i]. ' miles'), current_path(), $options) ;
     }

        $block['content'] =   theme('item_list', $items);
 
     break;

So what I did is created array, looped through it and added data to options array which is used in 'l' function to pass it to 'url' function for creating links. We then wrapped it all up to make a list of items with theme('item_list', $items); function and have nice working facet block.

p.s.
In helping you build url I used url encoder/decoder from here
http://meyerweb.com/eric/tools/dencoder/