Looks like it would be possible to modify the field formatter and views plugin to check all the map data of type "Point" for duplicate coordinates, and offset each duplicate slightly (say 5m) in a random grouping. This would force the google API to display them all as separate pins.
The Getlocations module supports Geofield and deals with the multiple markers with identical lat/lon problem by spreading them apart by a few meters so that they can be clicked.
Mm, I'd prefer not to be tracking more libraries and modules for a fairly simple requirement. Another possibility from the field/view formatter is to add multiple descriptions to a single location pin. This is a lot simpler to implement and avoids the crowding problem completely.
Fair enough, there are other mapping modules that will give you better control over this. But those either require fairly complex setup and/or need all output to be switched to a different formatter.
I think geofield should be able to handle it at a basic level by combining descriptions (optional via a settings checkbox), and perhaps also provide an alter hook, allowing other modules to modify the location data before it is passed to javascript.
As a first stab at it, something along these lines. I've tested it for the views field integration, but not for the node field display. The setting checkbox is "Combine duplicate locations".
The combined descriptions are just separated by html breaks at present, but to handle more complex descriptions it's probably desirable that each description is wrapped in a div, and perhaps that should be handled by a theme function/template.
It is quite a bad design decision to add markup when your are just working with your data – should either be templated (less optimal) or inherit markup per description from the individual description fields and then have a templatable wrapper.
Another approach would be to make the post- & prefix configurable so you can specify them individually.
That said, how does this differ from Group field by location in views?
I'm no longer using this patch in production (I was for 2 years), so at present it's unlikely I'll make the changes suggested sorry. Others may wish to do so.
Comments
Comment #1
johnpitcairn commentedAs I understand it, if you are using the google maps API, no, it is not.
I'd like to do this too, we have two different businesses in the same building and they both want to be on the map as separate pins.
Comment #2
Brandonian commentedBest way to handle this IMHO is to use Leaflet and Leaflet markercluster.
http://drupal.org/project/leaflet
https://drupal.org/project/leaflet_markercluster
Comment #3
johnpitcairn commentedLooks like it would be possible to modify the field formatter and views plugin to check all the map data of type "Point" for duplicate coordinates, and offset each duplicate slightly (say 5m) in a random grouping. This would force the google API to display them all as separate pins.
Comment #4
hutch commentedThe Getlocations module supports Geofield and deals with the multiple markers with identical lat/lon problem by spreading them apart by a few meters so that they can be clicked.
Comment #5
johnpitcairn commentedMm, I'd prefer not to be tracking more libraries and modules for a fairly simple requirement. Another possibility from the field/view formatter is to add multiple descriptions to a single location pin. This is a lot simpler to implement and avoids the crowding problem completely.
Comment #6
johnpitcairn commentedFair enough, there are other mapping modules that will give you better control over this. But those either require fairly complex setup and/or need all output to be switched to a different formatter.
I think geofield should be able to handle it at a basic level by combining descriptions (optional via a settings checkbox), and perhaps also provide an alter hook, allowing other modules to modify the location data before it is passed to javascript.
Would a patch along those lines be acceptable?
Comment #7
johnpitcairn commentedComment #8
johnpitcairn commentedAs a first stab at it, something along these lines. I've tested it for the views field integration, but not for the node field display. The setting checkbox is "Combine duplicate locations".
The combined descriptions are just separated by html breaks at present, but to handle more complex descriptions it's probably desirable that each description is wrapped in a div, and perhaps that should be handled by a theme function/template.
Comment #9
johnpitcairn commentedI neglected to add the new checkbox to field/views info and defaults. This patch corrects that, so features/views exports will work correctly.
Comment #10
halloffame commentedSuccessfully applied patch at #9, the "Combine duplicate locations" is working as it should.
Comment #11
johnpitcairn commentedCan you RTBC the issue please?
Comment #12
lslinnet commentedTested And reviewed, works as expected – but there is a few minor elements that I would prefer getting looked into
"Yes" & "No" should also be translatable?
It is quite a bad design decision to add markup when your are just working with your data – should either be templated (less optimal) or inherit markup per description from the individual description fields and then have a templatable wrapper.
Another approach would be to make the post- & prefix configurable so you can specify them individually.
That said, how does this differ from Group field by location in views?
Comment #13
johnpitcairn commentedI'm no longer using this patch in production (I was for 2 years), so at present it's unlikely I'll make the changes suggested sorry. Others may wish to do so.
Comment #14
fdverwoerd commentedI've rerolled the patch to 2.x-dev / 7.x-2.3. It still works.
It still needs work from comment 12.
Comment #15
daluxz commentedI rerolled the patch for 7.x-2.4.