title: Location verification in javascript (to identify user is in particular area )
body: <p>I am trying to implement something like below.</p>
  
  <p>When user comes to my page his location will be taken by clicking on button. If that location is valid based on defined location then further process will be done. If invalid it just shows a "try again" message and not proceed further.</p>
  
  <p>I tried with containLocation() method but it did not work for me</p>
  
  <p>Below is the code I have implemented (I just take location of user).</p>
  
  <p>What to do after this?</p>
  
  <pre class="lang-js prettyprint-override"><code>var x = document.getElementById("demo");
  
  function getLocation() {
    if (navigator.geolocation) {
      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>
  
  <pre class="lang-html prettyprint-override"><code>&lt;p&gt;Click the button to get your coordinates.&lt;/p&gt;
  
  &lt;button onclick="getLocation()"&gt;Try It&lt;/button&gt;
  
  &lt;p id="demo"&gt;&lt;/p&gt;
  </code></pre>
  
  
  
  <p><strong>this is picture representation what I want to do if my English is bad</strong>
  <a href="https://i.stack.imgur.com/QaVf0.png" rel="nofollow noreferrer">image</a></p>