tl;dr

Geofield should not save field data when all values are NULL. This will ensure a field will only render when there is data present. I am fairly sure "empty field" can be defined as "all values are NULL". Looking into the code myself and will pop back soon.

I have discovered that when a record is present in the field_data table for a field set to the "Geocode from another field" widget, even if all the "field_xxx" data columns have the value NULL, a map is still rendered when ideally no map should be rendered at all. Deleting said record solves this. Therefore, Geofield should treat all NULL values as an empty field.

My setup

Modules used:

AddressField 7.x-1.x-dev
Geocoder 7.x-1.0+8-dev
OpenLayers 7.x-2.0-beta1+46-dev

Fields:

- addressfield (AddressText)
- geofield wth "Geocode from another field" widget (AddressMap), using Google Geocoder, rejecting APPROXIMATE and GEOMETRIC_CENTER (this field does not compute any point data when only the Country value is passed from AddressText, which always happens with addressfield)
- geofield with "Openlayers Map" widget (CustomMap)

Display:

- AddressText as default (textual output)
- AddressMap as OpenLayers, set to use Full Geometry and an Openlayers View Layer (Google Map) with "Hide empty map for Views" set
- CustomMap as OpenLayers, set to use Full Geometry and an Openlayers View Layer (Google Map) with "Hide empty map for Views" set

Step 1:
Enter a full address into AddressText, and mark one/some point(s) on CustomMap.
Results:
Both AddressMap and CustomMap render maps, displaying their point data as markers.

Step 2:
Remove all text from all AddressText textfields, and delete all markers on CustomMap.
Results:
AddressMap renders an empty map according to the defaults. With OpenLayers, this can mean the initial center-point and extent set in the Center & Bounds options tab at admin/structure/openlayers/maps/map_name/edit.
CustomMap does not render a map, but does render a label if supplied.

CommentFileSizeAuthor
#4 medienhafen.zip12.51 KBDevr

Comments

henryblyth’s picture

Status: Active » Closed (duplicate)

My bad - this is an issue with the Geocoder widget. I have logged an issue there with a patch: #1592096: "Geocode from another field" widget does not delete field data when no results returned.

Devr’s picture

Hm, the patch above didn't work for me.

I have a geofield, which geocodes from another field, a filefield with GPX data in my case. When I delete the GPX-file from the node, the field_data_field entry still remains in the table and will not be erased. The result is: the data from the deleted GPX is still rendered in the geofield...

henryblyth’s picture

Hi @Devr,

Could you attach the GPX file so I may test with it please? I guess you have the latest stable releases of Geofield and Geocoder.

Thanks,
Henry

Devr’s picture

StatusFileSize
new12.51 KB

Hi Henry,

thanks for your help.
I'm using geofield 7.x-2.x-dev (2012-Jun-23) and geocoder 7.x-1.1 (which includes the patch already).
I have included a GPX, but I had the same bug also with other files. The file was zipped, because of the upload restriction to extensions other than gpx.

Devr