How exactly does one DO that so it is acceptable to GPolygon()?  I
swapped out an array of GLatLng with an array like this:

[{"x":"-85.9375839233398440","y":"39.9271392822265630"},
{"x":"-85.9373779296875000"},"y":"39.9264373779296870"]

(this is shortened to two points for illustration purposes) in my call
to GPolygon() and I get nothing at all, despite it working perfectly
(although slowly) with an array of GLatLng.

don


On Nov 26, 8:05 pm, bratliff <[email protected]> wrote:
> On Nov 26, 10:30 pm, "Michael Geary" <[email protected]> wrote:
>
> Thanks Mike,
>
> > 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.
>
> 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.
>
>
>
>
>
> > PolyGonzo uses a tight inner loop for the points within a single polygon,
> > with separate inner loops for IE (generating VML directly) and other
> > browsers (using Canvas). It makes no JavaScript function calls in these
> > inner loops, and precalculates as much of the coordinate conversion as
> > possible outside the inner loop. This conversion is hard coded to use
> > Mercator at the moment.
>
> > In addition, all of the variables used in the inner loop are local
> > variables. There's an eachShape() function in polygonzo.js that has a
> > surprisingly long list of function parameters. These parameters are there so
> > that the references to them are truly local variables. This saves on name
> > lookups in the inner loop.
>
> > 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.
>
> The conversion from float to string is done automatically.
>
> Is your own "round" function (interpreted) more efficient than the
> built-in "Math.round" function (compiled) ?
>
> > The use of "vml[iVml++] = ...." in the IE version is itself one of the
> > optimizations. It's quite a bit faster than the "vml.push(...);" that I
> > would prefer to use.
>
> Interesting.  I like to do the same thing using the loop counter for
> an index but it is simply dumb luck.
>
> > > 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. The
> > particular form that I used in polymap.js and testmap.js is popular in
> > jQuery code:
>
> 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.- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
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