ince it is something you will probably do quite often. You should make
add a "clear" function to the MVCArray.


  google.maps.MVCArray.prototype.clear = function (){
    // work backward should be faster
    for(var i=this.getLength(); i>0; this.removeAt(--i)) {};
  }
.....
  myMvcArray.clear();
  myMvcArray.push(new google.maps.LatLng(40.6, -73.9));
  myMvcArray.push(new google.maps.LatLng(53.4,117.0)); // will show a
line from NewYork to Siberia


  Pop is more expensive operation, then removeAt.

  I also get the length once.

  You have to watch out for the order/index which you delete or else
you have a half empty array.
  try "myMvcArray.removeAt(0);" or go backward

On Jun 15, 1:15 pm, Chad Killingsworth
<[email protected]> wrote:
> Standard JavaScript array methods/operations won't work on MVCArrays.
>
> Try:
>
> while(points.getLength() > 0) points.pop();
>
> Chad Killingsworth
>
> On Jun 15, 11:48 am, Nathan Raley <[email protected]> wrote:
>
>
>
> > Your second one is what I use to clear mine out.
>
> > On Tue, Jun 15, 2010 at 11:44 AM, Jason Sanford 
> > <[email protected]>wrote:
>
> > > Just a quick guess but would this work:
>
> > > myMvcArray.forEach(function(item,index){
> > >   myMvcArray.removeAt(index);
> > > });
>
> > > If not how about:
>
> > > for (i=0;i<myMvcArray.getLength();i++){
> > >   myMvcArray.removeAt(i);
> > > }
>
> > > I don't know if these work but glancing at the docs (
> > >http://code.google.com/apis/maps/documentation/javascript/reference.h...)
> > > that's what I would guess.
>
> > > On Tue, Jun 15, 2010 at 12:29 PM, Pil <[email protected]> wrote:
>
> > >> On Jun 15, 6:05 pm, Nathan Raley <[email protected]> wrote:
> > >> > Did you try points = [];?
>
> > >> Yes, this doesn't work when I say
>
> > >> poly.setPath(points);
>
> > >> i.e. nopolylinewill appear. When I use a MVCArray all works well.
> > >> The MVCArray should be shared alternately between aPolylineand a
> > >> Polygon. This all works well - but I found no way to set the elements
> > >> of the MVCArray to 0.
>
> > >> --
> > >> You received this message because you are subscribed to the Google Groups
> > >> "Google Maps JavaScript API v3" group.
> > >> To post to this group, send email to
> > >> [email protected].
> > >> To unsubscribe from this group, send email to
> > >> [email protected]<google-maps-js-api-v3%2B
> > >>  [email protected]>
> > >> .
> > >> For more options, visit this group at
> > >>http://groups.google.com/group/google-maps-js-api-v3?hl=en.
>
> > >  --
> > > You received this message because you are subscribed to the Google Groups
> > > "Google Maps JavaScript API v3" group.
> > > To post to this group, send email to
> > > [email protected].
> > > To unsubscribe from this group, send email to
> > > [email protected]<google-maps-js-api-v3%2B
> > >  [email protected]>
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/google-maps-js-api-v3?hl=en.- Hide quoted 
> > >text -
>
> - Show quoted text -

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" 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-js-api-v3?hl=en.

Reply via email to