I want to clear all the markers when i click on a submit button. If i have a latitude and longitude and want to clear that marker, how can i do that. Also if i search any route i want to clear all the marker already loaded.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
For removing markers from the map after insertion, you should keep track of them with a global variable:
Then, whenever you add a marker to the map, add the marker to the
markersarray as well:To clear all the markers from the map, you could use the following:
If you’d like to simultaneously clear the
markersarray, you could use this:or this:
If you’d like to remove a marker based on latitude and longitude values as a
LatLngobject, you can use the following:If you simply have the coordinates, you can use the following: