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'm using geofield to input location info by placing a marker on a OpenLayers map. In earlier releases geofield would allow only one marker to be placed ('Numbers of Values' set to 1), setting another marker would remove the first marker and add the new one.
With the 7.x-1.1 release and the 7.x-1-dev versions, it no longer restricts the number of markers placed on the map.
When I reverted to the 7.x-1.0 release the field worked as expected.
Comment | File | Size | Author |
---|---|---|---|
#26 | 1647416-26-geofield-widget-settings.patch | 683 bytes | mr.baileys |
#17 | geofield-respect_number_values_setting-1647416-17.patch | 584 bytes | peterm95018 |
#6 | innofund.perke_.local 2012-8-6 12:40:10.png | 267.83 KB | perke |
#5 | screenshot.png | 86.96 KB | perke |
Comments
Comment #1
ArchangelGuidz CreditAttribution: ArchangelGuidz commentedWould like to report this is an issue too. Seems this was fixed for drawing features with OpenLayers, though not in the Geofield OL Map. I'm more of a designer than a JS-PHP guy. Can anyone help out on a fix?
Comment #2
phayes CreditAttribution: phayes commentedI think we have this one fixed in the 2.x branch if you would like to check it out.
Comment #3
perkeJust upgraded from 7.x-1.1 to 7.x-2.x-dev and problem described above still appears.
Comment #4
phayes CreditAttribution: phayes commented@perke,
What field settings are you using? Specifically, do you have "use collections" turned on or off?
Comment #5
perkehi,
storage options is set as "Store as a single collection"
here is screenshot of all settings for the geofield
thanks
Comment #6
perkeedit: here is better screenshot, overlay messed it up
Comment #7
Wouter Van den Bosch CreditAttribution: Wouter Van den Bosch commentedI think this issue is related to this particular snippet of code in openlayers_behavior_geofield.js:
At that particular moment the Drupal.settings object does not exist, and hence the limitFeatures rule is ignored.
Commenting out the condition, results in one singular point being replaced on every click.
Comment #8
perkeI've tried commenting that out and it didn't worked. @Wouter, have you also upgraded from 7.x-1.1 or is it a clean install?
Comment #9
Wouter Van den Bosch CreditAttribution: Wouter Van den Bosch commented@Perke, I had an install with 7.x-1.0 at first, which I later upgraded to 7.x-1.1. It's only after a while that i noticed that I was now selecting multiple points and that the number of values setting was being ignored.
So after some digging I briefly altered:
into:
Just to check whether that could be the problem of course. As soon as I comment out those two lines, I am back to the correct 1 point behaviour.
Do make sure to clear your cache though. I've had some issues with the old JS file hanging around.
Comment #10
perkeah ok, i was commenting full if statement... thanks, it worked... guess i'll use this temp fix to get this thing going on
Comment #11
phayes CreditAttribution: phayes commentedThere should be no need to patch anything. If you are storing everything as a single collection, this is expected behavior. You should be using "Store each feature separately"
Comment #12
nubeli CreditAttribution: nubeli commentedNote that in the code "single" refers to "Store each feature separately" and "collection" to "Store as a single collection." That was a bit confusing.
I've got 7.x-1.1 on a site, it was not respecting 1 value for the field and it was set to Store each feature separately. I commented out the condition and it will now allow only one feature on the map. But it still ignores the value. For example, if I set it to 5 it will still only allow one feature on the map.
Comment #13
ressa CreditAttribution: ressa commentedThanks @Wouter Van den Bosch (#9) that works. The file in question is located here:
sites/all/modules/geofield/includes/behaviors/js/openlayers_behavior_geofield.js
Comment #14
gravisrs CreditAttribution: gravisrs commentedAnother fix better than in #9 - earlier debug approach in file geofield.widgets.inc :
add a line like this:
please review and put fix to repo
Comment #15
Sinovchi CreditAttribution: Sinovchi commentedThanks gravisrs,
This is really better fix for 7.x-1.1.
Comment #16
Brandonian CreditAttribution: Brandonian commented@gravisrs, can you make a patch for inclusion?
Comment #17
peterm95018 CreditAttribution: peterm95018 commentedHad the same issue, so I created (my first) patch based on gravisrs code in #14.
Peter
Comment #18
peterm95018 CreditAttribution: peterm95018 commentedComment #19
balagan CreditAttribution: balagan commentedI came here from http://drupal.org/node/1630836#comment-6869276, which I think is a duplicate of this issue. I haven't reviewed this patch, but I have also found that the $setting variable is not available from the geofield_widget_openlayers_afterbuild function, and using dpm I saw that the value needed can be accessed in the $form_state variable. I will get back to this patch tomorrow
Comment #20
balagan CreditAttribution: balagan commentedThe patch is working for me, but git produces a warning about whitespace error.
Comment #21
balagan CreditAttribution: balagan commentedComment #22
balagan CreditAttribution: balagan commentedComment #23
gerontas CreditAttribution: gerontas commentedI have tested the code in #14
It successfully limits the number of points that can be placed (1 in my case) but if the map is saved and then edited again, another point can be added and the original point cannot be deleted.
Comment #24
gerontas CreditAttribution: gerontas commentedSorry I spoke too soon - it looks as if it does work.
I discovered that I had 'Draw features' activated in the map behaviours settings. When I de-activated that the map respects the field setting.
Comment #25
shushu CreditAttribution: shushu commentedPatch seems to work for me as well. Can this be pushed into the 1.x branch and closed ?
Comment #26
mr.baileysI ran into the same issue.
The bug was introduced in #1298842-4: Map is not rendered after validation error., where part of the behavior setup code was moved from
geofield_field_widget_form
togeofield_widget_openlayers_afterbuild
. The snippet that was moved referenced a variable ($settings
) that was not moved to the new function, and thus out of scope, always triggering the default data storage fallback value 'collection'.The patch in #17 works but seems fragile (for example, having the
'und'
hardcoded.) Attached is a patch that usesfield_widget_instance
instead.Comment #27
balagan CreditAttribution: balagan commentedWell, it seems to be a lot nicer solution leaving out the 'und'.
Comment #28
organicwire CreditAttribution: organicwire commentedPatch #26 works for me.
Comment #29
Jarode CreditAttribution: Jarode commentedYes that works !
Comment #30
jcisio CreditAttribution: jcisio commentedI think it is important for the next release.
Comment #31
Brandonian CreditAttribution: Brandonian commentedPatch at #26 applied. Thanks, @mr.baileys!
http://drupalcode.org/project/geofield.git/commit/39acd9e