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.
When there is no data to render in a Data Overlay we get these messages:
Which can be made silent with a change like that:
diff --git a/modules/openlayers_views/views/openlayers_views_style_data.inc b/modules/openlayers_views/views/openlayers_views_style_data.inc
index 04850d5..ec0495b 100644
--- a/modules/openlayers_views/views/openlayers_views_style_data.inc
+++ b/modules/openlayers_views/views/openlayers_views_style_data.inc
@@ -33,9 +33,11 @@ class openlayers_views_style_data extends views_plugin_style {
// If we are in preview mode, dump out some useful information about this data layer
$output = "You can use the following parameters in your styles as dynamic values";
$output .= "\n------------\n";
- $keys = array_keys($data);
- foreach ($data[$keys[0]]['attributes'] as $key => $value) {
- $output .= '${'.$key."}\n";
+ if (!empty($data)) {
+ $keys = array_keys($data);
+ foreach ($data[$keys[0]]['attributes'] as $key => $value) {
+ $output .= '${'.$key."}\n";
+ }
}
$output .= "\n------------\n";
Comments
Comment #1
Countzero CreditAttribution: Countzero commentedThanks for the tip. Seems good to me and make the error disappear.
Related to the same logic, an Openlayers Map display fails with the following error :
Call to a member function render() on a non-object
... when no data is pulled. This one seems tougher to solve.
Comment #2
kurtzhong CreditAttribution: kurtzhong commentedNice fix, thanks.
Comment #3
zzolo CreditAttribution: zzolo commentedThansk @ao2! Committed. @Countzero, if you can provide an error message or more information, please open a new issue for that error.