# Experimenting with HTML Geolocation API

**URL:** <https://discourse.nodered.org/t/experimenting-with-html-geolocation-api/16709>\
**Category:** Dashboard\
**Created:** [14 October 2019 21:32 UTC](https://discourse.nodered.org/t/experimenting-with-html-geolocation-api/16709 "2019-10-14T21:32:17Z")\
**Posts on this page:** 1\
**Showing post:** 21

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [29 February 2020 21:10 UTC](https://discourse.nodered.org/t/experimenting-with-html-geolocation-api/16709/21 "2020-02-29T21:10:19Z")

</div>

I don't use template nodes myself, but you could try to create a code snippet similar to [this](https://discourse.nodered.org/t/how-to-show-modal-dialog-in-template-node/611/5) one:

```auto
<md-button class="md-raised" ng-click="clicked(); sendMsg(msg)"

function sendMsg(msg) {
   if (navigator.geolocation) {
      var position = navigator.geolocation.getCurrentPosition();
      msg.latitude = position.coords.latitude;
      msg.longitude = position.coords.longitude;
      $scope.send(msg);
   } 
   else {
      alert("Geolocation is not supported by this browser.");
   }
}

```

Caution: I haven't tested this code !!!

---

_[View the full topic](https://discourse.nodered.org/t/experimenting-with-html-geolocation-api/16709)._
