> From: bratliff > > If you are really bored, you might try the following: > > ~~ (whatever * 10 + 5) > > "~~" performs integer truncation without a function call.
Interesting... Now that is a nice trick, thanks for the tip! It's funny, I use !! all the time to convert a value to a boolean type, but it never occurred to me to do something similar with ~~. In a quick test ~~ does seem a little faster than round(), at least if I leave out the +5 and just do the ~~( whaterver * 10 ) - which is fine since I can add that extra half pixel in the overall VML offset if I want it. > I just realized you may be able to skip rounding entirely. > Part of the Lat/Lon to x/y conversion involves shifting by > the zoom level. > Shifting a floating point number generates an integer result. > Rounding an integer does not change it. Actually I do need the rounding or truncating, because the conversion code divides instead of shifting. This allows PG to support in-between zoom levels, as used on this map: http://maps.google.com/help/maps/elections/#2008_election The 48 states on that map are at zoom level 3.812, Alaska is zoom level 0.721, and Hawaii is zoom level 3.79. The background map image is a static bitmap of a larger Google map, reduced in size in a photo editor with the AK and HI inset maps pasted in. (For anyone who may wonder about the TOS, yes I had permission from Google to do this - it was a project I did for them.) > Google's "main.js" defines the "()" function in the global > name space. Google's modular js files define different > cryptic names in the global name space. I thought I might be > playing with fire. Just to be clear, main.js doesn't define a "()" function, it defines an *anonymous* function, and you can have as many of those as you want. For example, this is perfectly legal: (function() { // code here })(); (function() { // more code here })(); It's just as if you had written: function a() { // code here } a(); function b() { // more code here } b(); -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 -~----------~----~----~----~------~----~------~--~---
