<p>There are actually two problems happening here...</p>

<p>(1) For a location to appear on a map, it's critical for the latitude &amp; longitude to be filled in. Within the UX of the Address field, this can happen a few different ways... as you mentioned, clicking "Select Address" is one of the main ways of doing so. Additionally, the address selection modal will be automatically triggered when you tab between fields.</p>

<p><s>(2) There is apparently a small bug in Smart Map, which I'll go ahead and patch. If a location is lacking coordinates, the JS shouldn't attempt to render that marker. It should just be omitted from the map instead.</s></p>

<p>Hope that helps. I'll release a patch shortly.</p>

<hr>

<p><strong>UPDATE:</strong></p>

<p>I just pushed out Smart Map v2.3.2, which fixes the bug. Instead of triggering a JS error, the marker will simply be skipped. In that case, the JS console will output the following message:</p>

<blockquote>
  <p>Unable to draw marker, invalid coordinates.</p>
</blockquote>

<p>Hope that helps! For anyone who may need further support on this issue, feel free to email support@doublesecretagency.com.</p>

CC BY-SA 3.0
2016-01-11T04:46:45.877Z
2016-01-11T06:29:15.650Z
2016-01-11T06:29:15.650Z
Lindsey D
<p>On my _entry page, I'm trying to get the SmartMap plugin to generate a dynamic map, but it gets stuck on 'Loading Map'</p>

<p>Using this as the code:</p>

<pre><code>{{ craft.smartMap.map(entry.theEventAddress) }}
</code></pre>

<p>and the console tells me:</p>

<blockquote>
  <p>Uncaught SyntaxError: Unexpected token ,</p>
</blockquote>

<p>The documentation is a bit vague on this, and it doesn't really tell you how to fix JavaScript errors. Also, I have API keys in the settings.</p>

<p>EDIT</p>

<p>Here's the output as requested. Using the latest version of the plugin. (2.3.1)</p>

<pre><code>&lt;script type="text/javascript"&gt;
/*&lt;![CDATA[*/
if (logSmartMap) {console.log("[smartmap-mapcanvas-1] Drawing map...");}
smartMap.createMap("smartmap-mapcanvas-1", {"center":smartMap.coords(-48.876667,-123.393333),"scrollwheel":false});
if (logSmartMap) {console.log("[smartmap-mapcanvas-1.2497.theEventAddress] Drawing marker...");}
smartMap.createMarker("smartmap-mapcanvas-1.2497.theEventAddress", {"mapId":"smartmap-mapcanvas-1","map":smartMap.map["smartmap-mapcanvas-1"],"position":smartMap.coords(,)});
if (logSmartMap) {console.log("[smartmap-mapcanvas-1] Fitting bounds...");}
smartMap.fitBounds("smartmap-mapcanvas-1");
/*]]&gt;*/
&lt;/script&gt;
</code></pre>

<p>This is the problem line:</p>

<pre><code>smartMap.createMarker("smartmap-mapcanvas-1.2497.theEventAddress", {"mapId":"smartmap-mapcanvas-1","map":smartMap.map["smartmap-mapcanvas-1"],"position":smartMap.coords(,)});
</code></pre>

CC BY-SA 3.0
2016-01-11T00:27:26.697Z
Can you post a snippet of the generated source code, specifically where the console error is being thrown? Also, are you running the latest version of Smart Map (v2.3.1)?
Lindsey D
CC BY-SA 3.0
2016-01-11T01:26:50.303Z
I'm using 2.3.1 -- See post edit.
Dustin C
CC BY-SA 3.0
2016-01-11T02:50:36.523Z
Interesting, thanks. The JS error is being thrown by this specific chunk of code: `"position":smartMap.coords(,)`... Looks like a bug. For your entry with the ID of `2497`, does `theEventAddress` have coordinates? Or are the latitude & longitude fields blank?
Lindsey D
CC BY-SA 3.0
2016-01-11T04:20:35.700Z
They are blank. I didn't include them in the address entry field because I can't count on the client to enter the coords for the location. That's why I specifically bought this plugin.
Dustin C
CC BY-SA 3.0
2016-01-11T04:50:40.603Z
It's possible for an address to have multiple possible matches. The address selection modal ensures that the user is selecting the _correct_ address, not just the first match.
Lindsey D
<plugin-smartmap>
SmartMap throwing back javascript error
# SmartMap throwing back javascript error

(Asked by: username_0 on 2016-01-10)

On my _entry page, I'm trying to get the SmartMap plugin to generate a dynamic map, but it gets stuck on 'Loading Map'
Using this as the code:
{{ craft.smartMap.map(entry.theEventAddress) }}

and the console tells me:

Uncaught SyntaxError: Unexpected token ,

The documentation is a bit vague on this, and it doesn't really tell you how to fix JavaScript errors. Also, I have API keys in the settings.
EDIT
Here's the output as requested. Using the latest version of the plugin. (2.3.1)


This is the problem line:
smartMap.createMarker("smartmap-mapcanvas-1.2497.theEventAddress", {"mapId":"smartmap-mapcanvas-1","map":smartMap.map["smartmap-mapcanvas-1"],"position":smartMap.coords(,)});

**Tags:** plugin-smartmap
> **Comments:**
> **username_1**: Can you post a snippet of the generated source code, specifically where the console error is being thrown? Also, are you running the latest version of Smart Map (v2.3.1)?  
> **username_0**: I'm using 2.3.1 -- See post edit.  
> **username_1**: Interesting, thanks. The JS error is being thrown by this specific chunk of code: `"position":smartMap.coords(,)`... Looks like a bug. For your entry with the ID of `2497`, does `theEventAddress` have coordinates? Or are the latitude & longitude fields blank?  
> **username_0**: They are blank. I didn't include them in the address entry field because I can't count on the client to enter the coords for the location. That's why I specifically bought this plugin.  
> **username_1**: It's possible for an address to have multiple possible matches. The address selection modal ensures that the user is selecting the _correct_ address, not just the first match.  

---

## 1 answers

### Answer by username_1 on 2016-01-11. Score: 2 | Accepted answer

There are actually two problems happening here...

(1) For a location to appear on a map, it's critical for the latitude & longitude to be filled in. Within the UX of the Address field, this can happen a few different ways... as you mentioned, clicking "Select Address" is one of the main ways of doing so. Additionally, the address selection modal will be automatically triggered when you tab between fields.

~~(2) There is apparently a small bug in Smart Map, which I'll go ahead and patch. If a location is lacking coordinates, the JS shouldn't attempt to render that marker. It should just be omitted from the map instead.~~

Hope that helps. I'll release a patch shortly.

---

**UPDATE:**

I just pushed out Smart Map v2.3.2, which fixes the bug. Instead of triggering a JS error, the marker will simply be skipped. In that case, the JS console will output the following message:

> Unable to draw marker, invalid coordinates.

Hope that helps! For anyone who may need further support on this issue, feel free to email support@doublesecretagency.com.


---

