Remove polyline

Posted by Fran Rod on Stack Overflow See other posts from Stack Overflow or by Fran Rod
Published on 2012-11-21T16:58:14Z Indexed on 2012/11/21 16:59 UTC
Read the original article Hit count: 209

I have the next code which show a path using a polyline. How can I remove it?

downloadUrl("myfile.asp", function(data) {
var xml = xmlParse(data);
var markers = xml.documentElement.getElementsByTagName("marker");
var path = [];
for (var i = 0; i < markers.length; i++) {
  var lat = parseFloat(markers[i].getAttribute("lat"));
  var lng = parseFloat(markers[i].getAttribute("lng"));
  var point = new google.maps.LatLng(lat,lng);
  path.push(point);
}//finish loop

var polyline = new google.maps.Polyline({
  path: path,
  strokeColor: "#FF0000",
  strokeOpacity: 1.0,
  strokeWeight: 2
});
polyline.setMap(map);

}); //end download url

I have tried it using the next function but I m not able to make it work.

 function removePath() {
 polyline.setMap(null)

}

© Stack Overflow or respective owner

Related posts about google-maps-api-3

Related posts about google-polyline

  • Remove polyline

    as seen on Stack Overflow - Search for 'Stack Overflow'
    I have the next code which show a path using a polyline. How can I remove it? downloadUrl("myfile.asp", function(data) { var xml = xmlParse(data); var markers = xml.documentElement.getElementsByTagName("marker"); var path = []; for (var i = 0; i < markers.length; i++) { var lat = parseFloat(markers[i]… >>> More