Latitude and longitude

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.

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.

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.
1 Like

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

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

2 Likes