Comments

johnpitcairn’s picture

As 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.

Brandonian’s picture

Status: Active » Closed (won't fix)

Best way to handle this IMHO is to use Leaflet and Leaflet markercluster.

http://drupal.org/project/leaflet
https://drupal.org/project/leaflet_markercluster

johnpitcairn’s picture

Status: Closed (won't fix) » Active

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.

hutch’s picture

Status: Active » Closed (won't fix)

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.

johnpitcairn’s picture

Status: Closed (won't fix) » Active

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.

johnpitcairn’s picture

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.

Would a patch along those lines be acceptable?

johnpitcairn’s picture

Component: Documentation » GeoField Map
Category: support » feature
johnpitcairn’s picture

Title: Display 2 markers at same location » Combine markers with identical locations
Version: 7.x-1.1 » 7.x-2.x-dev
StatusFileSize
new3.38 KB

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.

johnpitcairn’s picture

Status: Active » Needs review
StatusFileSize
new4.55 KB

I neglected to add the new checkbox to field/views info and defaults. This patch corrects that, so features/views exports will work correctly.

halloffame’s picture

Issue summary: View changes

Successfully applied patch at #9, the "Combine duplicate locations" is working as it should.

johnpitcairn’s picture

Can you RTBC the issue please?

lslinnet’s picture

Status: Needs review » Needs work

Tested And reviewed, works as expected – but there is a few minor elements that I would prefer getting looked into

  1. +++ b/modules/geofield_map/geofield_map.module
    @@ -163,6 +168,9 @@ function geofield_map_field_formatter_settings_summary($field, $instance, $view_
    +    $summary[] = t('Combine duplicate locations: @yn', array('@yn' => ($settings['geofield_map_combine_duplicates'] ? 'Yes' : 'No')));
    

    "Yes" & "No" should also be translatable?

  2. +++ b/modules/geofield_map/geofield_map.module
    @@ -340,7 +354,44 @@ function geofield_map_settings_do($settings) {
    +      $description .= $description ? '<br />' : '';
    

    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?

johnpitcairn’s picture

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.

fdverwoerd’s picture

I've rerolled the patch to 2.x-dev / 7.x-2.3. It still works.

It still needs work from comment 12.

daluxz’s picture

I rerolled the patch for 7.x-2.4.