I think I figured out the mistake. The array index variable I was
trying to use in javascript  is actually defined in JSP. So the
variable reference was failing. I changed my code to:

poly[<%out.println (b);%>] =   new GPolyline([...

It worked fine. I can now add and remove polylines. I would however be
interested in knowing, if there is a better way to add and remove
multiple polylines. I need multiple polylines so that I can give them
different colors.



On Oct 16, 10:18 am, funnycide <[EMAIL PROTECTED]> wrote:
> I am having trouble creating polyline arrays with Javascript. I want
> to do something like this on my JSP page:
>
> var poly = new Array();
>
> <% for (int b = 0; b < count; b++ ) { %>
>
> Poly[b] =   GPolyline([
> new GLatLng( <%out.println
> (String.valueOf(segments[b].getStart_Lat()));%>, <%out.println
> (String.valueOf(segments[b].getStart_Lon()));%>),
> new GLatLng( <%out.println (String.valueOf(segments[b].getEnd_Lat()));
> %>, <%out.println (String.valueOf(segments[b].getEnd_Lon()));%>),
> ], “#347C17”, 3, 1);
> map.addOverlay(poly[b]);
>
> <%}%>
>
> Each polyline has just two points (a start and end point). During each
> iteration of the “for loop” the code will fetch the next set of points
> from the database and draw it as a polyline. Now I want to identify
> each polyline with a unique name so that I can remove all of them when
> users no longer need to see it. If I do not have a unique name for the
> polyline I can only remove the last polyline I draw. Can someone help?
> Is there a better way to do this?
>
> Thanks!
--~--~---------~--~----~------------~-------~--~----~
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