Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I use Openlayers with views. I have checked: "Do Not Display Empty Map" and the map is not shown if their is no value, but the view block itself (e.g. title) is still shown. If I change in the same view for example to unformatted list, then the block disappears. So I guess it might be bug in Openlayers. So the view block does not disappear, although I have a filter for latitude return true.
Comment | File | Size | Author |
---|---|---|---|
#29 | openlayers_views-block-visibility-768294-29.patch | 3.06 KB | fluffy |
#18 | patch-768294-18.patch | 2.41 KB | davidhk |
#16 | patch-768294-16.patch | 2.06 KB | davidhk |
#10 | patch-768294-10.patch | 2.12 KB | davidhk |
Comments
Comment #1
zzolo CreditAttribution: zzolo commentedHmmmm, I looked at this for a while but could not figure out how to get this to work. I'll have to look at the 2.x version to see if it behaves similarly.
Just to reiterate the issue:
* If no features are found and the "Do not show empty map" is checked, meaning that no map should show, the View is still showing the title (on a block). Testing a normal View block, nothing shows if there is no data.
Comment #2
ckreutz CreditAttribution: ckreutz commentedThanks for looking at it. I could not make sense of it and did not check with the 2.x version.
Comment #3
zzolo CreditAttribution: zzolo commentedThe 2.x version always shows the map, since it does not actually account for the "data" on the map.
I am still not sure how to fix this specific problem. We are rendering nothing, but the view still assumes it has output and therefore is showing the title. Maybe there is some sort of method or property for the view or display that needs to be set (though I have looked at the default code for Views and haven't noticed anything).
Comment #4
tmcw CreditAttribution: tmcw commentedIn 1.x, shouldn't the map style plugin return nothing if there are no features and the user chooses not to show a map? Currently it does some stuff and returns some stuff:
Comment #5
zzolo CreditAttribution: zzolo commentedWhat that is saying is: if we want an empty map if there is no data and there is no data, then we return nothing, but we want to run the process through Views theming in case someone wants to do something special. I remember looking at other plugins and seeing something similar, but I could be wrong.
Comment #6
gmclelland CreditAttribution: gmclelland commentedI just discovered this myself using the 2.x branch. In addition to rendering an empty map, it also fails to render the "Empty Text" for the view.
Comment #7
zzolo CreditAttribution: zzolo commentedWell, again, the 2.x version does not account for data so there is no real way to not display a map. Not sure if there is a real way around this. This means there is no way to display the empty text.
Comment #8
tmcw CreditAttribution: tmcw commentedTurning this into a feature request for 2.x. 1.x is no longer developed. However, this is trickier to actually do in 2.x, because a map can show more than one views layer, so is it appropriate to show empty text when one is empty? all? a specific one?
Comment #9
ckreutz CreditAttribution: ckreutz commentedFor me the title is the problem, but I guess with many layers possible in new version the empty text option would be best.
Comment #10
davidhk CreditAttribution: davidhk commentedHere's a patch that hides an empty map, and shows the view's 'empty text' instead. I think it may have fixed the 'Block still visible without values' problem too, but I haven't tested that.
Three parts to the patch:
1. Add a 'Hide empty map' checkbox at the end of the 'General information' tab for a preset.
2. In openlayers_render_map(), add up the number of features across all layers. If there aren't any features, assume map is empty and return empty string instead of map markup.
3. In openlayers-views-map.tpl.php, don't return anything if there isn't any map markup. (Previously it returned the div, even if there was nothing inside the div. This stopped Views from displaying the 'empty text', and I guess is what caused the block problem too - if there's any text at all present, even an empty div, Views considers the view isn't empty.)
Comment #11
gmclelland CreditAttribution: gmclelland commented@gwulo - Patch failed against 6.x-2.0-alpha8. Can you resubmit the patch against the latest version?
I downloaded the patch to the openlayers directory then ran the command patch -p0 < patch-768294-10.patch
Comment #12
zzolo CreditAttribution: zzolo commentedJust to let you know, in case you are not aware, all patches should be created and tested against HEAD or the branch HEAD. In this case DRUPAL-6--2. This means checking the module out from CVS. See CVS instructions: http://drupal.org/project/openlayers/cvs-instructions
Comment #13
davidhk CreditAttribution: davidhk commented@gmclelland I'm not using CVS, so to make the patch I downloaded then edited the '6.x-2.x-dev' version from the module homepage. If you try the patch against the dev version (I think that's the same as HEAD that @zzolo mentions), hopefully it will work.
Comment #14
zzolo CreditAttribution: zzolo commentedTechnically, the dev version is made only once a day so it is not the same as HEAD, but close. Overall this will not cause a problem. But more importantly, it allows you to make patches via CVS with cvs diff -up. Nonethless, we welcome your patches, even if they are not perfect. :)
Comment #15
gmclelland CreditAttribution: gmclelland commentedThanks for the responses @gwulo and @zzolo. Learned something new about patching modules.
@gwulo - I downloaded the 6.x-2.x-dev, but unfortunately the patch gave the same output as #11 when I tried to apply it.
I did see the new option and tried to test it anyway, but it didn't work.
Can anybody else test this patch? Seems like an important feature to have.
Comment #16
davidhk CreditAttribution: davidhk commented@gmclelland , I'm still learning how to make patches too, so we're a fine pair!!
Here's the patch file again. I converted it to unix format, which hopefully will stop the messages about trailing CR's. And I've deleted a blank line from the end of the file in case that's the cause of the complaint about line 60.
After applying the patch, do you see these extra lines added to the openlayers.module ?
Finally when you say "but it didn't work", do you mean that when the data view returns zero results:
1 A map on a page display is still displayed
2 No Empty Text is displayed
3 The Views Block is still visible
4 something else?
Comment #17
gmclelland CreditAttribution: gmclelland commentedHere is my output:
openlayers$ patch -p0 < patch-768294-16.patch
patching file modules/openlayers_ui/includes/openlayers_ui.presets.inc
patching file modules/openlayers_views/views/openlayers-views-map.tpl.php
patching file openlayers.module
patch unexpectedly ends in middle of line
patch: **** malformed patch at line 59:
After applying the patch, do you see these extra lines added to the openlayers.module? No
Finally when you say "but it didn't work", do you mean that when the data view returns zero results:
1 A map on a page display is still displayed
This is probably because the patch didn't fully apply the changes in openlayers.module file
Comment #18
davidhk CreditAttribution: davidhk commentedI've used a different piece of software to generate the attached patch. Fingers crossed this one applies ok.
Comment #19
gmclelland CreditAttribution: gmclelland commented@gwulo - Patch now applies cleanly. -Good job
I tested the all the functionally with my views and it indeed works great. Third time's a charm. :)
I'm not sure if we should change the issue status to "reviewed and tested by the community"?
Comment #20
davidhk CreditAttribution: davidhk commentedThat's good news - thanks for your patience.
I'm not sure about changing the status either. The handbook says that status means: "The patch has received a thorough review and test by one or more experienced developers, and they have deemed it as ready to be committed to the project. "
What do the module maintainers recommend?
Comment #21
tmcw CreditAttribution: tmcw commentedThanks gwulo & gmmcelland: Committed: http://drupal.org/cvs?commit=387332
after a quick coder adjustment, shortening the helptext, and making the counting logic safer.
Comment #23
ano1 CreditAttribution: ano1 commentedHi,
Unless I am missing something I am still experiencing the glitch that 1st started this thread. When there are no points to display on my OpenLayers block view I do not want the block to display at all.
Here are the steps I followed. I was originally using the 6.x-2.0-alpha10 version of OpenLayers but changed to the dev version to test and make sure the bug has yet to be fixed. I have selected the "Do Not Display Empty Map" option in my OpenLayers preset and left the view empty text field as empty. This correctly hides the map. However, the view itself still does display. The default behavior for views is to not display the view if no results are returned.
As a test I added empty text, the empty text does display, so until I have a solution I have empty text for my block. Any suggestions would be greatly appreciated. I apologize in advance if I have applied the incorrect status to this issue.
Comment #24
ano1 CreditAttribution: ano1 commentedI have updated to the most recent dev version of the module and am still having the same issue. Is anyone else still having this problem?
Comment #25
TomMynd CreditAttribution: TomMynd commentedHi,
I have the same error. The block of the map is rendered even if there is no map to show. When I add "empty text" to the view (the map is currently one layer only) the empty text is displayed.
Currently I have no title and no empty text on the live site with this setup, so there is only a small space for the "empty block".
Can I give any more informations regarding this bug?
Best regards, Tom
Comment #26
zzolo CreditAttribution: zzolo commentedWe currently return an empty string if these conditions are true. There must be a way to designate an empty set in Views, but I do not know what that is at the moment.
Comment #27
elyobo CreditAttribution: elyobo commentedPossibly this is because the views openlayers_map style plugin is defined with "even empty" set to true. I assume that using "even empty" is necessary for some reason, because if I switch it off then I get no views turning up at all, but perhaps there is a better workaround here?
Comment #28
Helge CreditAttribution: Helge commentedIf i left my address field empty, the map in my block shows alway the "gun and rod club rd" somewhere in dalaware.
But it schould better show no map or no block.
I have no idea why.
Comment #29
fluffy CreditAttribution: fluffy commentedThis issue is by design, the view always gets rendered by the plugin definition (the "even empty" parameter is set to TRUE). Here is a patch that actually checks for features on the map and then decides if it needs rendering.
Comment #30
PolExcellent thanks ! I'll review it tonight, if it works, it gets in :)
Comment #31
PolHello @fluffy,
I created a view with 2 displays.
1 display is a block who display an OpenLayer Map.
1 display is an OpenLayers Data Overlay.
The map displayed in the block is configured to display the Layer provided by the OpenLayers Data Overlay.
When I place the block somewhere, it's lways displayed even if there is no feature on the layer, so I guess but I might be wrong, that the patch is not working as it should ?
Thanks !
Comment #32
fluffy CreditAttribution: fluffy commentedHide empty map should be also ticked in the map settings.
Comment #33
Polthanks !
Tested and committed !
Comment #35
GuillaumeDuveauThanks Fluffy !
Comment #36
basvredelingThe patch committed from #29 is not correct. It fills the view result with a boolean or a string. But the view result should always be an array. See: #2457303: Wrong type passed to $view->results on empty view