Needs work
Project:
Leaflet
Version:
7.x-1.4
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
30 Sep 2012 at 04:55 UTC
Updated:
11 Feb 2018 at 21:03 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
joelrosen commentedI'm also looking at this problem.
A map view should have some way to display a default map even if no results are returned from the view. I think there's two ways you could go on this:
1) Provide a "No Results Behavior" plugin that lets you select a map to render if there are no results. The user can then be responsible for specifying "center" in hook_leaflet_map_info(). That would work fine but it seems a little silly to have to define two maps, one for a view with results and one that specifies "center" for no results.
2) Add some more configuration options to the map display plugin, something the likes of:
- Center (lat + lon)
- Zoom
- Initial viewport behavior (select from "fixed -- use center and zoom", or "auto -- use fixed center and zoom only for no results")
I'm willing to write a patch for either way, but can the maintainers provide some direction on this? #1 might be nice to have, since a no results behavior plugin might be a nice addition anyway. #2 might be more user-friendly, but then again it might be bloating up the configuration options and starting to look more like the OpenLayers module, which is probably not the direction you want to go.
Comment #2
joelrosen commentedHeh, again, I figured it would be easy and doesn't interfere with existing configuration so I went ahead and wrote a patch for #1.
The patch adds a Views area handler that renders a map, very simple. I also added some helpful comments to leaflet.api.php that instructs users how to define 'center' for maps that don't auto-focus or have no results. You might consider it a temporary solution to this issue.
Comment #3
mstrelan commentedNice work on the views handler, but the default position should not be hardcoded in to the module and users should not have to modify module code. Perhaps the views handler could allow you to set the default position? Or like the gmap module, leaflet could have a global setting for this.
Comment #4
jmev commentedDoes using the views area to display this same view in it for no results cause some kind of a looping situation, where the user may try and run the query again from the nested view and confuse ajax or views even further?
Comment #5
labboy0276 commentedHere is the same patch against 1.4
Comment #6
labboy0276 commentedThe patch in #5 is failing on the info, here is a better patch, sorry.
Comment #7
jenlamptonI think it would make more sense if the map settings asked for a center (similar to geofield_map) and then appeared all the time -- even when there were no results. There's already a Hide empty checkbox: Hide the Leaflet map if there are no results to display. If that box is checked then the map should be hidden, if not, it should display. Shouldn't that be fixed? I'm not sure I understand the approach taken here.