I'm not sure if it is the intended behavior, but I noticed when you have a view with a leaflet map display that doesn't contain any results the map still shows up with a grey background.

Should it instead display the Empty Result property from the view? or not display at all?

Comments

mgifford’s picture

I'm getting an empty display in 7.x-2.x-dev but not sure why. I'm not sure that's the ideal response to no active results. Better than a grey background mind you.

smussbach’s picture

I am getting an grey map with controls when displaying no results. I wold be grateful, if it would display empty result from views. Am I missing something?

Latest dev leaflet
Latest dev leaflet_markercluster

dasjo’s picture

your map definition might need to provide a default center + zoom level for such cases
here's an example: http://drupalcode.org/project/geocluster.git/blob/refs/tags/7.x-1.0-alph...

smussbach’s picture

Thank you very much dasjo for your help. It gave me a valuable insight how the module works.

Anyhow I seem to be missing something, as I can use my custom module with the defaults set but I receive a grey map anyways. Unfortunately I do not have the possibility (say budget) to figure it out and get it working, I had to just hide the map in case of no results. I might try it later on.

cojomojo’s picture

Issue summary: View changes

Did anyone ever figure the cause of this issue? I am experiencing the same thing.

back from 7’s picture

I think I figured out the issue. If you add width property to the map it solves the tile grey issue...

This is what fixed it for me:

div#leaflet-map {
width: 100%;
}

back from 7’s picture

Edit: #6 didn't fix the issue...

andlpd’s picture

The problem seems to be at map generation in javascript.

If the "features" array is empty, the map tiles are not generated. That means no CSS solution will be able to fix this.

kundu’s picture

Same problem here. Any news about it? Strangely, when I click on inspect element, on Chrome i can see the map.

adamps’s picture

Title: empty view results returns grey leaflet map » View with "Hide empty" displays grey leaflet map
Category: Feature request » Bug report
mgifford’s picture

Worth expanding the title for #1944096: Show empty views when no results. and declaring this one a duplicate?

kaido.toomingas’s picture

Add default map center and there will be no empty div. I guess it would be nice to add this option to leaflet module. This will take effect whenever you would like to add default center to map.
Quickfix for me was:

function hook_leaflet_map_prebuild_alter(&$settings) {
  $settings['map']['center'] = array(
    'lat' => 55.290,
    'lon' => 7.410, 
  );
}
mgifford’s picture

@kaido24 - can you write up a patch for that?

jlongbottom’s picture

#12 worked for me

would be nice if this was a setting in the View configuration options

rdeboer’s picture

Assigned: Unassigned » rdeboer
Status: Active » Closed (duplicate)

Might be fixed with the patch of #1944096: Show empty views when no results. that was applied today?
Rik