On Feb 17, 9:31 am, "h...@nnes" <[email protected]> wrote:
> Hi list, I'm not having a profound understanding about the API yet, so
> this might be only a minor mistake that drive me ... Argh. I'm trying
> to replace the Gdirections polyline by a custom one with different
> color and weight. So far this code is doing very well.
>
> poly = gdirs.getPolyline();
>  for (var i=0; i<poly.getVertexCount(); i++) {
>        polypoints.push(poly.getVertex(i));
>  }
>
>  map.addOverlay(new GPolyline(polypoints, "#000000",3,1));
>
> The problem is that I'm not able to remove this overlay using
>
> poly = gdirs.getPolyline();
>  for (var i=0; i<poly.getVertexCount(); i++) {
>        polypoints.push(poly.getVertex(i));
>  }
>
>  map.removeOverlay(new GPolyline(polypoints, "#000000",3,1));
>
> Did I get something wrong? Every help is highly appreciated!

Yes.  I would expect you to get an error doing that.  The line above
creates a new polyline, then attempts to remove it from the map.  If
fails as it hasn't been added to the map yet.  You need to keep a
reference to the one you already added to the map and use that as an
argument to the removeOverlay function.

If this doesn't help, please read and follow the posting guidelines:
http://groups.google.com/group/Google-Maps-API/web/suggested-posting-guidelines

  -- Larry


> Thanks, h...@nnes
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to