Can someone tell me why I can't remove my polylines with this code:
$("#chkRouteLines").click(function () {
var polyline = new google.maps.Polyline({
path: positions,
strokeColor: "#FF0000",
strokeOpacity: 1.0,
strokeWeight: 2,
visible: true
}); ;
if ($(this).is(':checked')) {
polyline.setMap(map);
} else {
polyline.setMap(null);
}
})
I found in the documentation of google maps api 3 that I need to do: setMap(null).. But this didn't work.
Thank you!