I feel like I'm overlooking something simple here, but I can't for the life of me figure out how to add markers to a map. I had this working with the Google Maps for Craft plugin but since switching to Smart Map I get as far as rendering a map and that's it.

My set up is such: I have a structure with multiple same-level entries, each of which has an address. I have an index page that's rendering a map which should be populated with markers based on the the addresses from each entry's address field.

Historically, I looped through the entries, defined each marker's address and then added that to the map variable like so:

{# Look for each location listed #}
{% for entry in craft.entries.section('locations').limit(null) %}
    {# For each location found, set the map marker properties to have an 
       address and a link to the location page within the pop-out menu that 
       shows on-click #}
    {% set marker = {
        address: entry.locationAddress,
        content: '...'
    } %}
    {# Then we add the marker to our map variable #}
    {{ craft.googleMaps.marker('map', marker) }}
{% endfor %}

However, now with Smart Map, I can't figure out how to recreate this. I don't quite understand how to set the locations for the {{ craft.smartMap.map(locations, options) }} call. The docs show that one can pass an array into it via craft.entries.section('myLocations') but since my address fields are not entries in a section I'm not sure how to parse that out.

Any help or insight would be greatly appreciated, thanks!

2 Answers 2


Author of Smart Map here...

It sounds like your locations are in a section (a Structure is a type of section). The first line of your solution is exactly what you'd need to get the locations value.

{% set locations = craft.entries.section('locations').limit(null) %}

{{ craft.smartMap.map(locations) }}

Just to clarify...

  • Are you using the "Address (Smart Map)" field to store your addresses?
  • And do each of those addresses contain "Latitude" and "Longitude" values?

If so, the code example above should definitely work for you!

  • Hey @Lindsey you're absolutely right, I misspoke about my locations being in a section - I mean't to say that my locations themselves were not a section, but contained within entries within a section. I think I wasn't sure how Craft or Smart Map was going to dive into each entry within said section to grab the Address (Smart Map) field values, since the locations have many different fields within them. You're correct, the code accomplishes just what I needed, and Smart Map has been great to work with thus far, now that I've switched context from the former plugin. Great work and thanks! Commented Aug 12, 2016 at 1:29
  • Awesome, thanks Josh! Glad you're digging the plugin. If you need any help in the future, feel free to email me at [email protected] :)
    – Lindsey D
    Commented Aug 12, 2016 at 3:09

I fiddled around with some fields and got this working. Not sure it's the most direct way, but hey. Progress is progress :)

{% set locations = craft.entries.section('locations').limit(null) %}

{# Look for each campus listed #}
{% for entry in craft.entries.section('campuses').limit(null) %}
    {% if entry.campusAddress|length %}
        {% set options = {
            markerOptions: {
                address: entry.campusAddress
        } %}
    {% endif %}
{% endfor %}

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.