4

I have a proximity search on views using Gmap and Location API, I've imported all the UK post codes into my zipcodes table in my database, and it all works great. The only thing I would like to change is the no results behaviour.

If a user enters a postcode, and there isn't a venue nearby, the map disappears, and I can show a no results message in its place.

What I would like to happen, is for the map to stay where it is, but showing all venues, with a message underneath saying "Please widen your search area".

Anyone know if this is possible? I've been searching for a similar post on Google, but can't find anything, as I'm not having any errors, just wondering if its possible, and can't seem to figure it out myself!

5

You can embed a different View under "No results behaviour"

e.g a View that lists all venues.

Views empty text - embed another View

  • Good idea, I can just add a block to the view and display that as a no results. Thanks. – Collins Nov 24 '13 at 21:50
1

BTW: If you want to show just empty map (without markers), you may add a 'Global: TextArea' to 'No Result Behaviour' and put the text area inside:

<script src="http://maps.googleapis.com/maps/api/js?&amp;sensor=false"></script>
<script >
  window.onload = function () {var mapOptions = {
                center: new google.maps.LatLng(10, 10),
                zoom: 2,
                mapTypeId: google.maps.MapTypeId.ROADMAP
  };
  var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
}
</script>
<div id="map_canvas" style="width:100%; height:485px;"></div>
  • Thats no good. I finished that website ages ago, but in the original question I asked for a no results behaviour that showed all icons. The questions I marked as the answer was perfect as I created an attachment for the existing view and showed that instead. I dont see how your solution would be useful to anyone? – Collins Mar 20 '14 at 18:06
  • 1
    You are right. I was looking for a solution without the markers on the map. I posted this message here for my memory. Sorry for disturbing you! – Peter Lozovitskiy Mar 20 '14 at 18:49
0

To work around, add a dummy item inside the result array

/**
* Implements hook_views_pre_render.
* to render the map even if there is no results
**/
function ei_users_customize_views_pre_render(&$view){
  if( $view->name == 'map_view'  ){
    if( count($view->result) == 0 ){
      $view->result = array('' => '');
    }
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.