<p>Found the solution, posting answer for future reference:</p>

<p>It seems the official docs provide a wrong example for outputting the parts. Instead of using <code>{{ myMapField.country_short }}</code> as mentioned in the docs, you have to use <code>{{ myMapField.parts.country_short }}</code> (or without the _short suffix). This will correctly output just the country part of the full address.</p>

CC BY-SA 3.0
2017-04-14T12:05:34.020Z
2017-04-14T12:05:34.020Z
Jake
<p>Never used the plugin, but from the docs:</p>
<blockquote>
<p><strong>parts</strong></p>
<p>This contains the locations address, broken down into its constituent parts. All values are optional so you'll need to have checks on any you use to make sure they exist.
A list of the available values can be found here.
To access the short version of any part, append _short to the end of its name. E.g. {{ myMapField.country_short }}.</p>
</blockquote>
<p>Sounds like the country info is optional and may not exist on the model, hence the note to check if it exists or not first.</p>
<p>i.e.</p>
<pre><code>{% if myMapField.country_short is defined %}
    {{ myMapField.country_short }}
{% endif %}
</code></pre>

CC BY-SA 3.0
2017-04-05T08:04:26.423Z
Thank you, unfortunately it does not solve the error. For the record the values I use are actually `{{ entry.myMapField }} {{ entry.myMapField.address }} {{ entry.myMapField.lat }}` etc. (in a for loop). Any other ideas?
Jake
CC BY-SA 3.0
2017-05-06T07:40:10.647Z
Jake please let me know if you got this figured out yet, I am running into the same.
Vin
CC BY-SA 3.0
2017-04-04T18:44:25.963Z
2017-04-04T18:44:25.963Z
2020-06-17T08:56:27.903Z
Brad Bell
<p>The docs of the <a href="https://github.com/ethercreative/simplemap" rel="nofollow noreferrer">SimpleMap</a> plugin mention it's possible to output only part of the full location, e.g. just the country by using </p>

<pre><code>{{ myMapField.country_short }}
</code></pre>

<p>but in my project I get this error when I try doing so:</p>

<pre><code>Internal Server Error

Craft\SimpleMap_MapModel and its behaviors do not have a method or closure named "country".
</code></pre>

<p>Same result without the _short suffix.
The plugin is set up properly as I can correctly output full address, lat, lng, zoom values like so:</p>

<pre><code>{{ myMapField.address }}
{{ myMapField.lat }}
{{ myMapField.lng }}
</code></pre>

<p>Just splitting up the full address results in the above error. What's going wrong?</p>

<plugin-simplemap>
How do I output only country part of location field using the SimpleMap plugin?
# How do I output only country part of location field using the SimpleMap plugin?

(Asked by: username_0 on 2017-04-04)

The docs of the SimpleMap plugin mention it's possible to output only part of the full location, e.g. just the country by using 
{{ myMapField.country_short }}

but in my project I get this error when I try doing so:
Internal Server Error

Craft\SimpleMap_MapModel and its behaviors do not have a method or closure named "country".

Same result without the _short suffix.
The plugin is set up properly as I can correctly output full address, lat, lng, zoom values like so:
{{ myMapField.address }}
{{ myMapField.lat }}
{{ myMapField.lng }}

Just splitting up the full address results in the above error. What's going wrong?

**Tags:** plugin-simplemap


---

## 2 answers

### Answer by username_0 on 2017-04-14. Score: 1 | Accepted answer

Found the solution, posting answer for future reference:

It seems the official docs provide a wrong example for outputting the parts. Instead of using `{{ myMapField.country_short }}` as mentioned in the docs, you have to use `{{ myMapField.parts.country_short }}` (or without the \_short suffix). This will correctly output just the country part of the full address.


---

### Answer by username_1 on 2017-04-04. Score: 1

Never used the plugin, but from the docs:

parts
This contains the locations address, broken down into its constituent parts. All values are optional so you'll need to have checks on any you use to make sure they exist.
A list of the available values can be found here.
To access the short version of any part, append _short to the end of its name. E.g. {{ myMapField.country_short }}.

Sounds like the country info is optional and may not exist on the model, hence the note to check if it exists or not first.
i.e.
{% if myMapField.country_short is defined %}
    {{ myMapField.country_short }}
{% endif %}

> **Comments:**
> **username_0**: Thank you, unfortunately it does not solve the error. For the record the values I use are actually `{{ entry.myMapField }} {{ entry.myMapField.address }} {{ entry.myMapField.lat }}` etc. (in a for loop). Any other ideas?  
> **username_2**: username_0 please let me know if you got this figured out yet, I am running into the same.  

---

