How to remove marker on google maps once another marker is placed

What I mean is how could a make my app delete a marker after a certain time?

Store the current time in a stored variable using the seconds since 1970 block. Then, when the screen opens, check to see if the current time is greater than the stored time plus some value (for example, 86400 is the number of seconds in 24 hours). If it is, delete a marker.

1 Like

I will try that

I have tried that can you please send me a screenshot of what you did.

Many thanks Levi.

This might help you as this works fine for me.

1 Like

So typically what works best is for you to post a screenshot of what you’ve tried and explain what works or does not work and we can go from there.

1 Like

Ok I have tried what you have shown in the scene shot and it does not seem to work, Here is what I have:

All I want it to do is remove the previous markers in a way that there is only one marker on the screen at a time, that way the app does not get filled up with markers.

Many thanks Levi

“It does not seem to work.” Okay, what exactly happens then? Are the markers all deleted? Is one added?

And what is the Button1 Click supposed to do? Why do you have a forever loop with another loop inside it? Why do you need a loop at all?

The button is there so when you click it it will start to send location data to a spreadsheet.

What I have in This screenshot here:

What it does is inconsistently places the markers every 2- 15 seconds then just stops placing markers on the map at all!

Here is a screenshot of the datasheet:

Do you think I should just change the timer after the loop to make it longer between the times it sends location data?

The problem I have is that even if I slow down the number of times it pings the location, it is still hard to see the current location. I was thinking also I could make it so the current marker is a different colour, so it’s easy to identify the current location, if so what would be the best way of doing that?

Many Thanks, Levi

Are you still deleting markers? Because the latest screenshot does not include the block to do that.

Yeah, I removed that because it just placed a marker where ever I taped on the screen.

I am not sure what would be easier, to remove the pervious markers, or make the current location marker a different colour.

Have you tried different pin colors? You can use a variable in place of the color thumbnail and then assign values using rgba() strings or other methods. That allows you to – for example – assign colors from a list of colors so that each one is different. Or, for starters since it’s quicker, you could just assign a random color and test to see if that works.

Ok, I will try that out

Many Thanks Levi

That idea almost works except is it still difficult to work out which marker is the most recent from the user’s perspective, is there a way I can make the marker be green for example when it is the most recent, the change to red after a new marker has been placed?

Many Thanks Levi

Here is a photo of what it looks like now:

See how it looks a bit random.

Here is what the code looks like: