# \[Solved\] Adding marker when clicking on map

**URL:** https://community.thunkable.com/t/solved-adding-marker-when-clicking-on-map/142183
**Category:** Questions about Thunkable X
**Tags:** solved
**Created:** [July 13, 2019, 11:09pm UTC](https://community.thunkable.com/t/solved-adding-marker-when-clicking-on-map/142183 "2019-07-13T23:09:21Z")
**Posts on this page:** 19
**Page:** 1

<div class="post-metadata">

### Author: ![Mr\_Nicolas](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/mr_nicolas/32/34033_2.png) [@Mr\_Nicolas](https://community.thunkable.com/u/Mr_Nicolas)
#### Post date: [July 13, 2019, 11:09pm UTC](https://community.thunkable.com/t/solved-adding-marker-when-clicking-on-map/142183/1 "2019-07-13T23:09:22Z")

</div>

hello dear community

i want to add marker when user touch on the map. but cannot this. help me please

---

<div class="post-metadata">

### Author: ![BlueWhaleYT](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/bluewhaleyt/32/28437_2.png) [@BlueWhaleYT](https://community.thunkable.com/u/BlueWhaleYT)
#### Post date: [July 14, 2019, 3:08am UTC](https://community.thunkable.com/t/solved-adding-marker-when-clicking-on-map/142183/2 "2019-07-14T03:08:13Z")

</div>

Hi there,  
Have you seen this way?  
[https://docs.thunkable.com/map#add-marker](https://docs.thunkable.com/map#add-marker)  
Thanks.😊

---

<div class="post-metadata">

### Author: ![Mr\_Nicolas](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/mr_nicolas/32/34033_2.png) [@Mr\_Nicolas](https://community.thunkable.com/u/Mr_Nicolas)
#### Post date: [July 14, 2019, 6:51am UTC](https://community.thunkable.com/t/solved-adding-marker-when-clicking-on-map/142183/3 "2019-07-14T06:51:01Z")

</div>

This option add marker to my current location, but i need to ability adding marker on the map where user want (by touching)

---

<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: [July 14, 2019, 7:20am UTC](https://community.thunkable.com/t/solved-adding-marker-when-clicking-on-map/142183/4 "2019-07-14T07:20:56Z")

</div>

Hi,

In the onPress map block, use these blocks to get the coordinates for the marker. To the right of these blocks you need to attach the green block “coordinate”

![%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/c/7/c791d3913f992f7c71ada4d1f6509df5a47acc63.png)

---

<div class="post-metadata">

### Author: ![Mr\_Nicolas](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/mr_nicolas/32/34033_2.png) [@Mr\_Nicolas](https://community.thunkable.com/u/Mr_Nicolas)
#### Post date: [July 15, 2019, 10:24am UTC](https://community.thunkable.com/t/solved-adding-marker-when-clicking-on-map/142183/5 "2019-07-15T10:24:01Z")

</div>

Thank you very much for your response! I will try and share result with you.  
Thank you again!

---

<div class="post-metadata">

### Author: ![Mr\_Nicolas](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/mr_nicolas/32/34033_2.png) [@Mr\_Nicolas](https://community.thunkable.com/u/Mr_Nicolas)
#### Post date: [July 15, 2019, 8:51pm UTC](https://community.thunkable.com/t/solved-adding-marker-when-clicking-on-map/142183/6 "2019-07-15T20:51:52Z")

</div>

it is the solution! THANK YOU!

---

<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 13, 2019, 6:43pm UTC](https://community.thunkable.com/t/solved-adding-marker-when-clicking-on-map/142183/7 "2019-10-13T18:43:06Z")

</div>

Maybe I am doing it wrong but it does not work for me - nothing happening “ontouch” 😕

 ![32](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/4/24bce5e5bbfef923c6fa22ded021deb7a71b27f6.png)  
I was really happy to finally find this solution to create markers on Touch since Thunkable wasn’t able to include this feature in more than a year ☹

---

<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 13, 2019, 7:15pm UTC](https://community.thunkable.com/t/solved-adding-marker-when-clicking-on-map/142183/8 "2019-10-13T19:15:31Z")

</div>

Update: I realized some really weird behavior here. To test if the coordinates were returned properly I used an alert to show me what was returned. If I used the blocks for latitude alone or longitude alone it returned something but no matter what - as soon as I added both of the “get property” block combinations in the do section it would always stop working at all (not even continuing to the further blocks).

I guess that might also be the reason why I don’t get any marker to show up. Ideas how to solve this?

 ![24](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/5/2/52d72d9d114a937816770b2fef68b46bd4e281c9.png)

---

<div class="post-metadata">

### Author: ![CBVG](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/cbvg/32/32401_2.png) [@CBVG](https://community.thunkable.com/u/CBVG)
#### Post date: [October 13, 2019, 8:27pm UTC](https://community.thunkable.com/t/solved-adding-marker-when-clicking-on-map/142183/9 "2019-10-13T20:27:15Z")

</div>

Perhaps you are dealing with a bug in the system, in that the ‘coordinate’ exists only for a single access.  
If this is the case, a work around would be to save the coordinate in a local variable, so that it could be accessed on your own terms.  
And since you always extract coordinate of nativeEvent, might as well save THAT instead, so you would have an object with only longitude and latitude properties, thus saving the need to re-extract to that level.

---

<div class="post-metadata">

### Author: ![domhnallohanlon](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/domhnallohanlon/32/29554_2.png) [@domhnallohanlon](https://community.thunkable.com/u/domhnallohanlon)
#### Post date: [October 21, 2019, 12:58am UTC](https://community.thunkable.com/t/solved-adding-marker-when-clicking-on-map/142183/10 "2019-10-21T00:58:07Z")

</div>

@Chris @CBVG, I ran into the same thing when creating this tutorial app for the map component, but used a variable instead to get everything working:

> [@Cartographr: How to work with the Map Component](http://community.thunkable.com/t/cartographr-how-to-work-with-the-map-component/230549):
>
> Click to Add Markers One request we hear from Thunkers is the ability to tap on the map component and then add a marker to the location that was just tapped. In this first example we’ll learn how to do just that. Map1.onPress This is the event we need to understand to make everything work. The onPress event has two outputs, coordinate and position - but other than the names of these outputs we don’t know much more about them. Since coordinate seems like the most promising, let’s take a closer l…

---

<div class="post-metadata">

### Author: ![Giuseppe\_Geppo\_Catta](https://avatars.discourse-cdn.com/v4/letter/g/2acd7d/32.png) [@Giuseppe\_Geppo\_Catta](https://community.thunkable.com/u/Giuseppe_Geppo_Catta)
#### Post date: [November 29, 2019, 1:43pm UTC](https://community.thunkable.com/t/solved-adding-marker-when-clicking-on-map/142183/11 "2019-11-29T13:43:50Z")

</div>

Hi, I was looking for this solution, but when I found it, it seems not working to me.  
If I Get only latitude, it works  
If i get only longitude, it works  
But If i place them into a join it doesn’t return nothing.  
In the same join, if I disconnect latitude or longitude I get the remaining value. If both, no results.  
What could be the problem?

---

<div class="post-metadata">

### Author: ![CBVG](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/cbvg/32/32401_2.png) [@CBVG](https://community.thunkable.com/u/CBVG)
#### Post date: [November 29, 2019, 2:51pm UTC](https://community.thunkable.com/t/solved-adding-marker-when-clicking-on-map/142183/12 "2019-11-29T14:51:01Z")

</div>

Can you show your blocks?

---

<div class="post-metadata">

### Author: ![Giuseppe\_Geppo\_Catta](https://avatars.discourse-cdn.com/v4/letter/g/2acd7d/32.png) [@Giuseppe\_Geppo\_Catta](https://community.thunkable.com/u/Giuseppe_Geppo_Catta)
#### Post date: [November 29, 2019, 3:11pm UTC](https://community.thunkable.com/t/solved-adding-marker-when-clicking-on-map/142183/13 "2019-11-29T15:11:46Z")

</div>

Sure,  
in pic#1 no navigation to screen2  
in pic#2 it goes to screen2 without any problem if i get only longitude or only latitude  
in pic#3 a solution I just found. but I can’t figure out why it works and not the pic#1  
 ![err_coord_1](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/3/1/31f1a4222c842219e1e363756fd83817b31b2728.png)

 ![err_coord_2](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/6/8/6806c1769b2f5fea5bcc90936e25bd20ac8bc0bb.png) ![err_coord_3](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/5/9/59777b68f281f109efcd5f9827ea98fdc2929535.png)

---

<div class="post-metadata">

### Author: ![domhnallohanlon](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/domhnallohanlon/32/29554_2.png) [@domhnallohanlon](https://community.thunkable.com/u/domhnallohanlon)
#### Post date: [November 29, 2019, 5:29pm UTC](https://community.thunkable.com/t/solved-adding-marker-when-clicking-on-map/142183/14 "2019-11-29T17:29:47Z")

</div>

@Giuseppe_Geppo_Catta

I was going to suggest you use an approach like #3 as that will work.

As a best practice, you should store the `coordinate` value in a variable and the work with the variable.

This is the method outlined in our tutorial here:

> [@\[Solved\] Adding marker when clicking on map](http://community.thunkable.com/t/solved-adding-marker-when-clicking-on-map/142183/10):
>
> @Chris @CBVG, I ran into the same thing when creating this tutorial app for the map component, but used a variable instead to get everything working:

---

<div class="post-metadata">

### Author: ![CBVG](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/cbvg/32/32401_2.png) [@CBVG](https://community.thunkable.com/u/CBVG)
#### Post date: [November 29, 2019, 6:14pm UTC](https://community.thunkable.com/t/solved-adding-marker-when-clicking-on-map/142183/15 "2019-11-29T18:14:51Z")

</div>

I have a hunch that this may be due to an over-active garbage collection in the system, i.e. something that is beyond the control of users to fix (but possibly something that Thunkable should be looking into).  
As you probably know, X Thunkable has the capability of creating new objects, and each object created takes memory space. With this comes the need to occasionally clean up the memory of objects that are no longer needed, and this is where possibly the problem may be. If the memory management is overly agressive, it may label any access to the ‘coordinate’ as the one that identifies as “you’ve seen this already, so you do not need anymore”. Normally, such labeling should wait until the END of the .onPress block.  
Therefore, your alternative then is to take your single access opportunity to duplicate the information in a form that is less volatile, that will remain at least until YOU decide you are finished with it.  
That is what is happening in your 3rd approach; the whole coordinate property of nativeEvent of coordinate is duplicated in your own ‘coord’ variable, giving you the opportunity to access at your leisure, since that object you define will not be considered garbage until the app itself has ended.

But that is still clearly a “bug” from a programmer and user’s perspective.

---

<div class="post-metadata">

### Author: ![Deluxe](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/deluxe/32/30016_2.png) [@Deluxe](https://community.thunkable.com/u/Deluxe)
#### Post date: [November 29, 2019, 9:54pm UTC](https://community.thunkable.com/t/solved-adding-marker-when-clicking-on-map/142183/16 "2019-11-29T21:54:52Z")

</div>

This maybe?

> <https://github.com/thunkable/thunkable-issues/issues/210>
>
> Ok so this is simple to explain. On Thunkable X companion for Android, when I do this:
> ...the two labels are getting...

---

<div class="post-metadata">

### Author: ![11fe73d2cc8e45](https://avatars.discourse-cdn.com/v4/letter/1/82dd89/32.png) [@11fe73d2cc8e45](https://community.thunkable.com/u/11fe73d2cc8e45)
#### Post date: [December 15, 2019, 3:55pm UTC](https://community.thunkable.com/t/solved-adding-marker-when-clicking-on-map/142183/17 "2019-12-15T15:55:04Z")

</div>

Can you please show me the whole block or share a version of this project??

Thanks

---

<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: [December 15, 2019, 4:01pm UTC](https://community.thunkable.com/t/solved-adding-marker-when-clicking-on-map/142183/18 "2019-12-15T16:01:56Z")

</div>

Link to which project are you interested in?

Best regards, Alex  
[ACtech demo project](https://x.thunkable.com/projects/5d70f93f8a62b4079eedaff2/project/properties/designer/)  
[Thunkable X Basic Programming Course](http://droidscript.ru/main/title_ds15.php)  
[Block Reference](http://droidscript.ru/main/statyi/thunkableios_blockhelper.php)  
[Component Reference](http://droidscript.ru/main/statyi/thunkableios_objects.php)  
[Bug tracker](https://x.thunkable.com/projects/5dbd5243a77acad1b26f851f/project/properties/designer/)  
[Polipaint](https://x.thunkable.com/projects/5db56632a1e1fcefd3932db7/project/properties/designer/)  
[Map canvas](https://x.thunkable.com/projects/5db56eadb7c037443fadb222/project/properties/designer/)  
[Method Inspector](https://x.thunkable.com/projects/5d9310fcdf0a8f208bd2bb11/openProject/designer)  
[Performance](https://x.thunkable.com/projects/5db93ebab8e0fc9c685b3477/project/properties/designer/)

---

<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, 11:46am UTC](https://community.thunkable.com/t/solved-adding-marker-when-clicking-on-map/142183/19 "2024-11-08T11:46:23Z")

</div>


