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

Hello, I have so far made an app that will send the user’s location to google maps and display their location with a marker. The Problem I am having is that after a while the maps will be filled with lots of markers so it is hard to see where they are exactly here is an example:

As you can see it’s hard to see which marker you are. I would like to know how to make it delete previous markers and also how to make it refresh as well.

Any help would be greatly appreciated.

Does this help?

Thanks, It’s Helpful, I will try to experiment with some of the Info you sent me. I might need your help if I can’t get it to work.

Should I do something like: “After 2 markers are placed, remove the last one”, or something like that?
If so, how should I do that?

Many Thanks, Levi

I’m not sure what would be best. It’s not clear exactly what you’re wanting to happen in your app.

But if you do want to do that, it looks like you already have the lat/long pairs in lists so it shouldn’t be hard to just remove the first marker (for example) from the list.

1 Like

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.