0

I have a google map on a website using Objective HTML's Google Maps for Expression Engine add-on. The map plots all club locations in the area, so shows a number of markers.

Strangely it is showing one club in two different locations, even though only one entry exists in the database.

It seems I'm not the first to experience this (Random Duplicate locations when using Google Maps for EE).

Any ideas how I could go about solving this one would be massively appreciated.

Thanks in advance,

Tom

Code:

{exp:channel:entries 
    channel="friendship_clubs_data_feed" 
    dynamic="no" 
    status="Open|Exclude from search results" 
    orderby="title" 
    sort="asc"
}
    {exp:gmap:marker 
        id="map" 
        address="{club_feed_postcode}" 
        infobox="true"
        zIndex="5" 
        icon="/assets/images/Map-Marker.png"
        clustering="false"
        show_one_window="false"
        extend_bounds="true"
        geocode="true"
        clearanceX="10"
        clearanceY="20"
        offsetX="10"
        offsetY="-10"
    }
        <a href="{url_title_path='clubs/our-clubs/detail/'}"><h5>{title}</h5></a>
        <h6 class="centre-location">{club_feed_town}</h6>
    {/exp:gmap:marker}
{/exp:channel:entries}
2
  • Did you try using latitude="{latitude}" longitude="{longitude}" instead of address="{club_feed_postcode}" Commented Dec 14, 2016 at 13:05
  • I don't have a latitude or longitude for the clubs sadly, just a postcode Commented Dec 14, 2016 at 17:47

2 Answers 2

1

After several hours of investigative work, I finally found that a few addresses were entered incorrectly (country where region should have been, or vice versa). I came to this conclusion based on:

  • All of the individual profile pages showed the correct map location
  • On the map page, if I changed the code to produce an individual map for each location (one after the other rather than a single map with all of the locations plotted), then all of the maps displayed properly

What I did was created a list of the channel entries right after the map, including the {entry_id} (so I could quickly see which entry might be the issue). In your case, maybe something like this

{/exp:gmap:marker}
<p>{entry_id} - {title} (Zip: {club_feed_postcode})</p>
{/exp:channel:entries}

This allowed me to see exactly what the map was seeing. Then I started to add a "limit=xx" to my {exp:channel:entries} until I could see what entry was causing the problem (in other words, where the map was working properly). In my case, I had 3 locations that were causing an issue. It might be a case that the entry that is appearing twice is not the problem, but the entry that comes up right before it is. In my situation, I was able to fix two of the locations, and excluded the other entry until they can come up with the proper version of the address that worked.

Not sure this will produce the same outcome as mine did, but it's worth a shot!

3
  • That's really helpful, I'll take a look. Thanks Todd! Commented Dec 14, 2016 at 17:48
  • Did you come up with any resolution? I was alerted by a client that two of their websites now have locations showing up in the wrong place!!! GRRR
    – Todd
    Commented Dec 22, 2016 at 17:08
  • I did, using your method I worked out that I needed a limit="1" on the marker tag which solved the issue Commented Dec 22, 2016 at 17:38
1

So I've now solved this one and thought I'd share the solution I found.

It appeared to be the lack of ‘limit"1"’ in the {exp:gmap:marker} tag that was causing the problem. By adding that in the issue disappeared:

{exp:channel:entries 
    channel="friendship_clubs_data_feed" 
    dynamic="no" 
    status="Open|Exclude from search results" 
    orderby="title" 
    sort="asc"
}
    {exp:gmap:marker 
        id="map" 
        address="{club_feed_postcode}" 
        infobox="true"
        zIndex="5" 
        icon="/assets/images/Map-Marker.png"
        clustering="false"
        show_one_window="false"
        extend_bounds="true"
        geocode="true"
        clearanceX="10"
        clearanceY="20"
        offsetX="10"
        offsetY="-10"
        limit="1" <<<<<<<<<<<<<<<<<<<< THIS MADE THE DIFFERENCE
    }
        <a href="{url_title_path='clubs/our-clubs/detail/'}"><h5>{title}</h5></a>
        <h6 class="centre-location">{club_feed_town}</h6>
    {/exp:gmap:marker}
{/exp:channel:entries}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.