title: IBM Worklight - How to use Google Maps API
body: <p>My question is: How to use geolocation (using Google Maps API) in an IBM Worklight application.</p>
  
  <p>I am confused as to how can I make the application auto-detect my location using GPS?<br>
  Also how to make the application always track the user position in real time?</p>
  
  <p><strong>This is my JavaScript:</strong></p>
  
  <pre><code>var x=document.getElementById("demo");
  
  function getLocation()
    {
    if (navigator.geolocation)
      {
        alert("ya");
      navigator.geolocation.getCurrentPosition(showPosition);
      }
    else{x.innerHTML="Geolocation is not supported by this browser.";}
    }
  function showPosition(position)
    {
    x.innerHTML="Latitude: " + position.coords.latitude + 
    "&lt;br&gt;Longitude: " + position.coords.longitude;    
    }
  </code></pre>
  
  <p><strong>The HTML:</strong></p>
  
  <pre><code>&lt;!DOCTYPE HTML&gt;
  &lt;html&gt;
          &lt;head&gt;
              &lt;meta charset="UTF-8"&gt;
              &lt;title&gt;HTMLGeoLocation&lt;/title&gt;
              &lt;meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0"&gt;
              &lt;link rel="shortcut icon" href="images/favicon.png"&gt;
              &lt;link rel="apple-touch-icon" href="images/apple-touch-icon.png"&gt;
              &lt;link rel="stylesheet" href="css/HTMLGeoLocation.css"&gt;
              &lt;script&gt;window.$ = window.jQuery = WLJQ;&lt;/script&gt;
          &lt;/head&gt;
          &lt;body id="content" style="display: none;"&gt;
              &lt;!--application UI goes here--&gt;
              &lt;p id="demo"&gt;Click the button to get your coordinates:&lt;/p&gt;
  &lt;button onclick="getLocation()"&gt;Try It&lt;/button&gt;
              &lt;script src="js/initOptions.js"&gt;&lt;/script&gt;
              &lt;script src="js/HTMLGeoLocation.js"&gt;&lt;/script&gt;
              &lt;script src="js/messages.js"&gt;&lt;/script&gt;
          &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>