0

ExpressionEngine 2.9.2 Google Maps for ExpressionEngine 3.3.8 Geocoder 1.2.0

I have a channel for branches and on the single entry page the map correctly displays the branches location using this code.

<div class="embed-container">
{exp:gmap:init id="map" scrollwheel="false"  style="width:1200px;height:460px"}

{exp:gmap:center id="map" address="{branch_address} {branch_city}"}
</div>

{exp:gmap:marker id="map" latitude="{branch_latitude}" longitude="{branch_longitude}" zoom="13"}

However on the landing page where I need to have a map showing all branches across Canada it is not working correctly. There are currently 27 branches but on the google map only 4 are displaying and they are not in the correct location. Furthermore the infobox for all pins contains exactly the same data rather than the data for that pins location.

Template code:

{exp:channel:entries channel="branches" disable="member_data|pagination|categories|category_fields" limit="300"}

 {exp:gmap:marker 
  id="map" 
  latitude="{branch_latitude}" 
  longitude="{branch_longitude}"
  duplicate_markers="false"
  icon="/images/map-pin.png"
  geocode="true" 
  clustering="false"
  latitude="48" 
  longitude="-83"
  limit="100"

  infobox="true"
  offsetY="-40"
  offsetX="0"
  class="entry-{entry_id} ui-infobox-dark"
  closeBoxMargin="5px"
}
  <div class="ui-infobox-content">
    <h4>{title}</h4>
    {branch_address} <br>
    {branch_city} {branch_province} <br>
    {branch_postcode} <br>
    Work Phone: {branch_phone} <br>
    Toll Free: {branch_toll_free} <br>
    Fax Number: {branch_fax}
  </div>
{/exp:gmap:marker}

{!--
// add active class to branch card to highlight it.
--}
{exp:gmap:event id="map"}
  $('.block article.entry{entry_id}').addClass('active');

  $( ".ui-infobox-dark  img" ).click(function() {
    $('.block article').removeClass('active');
  });

{/exp:gmap:event}

{/exp:channel:entries}

I've tried a number of different approaches and scoured the documentation but cannot seem to figure out what I'm doing wrong. Please advise.

4
  • Change geocode="true" to geocode="false". You shouldn't need that. – Justin Kimbrell Dec 22 '14 at 22:42
  • Justin - when I change to false - only one pin displays, there should be 29 pins total. Oh and the one pin that displays the info marker has info for a branch thousands of kilometers away. – CreateSean Dec 22 '14 at 22:49
  • I just noticed this as well, why do you have latitude and longitude defined twice? Remove the static declaration and just use the dynamic coordinates, and this should work. – Justin Kimbrell Dec 22 '14 at 22:51
  • Never mind - I'm freaking stupid. changed latitude="{branch_latitude}" longitude="{branch_longitude}" amd all good. – CreateSean Dec 22 '14 at 22:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.