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

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:

In your count with i loop, you’re cycling through all of the lat/lon values and adding markers. But the last row in the data source contains the most recent/current location. So in that loop, add an If block that says if i=length of app variable latlist then set pinColor to green (or whatever color)… else set pinColor to black (or whatever color).

Ok thanks for the info, I will try that out today.

Many Thanks Levi

So I add what you said here correct?

Yes.

I have tried what you have said but it does not let me connect the blocks together?

What Part of it am I doing wrong?

I have tried to do what you have said here, but it does not seem to let me add the colour part.

Or should I try something like this:

I have no idea if that will work.

You’re on the right track but if you read my post carefully, the If condition I suggested is i = length of app variable latlist. In that last screenshot, you have the If condition as length of i = app variable latlist. That won’t work.

The point of checking the value of i is that it’s the loop index. So when i is equal to the length of the list that you are looping through, that means you’ve reached the last item in the list.

So should I swap them around like this:

Nope, that’s still the same thing. You just switched the sides of the same equation. Here’s what you need:

Oh, Ok, Thanks, I will try that. :slight_smile:

Do I keep both of the blocks to place markers?

Yes. Because the if condition has two possible values: true or false. So if true, then you’ll create a marker with a green pin; and if false, then you’ll create a marker with a red pin.

Cool, thanks also do I need to change anything on the first marker to do with the lat and long, or should I keep them as they are on 0?

Screen Shot 2022-10-04 at 4.32.58 pm