[Guide] Advance Get Current Location Without using Google Maps API & Location Sensor

Hello Koders

I have made a small script to get current location of user without using any location sensor (or) Google Maps API.

Hope everyone will like it.

Files to get location coordinates:
index.zip (485 Bytes)

<!DOCTYPE html>
<html>
<body>
<p>Get your coordinates.</p>
<p id="geo"></p>
<p id="url"></p>

<script>
  var x = document.getElementById("geo");
  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 + ",longitude:" + position.coords.longitude;
    document.getElementById("url").innerHTML = window.location.href + x.innerHTML;
    location.replace(url.innerHTML)
  }
</script>

</body>
</html>

Components & Blocks needed

  • Kodular Web Viewer Components:
    component_method(1)
    component_event(1)

  • Replace All Text Blocks to remove unnecessary texts form Url:
    text_replace_all

You can view below image.

All you need to upload html file in your website or server & load url by using Web Viewer block.

Thanks
Memu Magar

1 Like

And don’t forget to enable this settings on Web Viewer Properties:

1 Like

Thanks a Lot !!. Needed this. Google Maps and other Services, are too heavy

2 Likes