How can i Show Current Location in Website

I am new to mendix Platform , i want to show current location in my application , kindly give some instruction or guideline for (How can i do it).
2 answers

Hi Surya,


You probably want the location of the user in the browser. This can be achieved with the HTML Geolocation API.


var x = document.getElementById("demo");
function getLocation() {
  if (navigator.geolocation) {
  } else {
    x.innerHTML = "Geolocation is not supported by this browser.";

function showPosition(position) {
  x.innerHTML = "Latitude: " + position.coords.latitude +
  "<br>Longitude: " + position.coords.longitude;


To include this in Mendix, you need to add a button to your page.

Set as onclick action a Nanoflow.

This nanoflow can trigger an JavaScript Action.

In this Javascript Action, you can use the Javascript snippet as shown above.


Take a look at the Nanoflow Commons module (available in the Marketplace if it’s not already in your project).

This provides the GetCurrentLocation action which can return the device’s current location in an Entity you can use from a nanoflow.

I hope this helps.