<p>According to <a href="https://plugins.doublesecretagency.com/smart-map/render-a-map-in-twig/" rel="nofollow noreferrer">the docs</a>, <code>locations</code> has to be an array of elements or an ElementCriteriaModel
if you want to display multiple markers.</p>
<pre><code>{% set mapEntries = craft.entries.section('markets') %}
{{ craft.smartMap.map(mapEntries, options) }}
</code></pre>

CC BY-SA 4.0
2016-12-20T15:46:46.477Z
2021-01-01T06:47:16.263Z
2021-01-01T06:47:16.263Z
carlcs
<p>I have a Smart Map field in a section and am trying to output multiple results (pins) to a single map.</p>
<p>This code will output multiple maps (one map per pin)</p>
<pre><code>{% for mapEntry in craft.entries.section('markets') %}
{% set options = {
    height: 500,
    zoom: 14,
    draggable: false,
    markerInfo: '_includes/mapInfoBubble',
    markerOptions: {
        icon: 'http://maps.google.com/mapfiles/ms/icons/green-dot.png'
    },
    infoWindowOptions: {
        maxWidth: 200
    }
} %}

{% set locations = craft.entries.section('markets').marketAddress.find() %}

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

{% endfor %}
</code></pre>
<p>So essentially I am trying to get the <code>{{ craft.smartMap.map(locations, options) }}</code> outside the for loop.</p>
<pre><code>{% set locations = '' %}
{% set options = '' %}
{% for mapEntry in craft.entries.section('markets') %}
{% set options = {
    height: 500,
    zoom: 14,
    draggable: false,
    markerInfo: '_includes/mapInfoBubble',
    markerOptions: {
        icon: 'http://maps.google.com/mapfiles/ms/icons/green-dot.png'
    },
    infoWindowOptions: {
        maxWidth: 200
    }
} %}
{% set locations = craft.entries.section('markets').marketAddress.find() %}
{{ craft.smartMap.map(locations, options) }}
{% endfor %}
</code></pre>
<p>But this only results in a single pin (most recent entry).</p>
<p>Can't get my head around this. Any assistance most welcome.</p>

CC BY-SA 3.0
2016-12-20T17:50:45.120Z
Turns out this code works fine. Adjusting zoom level showed proper results. Ahem!
Micky Kelleher
CC BY-SA 3.0
2016-12-20T22:36:43.970Z
Glad you got it worked out! For any other folks just passing by, a zoom level of `14` is extremely close. The maximum is `16`, which practically shows your front doorstep. (Conversely, `1` is a distant view from outer space.)
Lindsey D
<plugin-smartmap>
Smart Map - Setting single map with multiple pins
# Smart Map - Setting single map with multiple pins

(Asked by: username_0 on 2016-12-20)

I have a Smart Map field in a section and am trying to output multiple results (pins) to a single map.
This code will output multiple maps (one map per pin)
{% for mapEntry in craft.entries.section('markets') %}
{% set options = {
    height: 500,
    zoom: 14,
    draggable: false,
    markerInfo: '_includes/mapInfoBubble',
    markerOptions: {
        icon: 'http://maps.google.com/mapfiles/ms/icons/green-dot.png'
    },
    infoWindowOptions: {
        maxWidth: 200
    }
} %}

{% set locations = craft.entries.section('markets').marketAddress.find() %}

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

{% endfor %}

So essentially I am trying to get the {{ craft.smartMap.map(locations, options) }} outside the for loop.
{% set locations = '' %}
{% set options = '' %}
{% for mapEntry in craft.entries.section('markets') %}
{% set options = {
    height: 500,
    zoom: 14,
    draggable: false,
    markerInfo: '_includes/mapInfoBubble',
    markerOptions: {
        icon: 'http://maps.google.com/mapfiles/ms/icons/green-dot.png'
    },
    infoWindowOptions: {
        maxWidth: 200
    }
} %}
{% set locations = craft.entries.section('markets').marketAddress.find() %}
{{ craft.smartMap.map(locations, options) }}
{% endfor %}

But this only results in a single pin (most recent entry).
Can't get my head around this. Any assistance most welcome.

**Tags:** plugin-smartmap
> **Comments:**
> **username_0**: Turns out this code works fine. Adjusting zoom level showed proper results. Ahem!  
> **username_1**: Glad you got it worked out! For any other folks just passing by, a zoom level of `14` is extremely close. The maximum is `16`, which practically shows your front doorstep. (Conversely, `1` is a distant view from outer space.)  

---

## 1 answers

### Answer by username_2 on 2016-12-20. Score: 3 | Accepted answer

According to the docs, locations has to be an array of elements or an ElementCriteriaModel
if you want to display multiple markers.
{% set mapEntries = craft.entries.section('markets') %}
{{ craft.smartMap.map(mapEntries, options) }}


---

