Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I also tried something similar in Wakanda, but it seems the browser is blocking the call due to CORS (cross-reference of domains), so I used the below approach.</p> <p>Wakanda client --> Wakanda Server --> Google Maps API --> Back to Wakanda Server --> Back to Wakanda client</p> <p><strong>Client side code:</strong></p> <pre class="lang-js prettyprint-override"><code>button1.click = function button1_click (event) { var address = $$("addressField").getValue(); address = encodeURI(address); // Make call to server response = $sources.businesses.getGeoCoordinates(address); address_info = JSON.parse(response); if (address_info &amp;&amp; address_info.status === "OK") { $$("business_latitude_field").setValue( address_info.results[0].geometry.location.lat ); $$("business_longitude_field").setValue( address_info.results[0].geometry.location.lng ); alert('We got latitude &amp; longitude of your address.'); } else { alert("Could not find latitude and longitude of your given address."); } } </code></pre> <p><strong>Server side code - Code of getGeoCoordinates public method in business data class</strong></p> <pre class="lang-js prettyprint-override"><code>function (address) { // Call google geocode service to convert given address into lat / long if (address) { var api_url = "http://maps.googleapis.com/maps/api/geocode/json?sensor=false&amp;address=" + address; xhr = new XMLHttpRequest(); xhr.open("GET", api_url); xhr.send(); var response = xhr.responseText; return response; } } </code></pre> <p>Hope it helps.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload