I don't know if this is helpful for anyone, but since I took the time to figure it out, I thought I'd share.

I wanted users to be able to do a faceted search and have a map of their search results show up at the bottom when those results contained geographic data. Here's what I did to get it to work (pardon my verbosity, I'm trying to make this as accessible as possible):

  1. Apply the patch to the GMap module found at #623234: Views 2.7 - breaks field output - GMap marker info window (bubble) doesn't display fields correctly (so markers show up on a map view in views 2.7)
  2. Create a view of node data
  3. Add fields to display in map markers as well as lat/lon fields
  4. Add a filter for the node types that have geographic data
  5. Change the style to GMap, using the lat/lon fields
  6. Add an argument for Node ID - this part is important
  7. For "Action to take if argument is not present", select "Provide default argument"
  8. Select "PHP Code" for "Default Argument Type"
  9. Add the following PHP
  10. $env = faceted_search_env_load(1);
    $results = $env->load_results();
    $pages = array();
    foreach( $results as $result )
        $pages[] = $result->nid;
    $nodeids = implode( ",", $pages );
    return $nodeids;
    
  11. Make sure to check "Allow multiple terms per argument."
  12. Add a block view

This block, when enabled on faceted search pages, will display only the nodes returned from the faceted search.
I realize that this could break if there were more than one faceted_search environment in play - it could be modified to include that case.

Comments

the1andonlycary’s picture

It also works nicely to configure the block to show only when the following PHP code returns true:

$env = faceted_search_env_load(1);
return $env->ready();
WorldFallz’s picture

Excellent info-- thanks for posting. You should really consider posting this in the http://drupal.org/handbook/config/contribmodules section of the handbook!

ctw816’s picture

It might also be useful to include a defined number of results to be returned. I believe the default is 10 which could of course be restrictive for both faceted search and mapping purposes.

$results = $env->load_results($limit = 100);

Not sure about unlimited though.

-chris

benjah’s picture

this. . .is amazing. . .
Thanks so much.
Works like a charm.

the1andonlycary’s picture

We just switched from faceted search to apachesolr for our search. When I get a chance, I'll write up separately what I did for apachesolr, but basically it's the same as this except using the following php code:

$response = apachesolr_static_response_cache();
$docs = $response->response->docs;

$nids = array();
foreach( $docs as $doc ) {
  $nids[] = $doc->nid;
}

$nidList = implode( ",", $nids );

return $nidList;

alarhby’s picture

thank you so much for sharing, i will try it in my wesite and i hope it can work fine.
thanks again.