I am developing an application to design routes from data collected by an embedded GPS system. My server receives coordinates of different devices and I am writing this to my database.
What helped me a lot was this question in StackOverflow -en.
In this question I found the code of my application as well as a small correction to fit my needs.
My question is how to remove Map Markers.
In the image below I have a result coming from running my application:
Iwouldliketomakeitasshownintheimageeditedbelow(Nointermediatemarkers,onlystartandendmarkers):
During my research to solve this problem I found several possible solutions, among which I found plausible I found this, which is to add the following code to remove all markers.
for (i = 0;i < markers.length;i++) {
markers[i].setMap(null);
}
I know that with changes in the variable i
that could start with i = 1
and condition i <= markers.length
it might be possible to preserve the start and end markers, but I do not understand why this is not removing markers.