# \[Solved\] Get Lat and Lng from map press

**URL:** <https://community.thunkable.com/t/solved-get-lat-and-lng-from-map-press/282110>\
**Category:** Questions about Thunkable X\
**Tags:** solved\
**Created:** [June 19, 2019, 4:39pm UTC](https://community.thunkable.com/t/solved-get-lat-and-lng-from-map-press/282110 "2019-06-19T16:39:58Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![sysads](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/sysads/32/44975_2.png) [@sysads](https://community.thunkable.com/u/sysads)\
**Post date:** [June 19, 2019, 4:39pm UTC](https://community.thunkable.com/t/solved-get-lat-and-lng-from-map-press/282110/1 "2019-06-19T16:39:58Z")

</div>

Hi I was wondering how can I store the values of “lat” and “long” in a table?

Thanks

---

<div class="post-metadata">

**Author:** ![sysads](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/sysads/32/44975_2.png) [@sysads](https://community.thunkable.com/u/sysads)\
**Post date:** [June 20, 2019, 3:34pm UTC](https://community.thunkable.com/t/solved-get-lat-and-lng-from-map-press/282110/2 "2019-06-20T15:34:03Z")

</div>

Never mind, I finally did it. The mistake I made was that I did not treat the data from the event block as a text string.

All I did was create a list from the data and then split it using the “,”

---

<div class="post-metadata">

**Author:** ![sysads](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/sysads/32/44975_2.png) [@sysads](https://community.thunkable.com/u/sysads)\
**Post date:** [June 20, 2019, 3:46pm UTC](https://community.thunkable.com/t/solved-get-lat-and-lng-from-map-press/282110/3 "2019-06-20T15:46:04Z")

</div>

I spoke too soon, I just faced another issue. The coordinates are meant to be integers but since I am extracting the values a string, it does not work on map.

How can I convert them to Integers?

---

<div class="post-metadata">

**Author:** ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)\
**Post date:** [June 20, 2019, 4:10pm UTC](https://community.thunkable.com/t/solved-get-lat-and-lng-from-map-press/282110/4 "2019-06-20T16:10:24Z")

</div>

Try assigning a string to a variable block, and then use some suitable mathematical block to perform an operation on this variable, for example, add its value with the value 0.

---

<div class="post-metadata">

**Author:** ![sysads](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/sysads/32/44975_2.png) [@sysads](https://community.thunkable.com/u/sysads)\
**Post date:** [June 20, 2019, 4:16pm UTC](https://community.thunkable.com/t/solved-get-lat-and-lng-from-map-press/282110/5 "2019-06-20T16:16:48Z")

</div>

mama mia nice hack. That worked 🕺

---

<div class="post-metadata">

**Author:** ![7a808d888dc141](https://avatars.discourse-cdn.com/v4/letter/7/aeb1de/32.png) [@7a808d888dc141](https://community.thunkable.com/u/7a808d888dc141)\
**Post date:** [June 24, 2019, 6:52pm UTC](https://community.thunkable.com/t/solved-get-lat-and-lng-from-map-press/282110/6 "2019-06-24T18:52:43Z")

</div>

I was trying to make mine work but screen 3 doesn’t open with these blocks (starting from screen 2, clicking the callout on the map). I was trying to understand what data the “event” gives. Eventually I want to change screen3 based on a local database list (which restaurant is chosen from the map).

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/8/0/80d13b416bad613f5c1603270536b0fae6c80a92.png)

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/7/f/7f5fe4acb9e370a4c80fe8cd3836225b17bc0a14.png)

---

<div class="post-metadata">

**Author:** ![Mark](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/mark/32/18133_2.png) [@Mark](https://community.thunkable.com/u/Mark)\
**Post date:** [June 24, 2019, 9:51pm UTC](https://community.thunkable.com/t/solved-get-lat-and-lng-from-map-press/282110/7 "2019-06-24T21:51:55Z")

</div>

Please take a look at my previous post in this thread ([here](http://community.thunkable.com/t/map-component-event-block/73742/3?u=mark)) for some info on how to properly obtain longitude and latitude for the `onPress`, `onMarkerPress` and `onLongPress` event handlers of the Map component. Note that `onCalloutPress` appears to not work at all ☹

-Mark

---

<div class="post-metadata">

**Author:** ![7a808d888dc141](https://avatars.discourse-cdn.com/v4/letter/7/aeb1de/32.png) [@7a808d888dc141](https://community.thunkable.com/u/7a808d888dc141)\
**Post date:** [June 25, 2019, 7:44pm UTC](https://community.thunkable.com/t/solved-get-lat-and-lng-from-map-press/282110/8 "2019-06-25T19:44:41Z")

</div>

Thanks for your reply 🙂 Actually I got onCalloutPress to work with the below blocks. It does save the latitude value of a marker to the local storage. Next problem is how to do a vlookup formula using the latitude value in local\_db and returning another field in the spreadsheet. I can only find instructions if the choice is made in a list viewer… how to do that using a local storage value?

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/c/4c021430efb29c0f06ffd1459116c85a0263d9fe.png)

---

<div class="post-metadata">

**Author:** ![Mark](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/mark/32/18133_2.png) [@Mark](https://community.thunkable.com/u/Mark)\
**Post date:** [June 27, 2019, 7:03pm UTC](https://community.thunkable.com/t/solved-get-lat-and-lng-from-map-press/282110/9 "2019-06-27T19:03:41Z")

</div>

Frozen Aloha,

It’s not totally clear to me what you are trying to do. It seem as if you want to lookup a latitude value in one column of your local\_db and then return another column in the same row of that local\_db. Is that right?

By the way, I strongly suggest using [stored variables](https://docs.thunkable.com/variables) instead of the Local Storage component. It’s generally much easier to use. Here are some blocks which demonstrate how you can use them when the variable name (which is essentially the same as the key for the Local Storage component) is not necessarily fixed.

![50%20AM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/1/a/1a77bbf3e9163eb712c2e026a7accfb12930d009.png)

In the above example the `"test"` block could be replaced with something that is looked up or calculated dynamically.

-Mark

---

<div class="post-metadata">

**Author:** ![bymaho](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/bymaho/32/56102_2.png) [@bymaho](https://community.thunkable.com/u/bymaho)\
**Post date:** [September 21, 2019, 9:46pm UTC](https://community.thunkable.com/t/solved-get-lat-and-lng-from-map-press/282110/10 "2019-09-21T21:46:39Z")

</div>

[http://community.thunkable.com/uploads/thunkable1/original/3X/0/f/0f4258ff7aaf77d21cf18f7c832f32b02da78729.png](http://community.thunkable.com/uploads/thunkable1/original/3X/0/f/0f4258ff7aaf77d21cf18f7c832f32b02da78729.png)

These blocks doesnt work now. whats wrong?

 ![Ekran%20Al%C4%B1nt%C4%B1s%C4%B1](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/4/447aaf4be63e9e75b2e5433b3eede8d75d75b5ff.png)

but when I do below it gets longitude or latitude.

 ![Ekran%20Al%C4%B1nt%C4%B1s%C4%B12](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/7/b/7b701a35905e3d35b37ad42b53a2b3aac7739be4.png)

---

<div class="post-metadata">

**Author:** ![bymaho](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/bymaho/32/56102_2.png) [@bymaho](https://community.thunkable.com/u/bymaho)\
**Post date:** [September 21, 2019, 9:53pm UTC](https://community.thunkable.com/t/solved-get-lat-and-lng-from-map-press/282110/11 "2019-09-21T21:53:22Z")

</div>

![Ekran%20Al%C4%B1nt%C4%B1s%C4%B1](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/d/b/db586dcf75a52ba2396f6b9c698427c6cf4b0f13.png)  
With these blocks I can get longitude but I can’t get latitude. Why? or How can I get both? What is changed?

---

<div class="post-metadata">

**Author:** ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)\
**Post date:** [September 22, 2019, 7:56am UTC](https://community.thunkable.com/t/solved-get-lat-and-lng-from-map-press/282110/12 "2019-09-22T07:56:38Z")

</div>

Try this

![%D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/7/1/717772b7ea08e38aae19add938955c812b5b7402.png)

---

<div class="post-metadata">

**Author:** ![bymaho](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/bymaho/32/56102_2.png) [@bymaho](https://community.thunkable.com/u/bymaho)\
**Post date:** [September 22, 2019, 8:00am UTC](https://community.thunkable.com/t/solved-get-lat-and-lng-from-map-press/282110/13 "2019-09-22T08:00:18Z")

</div>

This works. Thanks.

---

<div class="post-metadata">

**Author:** ![rilo\_raspopo](https://avatars.discourse-cdn.com/v4/letter/r/e19b73/32.png) [@rilo\_raspopo](https://community.thunkable.com/u/rilo_raspopo)\
**Post date:** [October 21, 2019, 2:29am UTC](https://community.thunkable.com/t/solved-get-lat-and-lng-from-map-press/282110/14 "2019-10-21T02:29:55Z")

</div>

i have searching on all over thunkable community,  
actualy it’s same method… but why on mine is not working…  
i always got “null” on nativeEvent…

---

<div class="post-metadata">

**Author:** ![Chris](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/chris/32/78883_2.png) [@Chris](https://community.thunkable.com/u/Chris)\
**Post date:** [October 21, 2019, 7:11am UTC](https://community.thunkable.com/t/solved-get-lat-and-lng-from-map-press/282110/15 "2019-10-21T07:11:25Z")

</div>

There seems to be a bug that makes the Coordinate Object only available once. Therefor the solution of @actech is a workaround by storing the value and retrieving the information from the stored object afterwards 🙂

---

<div class="post-metadata">

**Author:** ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)\
**Post date:** [November 8, 2024, 12:08pm UTC](https://community.thunkable.com/t/solved-get-lat-and-lng-from-map-press/282110/16 "2024-11-08T12:08:38Z")

</div>


