# Geolocation , i am not able to get latitude and longitude value

**URL:** <https://forum.inductiveautomation.com/t/geolocation-i-am-not-able-to-get-latitude-and-longitude-value/52393>\
**Category:** General Discussion\
**Tags:** ignition81, perspective\
**Created:** [October 27, 2021, 12:03pm UTC](https://forum.inductiveautomation.com/t/geolocation-i-am-not-able-to-get-latitude-and-longitude-value/52393 "2021-10-27T12:03:56Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![user95](https://avatars.discourse-cdn.com/v4/letter/u/bbe5ce/32.png) [@user95](https://forum.inductiveautomation.com/u/user95)\
**Post date:** [October 27, 2021, 12:03pm UTC](https://forum.inductiveautomation.com/t/geolocation-i-am-not-able-to-get-latitude-and-longitude-value/52393/1 "2021-10-27T12:03:56Z")

</div>

I create a button and map component, when i click on the button get the live location latitude values and longitude values and it map to the live location.  
self.session.props.geolocation.enabled=true  
a=self.session.props.geolocation.data.latitude //getting latitude value  
b=self.session.props.geolocation.data.longitude //getting latitude value  
self.getSibling(“Map”).props.init.center.lat=a //assign values to latitudee  
self.getSibling(“Map”).props.init.center.lng=b //assign values to longitude and the  
location is so in the map

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [October 27, 2021, 12:26pm UTC](https://forum.inductiveautomation.com/t/geolocation-i-am-not-able-to-get-latitude-and-longitude-value/52393/2 "2021-10-27T12:26:52Z")

</div>

whats not working, any logs / errors?  
does your device have geolocation…  
did you accept the prompt/granted permission?

---

<div class="post-metadata">

**Author:** ![user95](https://avatars.discourse-cdn.com/v4/letter/u/bbe5ce/32.png) [@user95](https://forum.inductiveautomation.com/u/user95)\
**Post date:** [October 27, 2021, 1:14pm UTC](https://forum.inductiveautomation.com/t/geolocation-i-am-not-able-to-get-latitude-and-longitude-value/52393/3 "2021-10-27T13:14:45Z")

</div>

I am not able to get latitude and longitude values. Geolocation is enable. I not get any popup for grant permission. In the button instead of getting live location, i give the latitude and longitude values it will map and show that location in map.  
a=self.session.props.geolocation.data.latitude //getting latitude value  
b=self.session.props.geolocation.data.longitude //getting latitude value  
If the value is store in the a and b latitude and longitude values, the module is work fine.

Is there any script for getting latitude and longitude values of current location

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [October 27, 2021, 1:28pm UTC](https://forum.inductiveautomation.com/t/geolocation-i-am-not-able-to-get-latitude-and-longitude-value/52393/4 "2021-10-27T13:28:58Z")

</div>

> [@user95](#):
>
> self.session.props.geolocation.enabled=true

You should turn this on in a different location. As it prompts the user to click something so this should happen before centering the map. (unless you are looping through it i guess)

you will have to check your browser if it allowes geolocation, This might be somewhere else in the settings turned off to.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/4/748b78ff6831d8a32a8af3011dbfac72df487922.png)

---

<div class="post-metadata">

**Author:** ![user95](https://avatars.discourse-cdn.com/v4/letter/u/bbe5ce/32.png) [@user95](https://forum.inductiveautomation.com/u/user95)\
**Post date:** [October 28, 2021, 5:18am UTC](https://forum.inductiveautomation.com/t/geolocation-i-am-not-able-to-get-latitude-and-longitude-value/52393/5 "2021-10-28T05:18:17Z")

</div>

The geolocation is turned on only, I think it may be code issue think so. Is there any way to get latitude and longitude values. Any script related this.

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [October 28, 2021, 7:09am UTC](https://forum.inductiveautomation.com/t/geolocation-i-am-not-able-to-get-latitude-and-longitude-value/52393/6 "2021-10-28T07:09:53Z")

</div>

the session props are the way to get the lat and lng.

But actualy what you are doing wont actually work anyways cuz you are setting up the “init” of the map, so it want “move” to it when you press the button.

you should bind the init values to the session props and set the location to true from the start

---

<div class="post-metadata">

**Author:** ![user95](https://avatars.discourse-cdn.com/v4/letter/u/bbe5ce/32.png) [@user95](https://forum.inductiveautomation.com/u/user95)\
**Post date:** [October 28, 2021, 8:45am UTC](https://forum.inductiveautomation.com/t/geolocation-i-am-not-able-to-get-latitude-and-longitude-value/52393/7 "2021-10-28T08:45:46Z")

</div>

I already try that one but its not getting lat and long values, if it is get means when click on the button, i bind the values to map

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [October 28, 2021, 8:46am UTC](https://forum.inductiveautomation.com/t/geolocation-i-am-not-able-to-get-latitude-and-longitude-value/52393/8 "2021-10-28T08:46:49Z")

</div>

im getting the values no problem so its probaly your device/browser that is blocking geolocation

---

<div class="post-metadata">

**Author:** ![user95](https://avatars.discourse-cdn.com/v4/letter/u/bbe5ce/32.png) [@user95](https://forum.inductiveautomation.com/u/user95)\
**Post date:** [October 28, 2021, 8:47am UTC](https://forum.inductiveautomation.com/t/geolocation-i-am-not-able-to-get-latitude-and-longitude-value/52393/9 "2021-10-28T08:47:36Z")

</div>

can u send the script, that you write in the button

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [October 28, 2021, 8:51am UTC](https://forum.inductiveautomation.com/t/geolocation-i-am-not-able-to-get-latitude-and-longitude-value/52393/10 "2021-10-28T08:51:23Z")

</div>

```auto
	lat = self.session.props.geolocation.data.latitude
	lng = self.session.props.geolocation.data.longitude
	
	system.perspective.print(lat)
	system.perspective.print(lng)

```

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/3/23f5a744a7a77e3872c1c86a291a411d4567792d.png)

works fine in chrome after enabling location. there really isnt much that can go wrong with the script xd

---

<div class="post-metadata">

**Author:** ![user95](https://avatars.discourse-cdn.com/v4/letter/u/bbe5ce/32.png) [@user95](https://forum.inductiveautomation.com/u/user95)\
**Post date:** [October 28, 2021, 8:54am UTC](https://forum.inductiveautomation.com/t/geolocation-i-am-not-able-to-get-latitude-and-longitude-value/52393/11 "2021-10-28T08:54:33Z")

</div>

okay thank you, I dont know why its not working on my script.  
self.session.props.geolocation.enabled=bool(1)  
a=self.session.props.geolocation.data.latitude  
b=self.session.props.geolocation.data.longitude  
self.getSibling(“Map”).props.init.center.lat=a  
self.getSibling(“Map”).props.init.center.lng=b

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [October 28, 2021, 8:55am UTC](https://forum.inductiveautomation.com/t/geolocation-i-am-not-able-to-get-latitude-and-longitude-value/52393/12 "2021-10-28T08:55:19Z")

</div>

because its not the script but your security settings.  
location can get blocked (else every website can track your location without permission… or atleast make it harder to track you cuz they can track you anyways but eh xd)

---

<div class="post-metadata">

**Author:** ![user95](https://avatars.discourse-cdn.com/v4/letter/u/bbe5ce/32.png) [@user95](https://forum.inductiveautomation.com/u/user95)\
**Post date:** [October 28, 2021, 8:57am UTC](https://forum.inductiveautomation.com/t/geolocation-i-am-not-able-to-get-latitude-and-longitude-value/52393/13 "2021-10-28T08:57:03Z")

</div>

yes, I looking in every settings but i am not able to find where the issue is.

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [October 28, 2021, 8:57am UTC](https://forum.inductiveautomation.com/t/geolocation-i-am-not-able-to-get-latitude-and-longitude-value/52393/14 "2021-10-28T08:57:58Z")

</div>

what are you using to try it out? chrome? on windows or an andoird? apple?

---

<div class="post-metadata">

**Author:** ![user95](https://avatars.discourse-cdn.com/v4/letter/u/bbe5ce/32.png) [@user95](https://forum.inductiveautomation.com/u/user95)\
**Post date:** [October 28, 2021, 8:59am UTC](https://forum.inductiveautomation.com/t/geolocation-i-am-not-able-to-get-latitude-and-longitude-value/52393/15 "2021-10-28T08:59:12Z")

</div>

I am trying in chrome as well as android, it asking allow the location too

---

<div class="post-metadata">

**Author:** ![user95](https://avatars.discourse-cdn.com/v4/letter/u/bbe5ce/32.png) [@user95](https://forum.inductiveautomation.com/u/user95)\
**Post date:** [October 28, 2021, 8:59am UTC](https://forum.inductiveautomation.com/t/geolocation-i-am-not-able-to-get-latitude-and-longitude-value/52393/16 "2021-10-28T08:59:49Z")

</div>

I allow the location till, its not working

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [October 28, 2021, 8:59am UTC](https://forum.inductiveautomation.com/t/geolocation-i-am-not-able-to-get-latitude-and-longitude-value/52393/17 "2021-10-28T08:59:56Z")

</div>

> [@user95](#):
>
> it asking allow the location too

then what is the problem? after that it should work

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [October 28, 2021, 9:00am UTC](https://forum.inductiveautomation.com/t/geolocation-i-am-not-able-to-get-latitude-and-longitude-value/52393/18 "2021-10-28T09:00:42Z")

</div>

> [@user95](#):
>
> its not working

your script in the button wont do anything tho, setting the init values after the map already has been loaded does nothing.. like i said, bind them to the init props of the map

---

<div class="post-metadata">

**Author:** ![user95](https://avatars.discourse-cdn.com/v4/letter/u/bbe5ce/32.png) [@user95](https://forum.inductiveautomation.com/u/user95)\
**Post date:** [October 28, 2021, 9:00am UTC](https://forum.inductiveautomation.com/t/geolocation-i-am-not-able-to-get-latitude-and-longitude-value/52393/19 "2021-10-28T09:00:58Z")

</div>

yeah its now working , i try it in android. Thank you bro

---

<div class="post-metadata">

**Author:** ![user95](https://avatars.discourse-cdn.com/v4/letter/u/bbe5ce/32.png) [@user95](https://forum.inductiveautomation.com/u/user95)\
**Post date:** [October 28, 2021, 9:02am UTC](https://forum.inductiveautomation.com/t/geolocation-i-am-not-able-to-get-latitude-and-longitude-value/52393/20 "2021-10-28T09:02:38Z")

</div>

I cleared the cache memory and i execute, its working fine now. Thank you victordcq

[Next page](https://forum.inductiveautomation.com/t/geolocation-i-am-not-able-to-get-latitude-and-longitude-value/52393.md?page=2)
