[Solved] Adding marker when clicking on map

hello dear community

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

Hi there,
Have you seen this way?

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


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”



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

it is the solution! THANK YOU!

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

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 :frowning:

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?

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.

@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:

1 Like

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?

Can you show your blocks?

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



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:

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.

This maybe?

1 Like

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


Link to which project are you interested in?

Best regards, Alex
ACtech demo project
Thunkable X Basic Programming Course
Block Reference
Component Reference
Bug tracker
Map canvas
Method Inspector