Closed (fixed)
Project:
Openlayers
Version:
6.x-2.x-dev
Component:
OpenLayers CCK
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
26 Dec 2010 at 10:01 UTC
Updated:
8 Jun 2011 at 03:41 UTC
Jump to comment: Most recent file
Comments
Comment #1
tmcw commentedGEOMETRYCOLLECTION()is the minimum valid WKT generated by OpenLayers, when nothing is added to the map. Currently there is no support for dictating whether users add features to the map, given that this lies above the level of Drupal and the form api, and would require a bit of brittle code with uncertain requirements. Feel free to implement a behavior that checks that features are added - it's an afternoon project once you've learned the behaviors system.Comment #2
figs commentedIn case anyone encounters the same problem, my quick fix for this was to make an unpublished node (the unpublished node will not be accessible or be read by Views) with the WKT field containing the problematic "GEOMETRYCOLLECTION()" text, and preventing this from ever being duplicated by using the unique field module (http://drupal.org/project/unique_field). This prevents form validation for "empty" WKT fields.
Comment #3
levelos commentedHey gang - tmcw, I respectfully disagree that this is a feature request. This behavior makes it impossible to require an openlayers_cck field. At the least, users should be warned that you can't actually require the field.
Further, having a map feature with the coordinates set to
GEOMETRYCOLLECTION()flat out breaks maps. It leads to an error on line 99 of openlayers.js,TypeError: Cannot call method 'transform' of undefinedand a completely empty map page.I'm not sure this is the best approach, but the attached patch solves the required field issue, at least for my use case. What wasn't obvious to me, is where the code that's inserting the empty
GEOMETRYCOLLECTION()is located. Perhaps that would be a better area to find a solution.Comment #4
tmcw commentedloubabe: Thanks for the patch. Can you reformat it as a CVS diff?
Comment #5
levelos commentedtmcw, sorry, but I don't have a CVS checkout and don't have time now to grab it, reapply the patch, generate a new one, etc. In my experience, the git patch should apply cleanly to a CVS checkout. And I also heard something about a git migration happening in 2 days ;)
Comment #7
pgr1973 commentedInstead of patching the 'openlayers_cck.module' to throw an error to user *after* submitting, one could also put some Javascript on the Page with the Input form, that checks before submitting the empty Field content. I did that on http://gmna.de, the js, that is inserted on the page with the input-form is this:
I putted this in an extra js-file in the theme directory and modified the 'template.php' so, that it inserts this js on the input-form-page for my content-type with the openlayers-maps. Trying to save an 'empty' Geomnesia-Point, you'll get an js-alert, telling you to set a point first ('edit-field-gp-openlayers-wkt' has to be the ID of the openlayers-wkt field).
That way, the user can't even submit the form, with no data (point) added. Because I don't want anonymous users to see any drupal-error-messages, the way with the patched 'openlayers_cck.module' was not appropriate.
Regards Paddy
Comment #8
steinmb commented@pgr1973 thanx for a great usability tip, we might consider putting that one into a doc page somewhere?
Playing with the new recommanded patch format from Git, and rerolling the patch against the latest dev. code a73e982bb1f040192bfa138e153d954029412669
Comment #9
steinmb commentedGit fun aside, is this patch still needed/valid? There is no way I'm able to create a node that contain a required OL field, if it's empty. Other problems related GEOMETRYCOLLECTION() do I also think are fixed:
What is stopping us from rolling out alpha 11?
Comment #10
zzolo commentedThanks for the patch. I have not actually tested it, but the logic looks sound. It would be great if someone could confirm.
http://drupalcode.org/project/openlayers.git/commit/837c92c
As far as an alpha 11. Was hoping for an actual Beta, but not sure how stable things are. Also, most of the dev's have been working on the D7 version lately. Hopefully soon.
Comment #11
zzolo commentedOh also, not that I think this is a high priority, but a better way to handle this is define GEMOTRYCOLLECTION() as the empty field. This would allow CCK to handle things better.
Comment #13
diond commentedThanks @pgr1973 for your JS suggestions. You saved my butt until I can get a better solution in place.