Answers.Body: <p>Let me start with a minor side note... You'll want to change the first line to this:</p>
  
  <pre><code>{% if craft.smartMap.visitor.ip %}
  </code></pre>
  
  <p>It's better to test against a "falsey" IP address, instead of explicitly testing for an empty string. I believe the IP address would resolve to <code>false</code> if nothing was found. Either way, a general "falsey" check will work as expected here.</p>
  
  <hr>
  
  <p>It's not currently possible to convert a raw set of coordinates into a more complex object.</p>
  
  <p>That being said, you could fairly easily do it using the built-in <code>smartMap</code> JavaScript object...</p>
  
  <pre><code>{# Get visitor's coordinates #}
  {% if craft.smartMap.visitor.ip %}
      {% set coords = craft.smartMap.visitor.coords %}
      {% set jsCoords = 'smartMap.coords(' ~ coords[0] ~ ', ' ~ coords[1] ~ ')' %}
  {% else %}
      {% set coords = craft.smartMap.lookupCoords(90210) %}
      {% set jsCoords = 'smartMap.coords(' ~ coords['lat'] ~ ', ' ~ coords['lng'] ~ ')' %}
  {% endif %}
  
  {# Blank map #}
  {{ craft.smartMap.map([], options) }}
  
  {# Add visitor marker #}
  {% js %}
      smartMap.createMarker('visitor-marker', {
          position: {{ jsCoords }},
          map: smartMap.map['smartmap-mapcanvas-1'],
      });
  {% endjs %}
  </code></pre>
  
  <hr>
  
  <p><strong>UPDATE:</strong> I fixed a bug in v3.0.5 which makes this even easier.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-29T05:52:57.070Z
Answers.LastActivityDate: 2018-03-29T18:55:38.420Z
Answers.LastEditDate: 2018-03-29T18:55:38.420Z
Answers.UserDisplayName: Lindsey D
Answers.Body: <p>Actually you can check google map api directly other than using map plugins</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-31T18:16:40.070Z
Answers.Text: Thank you both. I don't just want to put a pin on a map, I want to display all addresses in a craft structure within a certain distance.
Answers.UserDisplayName: Eric Snyder
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-29T01:07:54.180Z
Answers.LastActivityDate: 2018-03-29T01:07:54.180Z
Answers.UserDisplayName: yu xia
Body: <p>I see the <a href="https://plugins.doublesecretagency.com/smart-map/front-end-address-lookup/" rel="nofollow noreferrer">docs here</a> about getting the lat/long of an address from a zip code, city, etc. I am having issues getting the map to render from this info. My code:</p>
  <pre><code>{% if craft.smartMap.visitor.ip != '' %}
      {% set locations = craft.smartMap.visitor.coords %}
  {% else %}
      {% set locations = craft.smartMap.lookupCoords(90210) %}
  {% endif %}
  
  {{ craft.smartMap.map(locations, options) }}
  </code></pre>
  <p>I get:</p>
  <blockquote>
  <p>Undefined index: fieldId</p>
  </blockquote>
  <p>How do I convert the lat/long result into one of the <a href="https://plugins.doublesecretagency.com/smart-map/render-a-map-in-twig/" rel="nofollow noreferrer">correct location types</a>?</p>
  
Tags: <craft3><plugin-smartmap>
Title: Using front end lookup for map display
ThreadText: # Using front end lookup for map display
  
  (Asked by: username_0 on 2018-03-28)
  
  I see the [docs here](https://plugins.doublesecretagency.com/smart-map/front-end-address-lookup/) about getting the lat/long of an address from a zip code, city, etc. I am having issues getting the map to render from this info. My code:
  
  ```
  {% if craft.smartMap.visitor.ip != '' %}
      {% set locations = craft.smartMap.visitor.coords %}
  {% else %}
      {% set locations = craft.smartMap.lookupCoords(90210) %}
  {% endif %}
  
  {{ craft.smartMap.map(locations, options) }}
  
  ```
  
  I get:
  
  > Undefined index: fieldId
  
  How do I convert the lat/long result into one of the [correct location types](https://plugins.doublesecretagency.com/smart-map/render-a-map-in-twig/)?
  
  **Tags:** craft3, plugin-smartmap
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2018-03-29. Score: 1 | Accepted answer
  
  Let me start with a minor side note... You'll want to change the first line to this:
  
  ```
  {% if craft.smartMap.visitor.ip %}
  
  ```
  
  It's better to test against a "falsey" IP address, instead of explicitly testing for an empty string. I believe the IP address would resolve to `false` if nothing was found. Either way, a general "falsey" check will work as expected here.
  
  ---
  
  It's not currently possible to convert a raw set of coordinates into a more complex object.
  
  That being said, you could fairly easily do it using the built-in `smartMap` JavaScript object...
  
  ```
  {# Get visitor's coordinates #}
  {% if craft.smartMap.visitor.ip %}
      {% set coords = craft.smartMap.visitor.coords %}
      {% set jsCoords = 'smartMap.coords(' ~ coords[0] ~ ', ' ~ coords[1] ~ ')' %}
  {% else %}
      {% set coords = craft.smartMap.lookupCoords(90210) %}
      {% set jsCoords = 'smartMap.coords(' ~ coords['lat'] ~ ', ' ~ coords['lng'] ~ ')' %}
  {% endif %}
  
  {# Blank map #}
  {{ craft.smartMap.map([], options) }}
  
  {# Add visitor marker #}
  {% js %}
      smartMap.createMarker('visitor-marker', {
          position: {{ jsCoords }},
          map: smartMap.map['smartmap-mapcanvas-1'],
      });
  {% endjs %}
  
  ```
  
  ---
  
  **UPDATE:** I fixed a bug in v3.0.5 which makes this even easier.
  
  
  ---
  
  ### Answer by username_2 on 2018-03-29. Score: 0
  
  Actually you can check google map api directly other than using map plugins
  
  > **Comments:**
  > **username_0**: Thank you both. I don't just want to put a pin on a map, I want to display all addresses in a craft structure within a certain distance.  
  
  ---
  
  