# Latitude and longitude

**URL:** <https://forum.inductiveautomation.com/t/latitude-and-longitude/82524>\
**Category:** Ignition\
**Tags:** scripting, ignition81, perspective\
**Created:** [November 30, 2023, 11:19am UTC](https://forum.inductiveautomation.com/t/latitude-and-longitude/82524 "2023-11-30T11:19:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Purushothaman\_R](https://avatars.discourse-cdn.com/v4/letter/p/8797f3/32.png) [@Purushothaman\_R](https://forum.inductiveautomation.com/u/Purushothaman_R)\
**Post date:** [November 30, 2023, 11:19am UTC](https://forum.inductiveautomation.com/t/latitude-and-longitude/82524/1 "2023-11-30T11:19:53Z")

</div>

Hey guys, I have developed a form in which user will add device name, type etc.... so if user knows the latitude and longitude of sensor, user can mention directly into the text field component if not they can type the location name once search button is clicked user can see the options in the dropdown to choose the location. i need to fetch the latitude and longitude of the location to the respective text fields.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/8/f8628e4adb21200e8e7972c652e475e492f2a12c.png)

> coordinates = self.props.values()  
> #self.getSibling("NumericEntryField").props.value = coordinates["lat"]  
> #self.getSibling("NumericEntryField\_0").props.value = coordinates["lng"]  
> lat = coordinates[0]  
> system.perspective.print(lat)

You can see the output in the console i am getting the output of latitude and longitude i need to fetch those values into textfield i have tried my best to fetch it into textfield i am getting error stating typerror: list indices must be integers. Can you guys help me out kindly.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [November 30, 2023, 11:38am UTC](https://forum.inductiveautomation.com/t/latitude-and-longitude/82524/2 "2023-11-30T11:38:31Z")

</div>

> `coordinates = self.props.values()`

The property shown in the Property Editor is `value`, not `values`. Try,  
`coordinates = self.props.value`

That will return a **dictionary** , not a list, so you will need to refer to the elements using the key (and we can do it directly without introducing the `coordinates` variable):  
`lat = self.props.value.lat`  
`lng = self.props.value.lng`

Tips:

1. Use the Script Editor's Browse Properties button to pick properties. It can eliminate this type of error.
2. Post code as code, not as quotations. See below.

> [@Wiki - how to post code on this forum](https://forum.inductiveautomation.com/t/wiki-how-to-post-code-on-this-forum/77831):
>
> This thread is intended as a short help file for all those struggling to post formatted code on the forum. Posting formatted code on the forum (and most others) is as simple as selecting the code and pressing the \</\> button. It works the same as applying Bold or Italic styles to your document. It preserves indentation and applies syntax highlighting. [How to post code]

---

<div class="post-metadata">

**Author:** ![Purushothaman\_R](https://avatars.discourse-cdn.com/v4/letter/p/8797f3/32.png) [@Purushothaman\_R](https://forum.inductiveautomation.com/u/Purushothaman_R)\
**Post date:** [November 30, 2023, 12:30pm UTC](https://forum.inductiveautomation.com/t/latitude-and-longitude/82524/3 "2023-11-30T12:30:22Z")

</div>

Thank you @Transistor. It worked!. I will add my script in this way which you shared.Thanks a lot once again.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [November 30, 2023, 1:19pm UTC](https://forum.inductiveautomation.com/t/latitude-and-longitude/82524/4 "2023-11-30T13:19:08Z")

</div>

Good work.  
Please click the 'Solution' button under the answer that solves your problem. That will mark it solved on the main index.
