TransWikia.com

Duplicate markers appearing when using Google Maps for Expression Engine

ExpressionEngine® Answers Asked by Tom Perkins on September 16, 2020

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 Answers

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}

Answered by Tom Perkins on September 16, 2020

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!

Answered by Todd on September 16, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP