<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Accessing geocoded results in hubl in CMS Development</title>
    <link>https://community.hubspot.com/t5/CMS-Development/Accessing-geocoded-results-in-hubl/m-p/273184#M12472</link>
    <description>&lt;P&gt;Thanks again, Jsum. &lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/73904"&gt;@JAbella&lt;/a&gt;: just wanted to link you to some relevant HubL documentation. We have some documentation on the HTTP request variables here: &lt;A href="https://designers.hubspot.com/docs/hubl/hubl-supported-variables#http-request-variables" target="_blank"&gt;https://designers.hubspot.com/docs/hubl/hubl-supported-variables#http-request-variables&lt;/A&gt;. So like Jsum suggested, you can pull the query string parameters from a dict created at {{ request.query_dict }} . I'd also suggest reading our article about using the Developer Info tab: &lt;A href="https://designers.hubspot.com/docs/hubl/how-to-use-developer-info-on-cos-pages" target="_blank"&gt;https://designers.hubspot.com/docs/hubl/how-to-use-developer-info-on-cos-pages&lt;/A&gt;. It can help in terms of finding HubL variables that you can use. I hope that helps.&lt;/P&gt;</description>
    <pubDate>Mon, 03 Jun 2019 16:06:40 GMT</pubDate>
    <dc:creator>lscanlan</dc:creator>
    <dc:date>2019-06-03T16:06:40Z</dc:date>
    <item>
      <title>Accessing geocoded results in hubl</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Accessing-geocoded-results-in-hubl/m-p/272666#M12424</link>
      <description>&lt;P&gt;We are adding a search by address for users to filter facilities near them (&lt;A href="https://www.addictionresourcecenter.org/find-local-resources/massachusetts" target="_self"&gt;right now&lt;/A&gt; we just have the basic zip search).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm still getting familiar with hubl and the google maps API and need to capture the geocode results as a param. This does not work because the scope of the results doesn't extend to the hubl. How can I get the returned info in there?&lt;/P&gt;&lt;PRE&gt;resultsMap.setCenter(results[0].geometry.location);
                  {% set lat_param = lat_param ~ "&amp;amp;latitude=" + results[0].geometry.location.lat|urlencode %}
                  {% set lon_param = lon_param ~ "&amp;amp;longitude=" + results[0].geometry.location.lat|urlencode %}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help or direction would be greatly appreciated!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 May 2019 14:42:47 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Accessing-geocoded-results-in-hubl/m-p/272666#M12424</guid>
      <dc:creator>JAbella</dc:creator>
      <dc:date>2019-05-30T14:42:47Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing geocoded results in hubl</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Accessing-geocoded-results-in-hubl/m-p/272881#M12454</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/73904"&gt;@JAbella&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can help, but I think I need to understand your code a little better. How are you currently getting the lat and long? You said that the scope of the results doesn't extend to HubL. Where are the results currently? Is it coming just from the query string?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;BR /&gt;Leland&lt;/P&gt;</description>
      <pubDate>Fri, 31 May 2019 16:45:43 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Accessing-geocoded-results-in-hubl/m-p/272881#M12454</guid>
      <dc:creator>lscanlan</dc:creator>
      <dc:date>2019-05-31T16:45:43Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing geocoded results in hubl</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Accessing-geocoded-results-in-hubl/m-p/272921#M12456</link>
      <description>&lt;P&gt;Hiya Leland -- thank you for helping!!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using the google maps geocoding api (and the boilerplate code from &lt;A href="https://developers.google.com/maps/documentation/javascript/examples/geocoding-simple" target="_self"&gt;here&lt;/A&gt;) and the results come back as this object&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;results[]: {
 types[]: string,
 formatted_address: string,
 address_components[]: {
   short_name: string,
   long_name: string,
   postcode_localities[]: string,
   types[]: string
 },
 partial_match: boolean,
 place_id: string,
 postcode_localities[]: string,
 geometry: {
   location: LatLng,
   location_type: GeocoderLocationType
   viewport: LatLngBounds,
   bounds: LatLngBounds
 }
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's the first time I've worked with the geocoding api, so I set it up on &lt;A href="https://www.addictionresourcecenter.org/this-is-a-test" target="_self"&gt;this test page&lt;/A&gt; to recenter the map and it has it's own submit button.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As the interim step, I've been trying to capture the values when the results object is returned. But all I get is ?lat=&amp;amp;lon=&amp;nbsp; .&amp;nbsp; Here's the code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&amp;lt;script&amp;gt; 
          var geocoder;
          var map;
          
          function initMap() {            
            map = new google.maps.Map(document.getElementById('map'), {
              zoom: 10,
              center: {lat: 42.3853, lng: -71.8368}
            });
            
            {% for row in hubdb_table_rows(table_id, filter_params) %}           
              var marker_{{ row.hs_id }} = new google.maps.Marker({          
                  map: map,
                  position: {lat: {{ row.location.lat }}, lng: {{ row.location.lon }} }, 
                  icon: { scaledSize: {width: 20, height:20}, url: "https://cdn2.hubspot.net/hubfs/4764394/01012019_ARC_icon_svgs/ARC_map_150px_150px_navy_02.png" },
                  title: "{{ row.organization }}",
              });

              marker_{{ row.hs_id }}.addListener('click', function() {
                new google.maps.InfoWindow({
                    content: "&amp;lt;div&amp;gt; {{ row.organization }} &amp;lt;/div&amp;gt;"
                }).open(map, marker_{{ row.hs_id }});
              });
            {% endfor %}
            
            geocoder = new google.maps.Geocoder();
            
            document.getElementById('address-submit').addEventListener('click', function() {
              codeAddress(geocoder, map);
            });

           
            function codeAddress(geocoder, resultsMap) {
              var address = document.getElementById('address').value;
              geocoder.geocode( {'address' : address}, function(results, status) {
                if (status ==  'OK') {
                  resultsMap.setCenter(results[0].geometry.location);
                  {% set lat_param = lat_param ~ "&amp;amp;latitude=" + results[0].geometry.location.lat|urlencode %}
                  {% set lon_param = lon_param ~ "&amp;amp;longitude=" + results[0].geometry.location.lat|urlencode %}

                  var marker_origin = new google.maps.Marker({
                    map: resultsMap,
                    title: "You are here.",
                    icon: { scaledSize: {width:25, height:25}, url: "https://cdn2.hubspot.net/hubfs/4764394/01012019_ARC_icon_svgs/ARC_map_150px_150px_green_02.png"},
                    position: results[0].geometry.location,
                    zoom: 14,
                  });
                  
                } else {
                  alert('Geocode was not successful for the following reason: ' + status)
                }
              });
            }
          }
        &amp;lt;/script&amp;gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I figured once I was able to do that, then I could rewrite to the full feature which should use one submit button, so people could filter on the additional options too, and then the return would recenter the map on their address and sort the facility cards by closest first.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does this help you help me? What else can I provide? Should I add you to the project so you can look at my (super-messy, unrefactored) module?&lt;/P&gt;</description>
      <pubDate>Fri, 31 May 2019 18:22:42 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Accessing-geocoded-results-in-hubl/m-p/272921#M12456</guid>
      <dc:creator>JAbella</dc:creator>
      <dc:date>2019-05-31T18:22:42Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing geocoded results in hubl</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Accessing-geocoded-results-in-hubl/m-p/273009#M12460</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/73904"&gt;@JAbella&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You are providing a search a search for your users to find nearby locations?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can do this with:&lt;/P&gt;
&lt;P&gt;1. google autocomplete api&amp;nbsp; &amp;nbsp;&lt;A href="https://developers.google.com/maps/documentation/javascript/places-autocomplete" target="_blank"&gt;https://developers.google.com/maps/documentation/javascript/places-autocomplete&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. grab the lat/lon values from the autocomplete function you create.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. on submit, use a javascript redirect back to the page, but with the latitude and longitude in the the url as query params.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;4. Use HubL request variables to retrieve the params from the url&lt;/P&gt;
&lt;PRE&gt;url : www.url.com?latitude=12344.322

hubl: {{ request.query_dict.latitude }}&lt;/PRE&gt;
&lt;P&gt;5. use the hubl tokens for the the latitude and longitude to filter the results.&lt;/P&gt;</description>
      <pubDate>Sat, 01 Jun 2019 06:56:43 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Accessing-geocoded-results-in-hubl/m-p/273009#M12460</guid>
      <dc:creator>Jsum</dc:creator>
      <dc:date>2019-06-01T06:56:43Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing geocoded results in hubl</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Accessing-geocoded-results-in-hubl/m-p/273184#M12472</link>
      <description>&lt;P&gt;Thanks again, Jsum. &lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/73904"&gt;@JAbella&lt;/a&gt;: just wanted to link you to some relevant HubL documentation. We have some documentation on the HTTP request variables here: &lt;A href="https://designers.hubspot.com/docs/hubl/hubl-supported-variables#http-request-variables" target="_blank"&gt;https://designers.hubspot.com/docs/hubl/hubl-supported-variables#http-request-variables&lt;/A&gt;. So like Jsum suggested, you can pull the query string parameters from a dict created at {{ request.query_dict }} . I'd also suggest reading our article about using the Developer Info tab: &lt;A href="https://designers.hubspot.com/docs/hubl/how-to-use-developer-info-on-cos-pages" target="_blank"&gt;https://designers.hubspot.com/docs/hubl/how-to-use-developer-info-on-cos-pages&lt;/A&gt;. It can help in terms of finding HubL variables that you can use. I hope that helps.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jun 2019 16:06:40 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Accessing-geocoded-results-in-hubl/m-p/273184#M12472</guid>
      <dc:creator>lscanlan</dc:creator>
      <dc:date>2019-06-03T16:06:40Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing geocoded results in hubl</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Accessing-geocoded-results-in-hubl/m-p/280248#M12923</link>
      <description>&lt;P&gt;Thank you,&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/3688"&gt;@Jsum&lt;/a&gt;! Really appreciate your tips and the steps. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After playing with the Autocomplete api, I figured out how to make the geocoding api work, and create the params.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2019 18:47:36 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Accessing-geocoded-results-in-hubl/m-p/280248#M12923</guid>
      <dc:creator>JAbella</dc:creator>
      <dc:date>2019-07-11T18:47:36Z</dc:date>
    </item>
  </channel>
</rss>

