> > From: Michael Geary
> > GPolygon goes through multiple function calls for every point. You
> > have to create a GLatLng for each point, ang GPolygon converts each
> > lat/lng to a pixel coordinate by going through quite a bit
> of general purpose code.
> From: bratliff
> It baffles me why people use an array of [new
> GLatLng(Lat,Lon)] objects instead of an array of
> [{x:Lon,y:Lat}] objects to build a GPoly object. The speed
> advantage of GPoly.fromEncoded() vanishes with the later approach.
Aha! That is a good tip. I'd kind of wondered if you really had to construct
all those expensive GLatLng objects. The documentation doesn't really say
one way or the other.
> > Here's the innermost loop for IE:
> >
> > for( var iCoord = -1, coord; coord = coords[++iCoord]; ) {
> > vml[iVml++] = round( coord[0] * 10 );
> > vml[iVml++] = ',';
> > vml[iVml++] = round( coord[1] * 10 );
> > vml[iVml++] = ' l ';
> > }
> I might have joined elements in the outer loop but
> concatenated elements in the inner loop. I am surprised four
> elements incur much penalty.
>
> Concatenation degrades for long strings exceeding their
> allocated space.
>
> str+=round( coord[0] * 10 );
> str+=',';
> str+=round( coord[1] * 10 );
> str+=' l ';
>
> is slow but
>
> str[i++]=round( coord[0] * 10 )+','+round( coord[1] * 10 )+' l ';
>
> ought to be fast.
I just tested it, and interestingly enough, that version takes about twice
as long as the current PolyGonzo code.
> Is your own "round" function (interpreted) more efficient
> than the built-in "Math.round" function (compiled) ?
It *is* the native Math.round function, just a local reference to it.
In theory, this should speed things up by avoiding some name lookups. But I
just tried a quick test and didn't notice any measurable difference in IE or
Firefox.
> > > For my own JS enlightenment, I am not sure I
> > > understand the purpose of the unnamed / anonymous
> > > "()" function. Is it to keep clutter out of the global
> > > namespace ? I believe Google is using a similar trick
> > > with their classic loader. Do you anticipate a conflict ?
> > Yes, that's precisely what it's for - to create a local
> > namespace...
> I have been looking for a way to avoid namespace pollution.
> I was afraid to redefine the "()" function. Google's
> "main.js" already uses it.
There's no function being redefined here. Is that the potential conflict you
were asking about - the fact that both PG and Google do something similar?
That's no problem at all. Each anonymous function is independent of any
others.
-Mike
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---