Google SKY!

I thought I’d share this with anyone who hasn’t received it yet… Another example of what you could do with the maps interface and an alternative tile set like Jeff’s blue-marble map.

Starting today, astronomy enthusiasts can now view imagery of millions
of celestial objects online - without downloading software.

Google Sky brings the imagery and functionality of the popular Sky in
Google Earth feature to a web browser, making it easier than ever for
students, amateur astronomers and professionals alike to explore the
universe.

By simply pointing their browsers to http://sky.google.com, users can
browse, zoom and pan the sky, search for stars and galaxies, and link
to any place in the sky. The same layers that are available in Sky in
Google Earth, such as “Backyard Astronomy,” “Hubble Showcase” and
podcasts from the radio program Earth & Sky can be accessed by
clicking on an image strip that appears along the bottom of the page.

For instance, the part of the sky visible when a user first loads
sky.google.com shows the Cigar Galaxy (also known as Messier 82), one
of the most striking galaxies in the universe. Switching on the
infrared view of the sky using the “Spitzer Infrared Showcase” button
at the bottom of the screen will overlay images from NASA’s Spitzer
satellite and show how different the Cigar Galaxy appears in the
infrared. When the overlay is activated a slider will appear, letting
users move back and forth between infrared and optical light. To look
in more detail, users should zoom into the galaxy or enter its name in
the search box.

Rails 2 changed the way to_json works on ActiveRecord objects. Prior to Rails 2, to_json returned a hash of hashes — the first level hash had the key ‘attributes’, which in turn had another hash with your field name/values.

With Rails 2, calling to_json on an AR object just gives you a hash of field name/values. The new way is easier and more intuitive. However, in breaks our code in places where we use to_json to pass AR data into JavaScript.

The changes are straightforward. There were two ways we dealt with the intermediate “attributes” hash prior to Rails 2:

  1. we used map/collect before calling to_json, i.e.: cities.collect{|c|c.attributes}.to_json
  2. we dealt with ‘attributes’ in JavaScript, i.e., var marker=markers[i].attributes

Fixing it just means removing references to the ‘attributes’ and using the ActiveRecord instance directly.

Here are all the places changes need to be made:

  • 3.8: var marker=markers[i].attributes to var marker=markers[i]
  • 4.6: all instances of result.attributes to just result
  • 4.15: var stores=<%=(@stores.collect {|s|s.attributes}).to_json%>; to var stores=<%=@stores.to_json%>;
  • 5-12: remove the to_json method from class Tower
  • 7-2: render :text=>cities.collect{|c|c.attributes}.to_json to render :text=>cities.to_json
  • 7-5: render :text=>cities.collect{|c|c.attributes}.to_json to render :text=>cities.to_json
  • 7.15: var points=<%=@towers.collect{|c|c.attributes}.to_json %>; to var points=<%=@towers.to_json %>;

50 Things You Didn’t Know…?

Amy writes “We just posted an article Top 50 Things You Didn’t Know You Could Do With Google Maps. I thought I’d bring it to your attention just in case you think your readers would find it interesting.”

Indeed. Some of this will be well known to our readers, however our newer mashup friends might find something here that is interesting. Enjoy.

In the last few weeks we’ve seen an explosion of people complaining about the lack of asinh() on the Windows version of PHP. We use the asinh() function extensively in Chapter 7 for the custom tile overlays. Admittedly, we didn’t test any of the code against windows versions of PHP (we’re LAMP folks), so until the middle of September when Stuart contacted us to ask a question we had no idea about the problem. Continue reading ‘PHP and asinh() on Windows’

DragZoom (previously called GZoom) is my drag-to-zoom custom Google Map control I open-sourced last year. I’m happy to say the code has been incorporated into Google’s own GMaps Utility Library. Thanks to Pamela Fox from Google for doing a lot of work to bring it in. You can now source DragZoom directly off of Google’s servers, so there’s no need to download your own copy.

Pamela also put together a great example page demonstrating the different instantiation options. Other links for the project: