There is lots of code in the Location CCK module which is left over from the way CCK worked in D5 and which will not work in D6. In addition, the current code includes no way to display a GMap, it will only display an address.

I've reworked the module to clean up most of the D5->D6 transition stuff and added two additional formatters so you have three formatters to choose from if GMap is installed: 1) Show the address only, 2) Show the address with a map, 3) Show the map only.

I removed lots of deprecated code, like the 'arguments' and 'filters' ops, hook_field_formatter(), etc. There are probably still some bugs in here, but it is working pretty well for me at this point, even for multiple values. I'll keep digging into it to see if I find other fixes, but it is definitely working better than the existing code for me.

Because there are a lot of changes, I've also attached a zip file with a complete, updated module.

Comments

karens’s picture

Oh, yeah, I also added a way to set some GMap settings in the field, so you can do things like set the marker type, zoom level, and the size of the map.

karens’s picture

Bumping this so it doesn't get lost. There are lots of bugs in Location CCK and I think some are fixed by this code, but people will keep opening new issues unless some of this gets reviewed and committed.

yesct’s picture

Thanks KarenS!

Can a couple people try out this patch? If anyone wants to help with getting this committed/tested, but has not ever applied a patch before, try http://drupal.org/patch/apply and please feel free to post here or ask in irc http://drupal.org/irc

After applying the patch, post back here and say how it went, does your site still work? What did you try?
http://drupal.org/patch/review is a link about how to do a review for core, and here things are not as strict, but it is still a nice guide to give an idea of doing a review for someone who has never done it before. Dont feel like you need to review everything, just do what you can and report back.

deva1983’s picture

Thanks KarenS!

I have installed the patched module on the site I'm working on. The configuration options on the Location field and the new display options are really neat. I haven't tested the multiple location settings, as my nodes only have one associated each.

I've had however some trouble with setting the initial zoom through the Gmap Macro option for the field, as every map produced from the field starts with a zoom level of 0. Width, Height and Control type seem to work properly.

The javascript that creates the map on the page source starts like that:
jQuery.extend(true, Drupal, { settings: { "gmap": { "auto1map": { "width": "400px", "height": "300px", "zoom": 0, "maxzoom": "17", "controltype": "Large", ...

I am not very familar with gmap + locations, and this site is my first implementation of them, so I'm not sure if I've just been doing something wrong on my setup. Zoom with gmap macros written in nodes, or affected by the default gmap options seems to work just fine, though. I am using cck 6.x-2.4, location 6.x-3.1-rc1 and gmap 6.x-1.1-rc1.

Views solutions to cck gmaps were just creepy, in my opinion. I'd love to see this commited.

yesct’s picture

Does anyone know if this patch might fix #373465: Array errors in location_cck module?

I'm wondering if we list the issues that this patch might clear up, and cross post a link from those issues to this one, if this issue would get more publicity and more people testing it. :)

luckysmack’s picture

Using 6.x-3.x-dev i patched the files, with the following result:

patching file location_cck.module
Hunk #11 succeeded at 309 with fuzz 1

After logging in and trying out a few things i did not receive any errors or other problems. But do keep in mind that at this point i dont have any maps up yet so if there are any issues with gmaps they wouldnt have surfaced. but creating a small view, using some relationships i have setup, and making a few workarounds it all seemed to work fine with no visible errors in dblog. im glad to see this patch for location_cck, many people have been wating for it. thanks and keep up the great work karens. thanks. if i have a change to try it with a map i will report back any problems

fallsemo’s picture

I patched this against 6.x-3.1-rc1

Like #4 zoom settings do not seem to save. All other macro's seem to work.

samhassell’s picture

Like fallsemo i patched against rc1 and zoom doesnt work (all maps set to world view).

In my install the pages sometimes stall when loading a file from gg.google.com but that may be unrelated.

bcn’s picture

Does anyone know if this patch might fix #373465: Array errors in location_cck module?

It doesn't seem to... After replacing my patched copy of location with the one from this issue, the "The first argument should be an array" errors returned, seeming to indicate that this patch doesn't fix that error.

bcn’s picture

StatusFileSize
new5.2 KB
new16.16 KB

Attached is an version of the patch with the fixes from #373465: Array errors in location_cck module applied as well.

jontheil@gmail.com’s picture

Subscribing

bdragon’s picture

Reviewing, sorry about the delay!

bdragon’s picture

KarenS patch committed.
http://drupal.org/cvs?commit=243990
http://drupal.org/cvs?commit=243994

noahb patch committed.
http://drupal.org/cvs?commit=244004
http://drupal.org/cvs?commit=244006

Verified that noahb patch is functionally equivalent to #373465: Array errors in location_cck module #60 patch.

Leaving as needs review, I don't have my full testing environment set up at the moment.

bdragon’s picture

I didn't like the field settings, so I rewrote that part a bit.
The canonical "null macro" is [gmap ].

Also, took more care to preserve the user's settings.

http://drupal.org/cvs?commit=244030
http://drupal.org/cvs?commit=244032

bdragon’s picture

Forgot to fix the defaults on the other end...

http://drupal.org/cvs?commit=244040
http://drupal.org/cvs?commit=244042

bdragon’s picture

Fix warning, remove non functioning code that was forcing the zoom to 0. (Should address deva1983's problem).

http://drupal.org/cvs?commit=244048
http://drupal.org/cvs?commit=244050

bcn’s picture

Great work Brandon! Thanks for the updates...

I will be testing later today once the dev tarballs are updated.

bdragon’s picture

* Fix emptiness check centrally, instead of relying on location_save().
* Remove cck validator -- the condition it was checking for was a bug, not
a feature.

http://drupal.org/cvs?commit=244962
http://drupal.org/cvs?commit=244966
http://drupal.org/cvs?commit=244968

bdragon’s picture

* Bring CCK tests in sync with base COW tests.
* Fix location_cck node deletion (Apparently this never worked in the first place.)
* Remove extra checks from location_cck that were working around a bug in location.
*
* Fix a few bugs in location_cck discovered while revamping the tests.
* location_is_empty() will now consider a node with the delete checkbox checked to be "empty."
* Change reorderLocations() in the test suite to work on CCK fields.

http://drupal.org/cvs?commit=245052
http://drupal.org/cvs?commit=245058

bdragon’s picture

I am *very* confused about default value handling.

CCK in general saves an "all-defaults" field, but Location has traditionally avoided saving such.

Should I remove all the code that tries to compensate for the default value of the first location being provided by cck, and assume that if someone set the default value in the instance settings, that they want to save a location even if nothing was changed from the default?

neddim’s picture

Hello, when I want to show only one map with multiple value it doesnt show up.
All other kind of maps are working and are visible, just this one which is important to me.
Also, if I set market to "Number" it is always zero.
Thanks in advance for Your respone.

neddim’s picture

Anyway, this doesnt work.
It seems like ti doesnt call function anywhere. I do not knwo why.
I would really like if this can be fixed. Maybe some parameters in database were not saved when I select multiple location on one map or so?
I am ready to pay to reslovne this problem.
Although it would be nice if there is a posibility to show "Multiple values on one map with polylines/lines" instead markers.

srobert72’s picture

subscribing

Location : 6.x-3.x-dev (2009-Jul-31)
GMap : 6.x-1.x-dev (2009-Jun-09)

I have Views with GMap display style.
Since I have installed new Location release (2009-jul-31) all nodes with Location CCK have disappeared.
Only updated nodes have disappeared as if there is a problem with saving data.

To be sure i've created new ContentType, with new Location CCK field and new Content for this type.
Location data are correctly displayed in edit form with GMap widget.
But in my views no nodes are displayed.

Something wrong with Location CCK and Views.

srobert72’s picture

Sorry it works.

Following the procedure I could repare my views.
* add RelationShips Content:Location
* add 2 non displayed fields Location:Longitude and Location:Latitude
* modify DisplayStyle GMap : no more DataSource Location module but the 2 new fields Location:Longitude and Location:Latitude

And now it works.

neddim’s picture

I am speaking about "Multiple locations on one map".
I followed your procedure and it doesnt work, with or without Views. Is is same. :(
It seems like there is no calling this function.

izmeez’s picture

subscribing

karens’s picture

@bdragon, the widget_info settings for callbacks for default value should be set to CONTENT_CALLBACK_NONE. I am not sure where that got lost but that means 'Do not create a default value widget for this field.' which is what I think we want here. The only other alternative is CONTENT_CALLBACK_MODULE, where we would have our module create its own default value widget by creating a function called 'location_cck_default_value' that would return the right default value, but getting that working would be very very hard so I would leave that out.

I see that this got commented out in the code (might be might fault), but we need to set that back CONTENT_CALLBACK_NONE to quit trying to create a default value widget. Because if that value isn't set CCK will try to create a default value widget and it won't work.

arcaic’s picture

I am using location_cck with Gmap and views. My use case is that each member of a club I am part of can create a node and click on a location map to set their home location. They are anonymous to my site and do not log in. Their entries are unpublished and then reviewed by me.

I then display a View Page with a map containing all the locations. Works great apart from one thing.

Location_CCK does not seem to have any functionality that validates that the map has actually been clicked. In other words users can submit a node without having set their location. There doesn't seem to be anyway to force them to provide a location.

I may be misunderstanding as I'm a long way from being a Drupal/PHP expert but I thought validation of CCK fields happens in the hook_field function when the op is 'validate'. There is no such code in location_cck.module.

Anyone else using Location_CCK see this issue?
Is my understanding of hook_validate correct?
Can anyone give me pointers on how to fix it or implement a workaround?

Thanks

Andy

neddim’s picture

You can set optinion to "Required" in location cck field.
That will force users to insert their location.
Also, there is a possibility to define required fields inside location cck module, p.e. : street, additional, lat/long, etc
Go to: admin/content/types then click "Edit" for desired content which uses location cck module.
Under the "Locative information" group when editing content click tab "Collection settings".
Then You would have a possibility to overlook all fields for your location cck modules.
Under the option "Collect", you have possibility to define which fields should be required or similar.
Hope this helps

arcaic’s picture

Thanks for the reply.

I have required set for the location_cck field. I also have 'Require' set for the coordinate chooser. I can still submit a node for the content type without picking a location on the map.

My point was there is nothing in the hook_field 'validate' that actually does any validation at all. No one has been able to tell me whether there should be any validation code in hook_field of location_cck.module or whether it is done in some other way.

@neddim - Do you actually have this working? What versions are you using?

Andy

neddim’s picture

Yes offcourse this working with me.
I am using drupal 6.x.x - something.
Maybe You are checking different location modules. ( Please note, there is an option to add location via location cck field and via Locative information in node).
These are two different types of content.

nickl’s picture

Status: Needs review » Fixed

Marking to fixed. Lots of patches already committed to cvs and many users confirming reveiw and testing.

There are still 2 issues outstanding, but catered for in many other places.
There are fixes in place for the cck views fields ready for review CCK/Views: location_instance fix

node view gmap: location cck fix which will make cck handle the node view with map included and enable theme support.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

yesct’s picture

Status: Closed (fixed) » Postponed (maintainer needs more info)

What about karen's #27 comment?
Karen is this ready to be closed? There were lots of commits (last July 30th 2009). Maybe a new issue could be opened to tie up loose ends?

mcurry’s picture

subscribe

geerlingguy’s picture

Is there any way to simply display a map link along with the address in the node view? I don't need to integrate a GMap, as I'm using views attach to attach a map... but I'd still like a map link to Google Maps (direct) to be displayed alongside the address, so someone can get driving directions...

yesct’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

geerlingguy, I think the map link happens. Try the dev release, and maybe check out this demo video (which is about the views relation, but in the beginning does show a location with a map link. And I didn't do anything special to get that.) If you are still having a problem, please open up a new issue for it. Thanks.

http://cathytheys.blip.tv/file/3439392