1

Using Objective HTMLs "Google Maps for ExpressionEngine" plugin this query returns 3 records and it is giving me the first two maps as staic maps and third map as a live map:

{exp:channel:entries channel="events" orderby="events_start_date" sort="desc"}

<div class="map">
{exp:gmap:init id="map{entry_id}" class="google-maps" style="width:100%;height:380px" scrollwheel="false"} 
                {exp:gmap:marker id="map{entry_id}" latitude="{events_map_latitude_field}" longitude="{events_map_longitude_field}" zoom="16"}
</div>

{/exp:channel:entries}

Why are all the maps not live maps with a marker on them?

The maps are also in a div that uses jquery show/hide and the real map only shows the first tile and the static maps (which should be real maps) don't even show. If the show/hide is disabled the maps render correctly (though the first two are static).

2
  • Are you getting any js errors in your console? Chrome console, Firebug console etc. ?
    – Natetronn
    Dec 5, 2012 at 6:10
  • Can we see the code online somewhere?
    – Anna_MediaGirl
    Dec 5, 2012 at 6:16

1 Answer 1

6

Take a look at the DOM, you will notice that the Google Maps library is included with each loop.

Use the script_tag="false" parameter.

https://objectivehtml.com/google-maps/documentation/tag/init#script_tag

Try something to this effect:

{if count == 1}
    {exp:gmap:init id="map{entry_id}" class="google-maps" style="width:100%;height:380px" scrollwheel="false" latitude="{events_map_latitude_field}" longitude="{events_map_longitude_field}" zoom="16"}
{if:else}
    {exp:gmap:init id="map{entry_id}" class="google-maps" style="width:100%;height:380px" scrollwheel="false" latitude="{events_map_latitude_field}" longitude="{events_map_longitude_field}" zoom="16" script_tag="false"}
{/if} 
7
  • That did the trick Justin, Thanks! Am I calling the maker correctly in my code? Any ideas about why the maps only showing the first tile when they are hidden with jquery? Dec 5, 2012 at 6:22
  • 1
    Make a new post for the jQuery question, I get that all the time in my email. That will be helpful for others too. Basically, you just need to redraw the map each time is goes from hidden to being displayed. Dec 5, 2012 at 6:24
  • 1
    And you are calling the marker code ok. That's really the original syntax. I won't call it legacy because it's still 100% supported with no plans on being deprecated... However, I usually break up the tags into the exp:gmap:init and exp:gmap:marker tags so it's more readable. You can do it however you want though, it really all executed the same code. Dec 5, 2012 at 6:27
  • @MikeDexter don't forget to accept this answer as the correct answer if it worked for you :)
    – Natetronn
    Dec 5, 2012 at 6:27
  • 1
    The tile issue is most likely this: stackoverflow.com/a/3066751/135935. This change fixed a recent tab/google map issue I was having where the map didn't completely show.
    – Anna_MediaGirl
    Dec 5, 2012 at 6:35

Your Answer

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

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