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!
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!
– Josh Kennedy Aug 12 '16 at 01:29