Little background. I have a navigation setup for when you click on a certain navigation item, it creates markers on the map. If you click on a different navigation
markers
You have to do polyline.setMap(null), that will remove the line from the map. Documentation.
polyline.setMap(null)