PostGIS + Rails + ActiveRecord + AJAX + JSON + GMaps = Awesome

Well, I hacked for a solid day, and I managed to integrate PostGIS, Rails/ActiveRecord, and sprinkled a little AJAX + JSON, and baked in some Google Map API, and here’s the result:

(click on the thumbnail for detail)

The end result is a scrollable Google Map that loads cartographic data from PostGIS based on the bounds that the map window is centered over. The end result is also very slow at the extremes :)

My next TODO involves changing how the shapes are simplified when the map is zoomed way in or out, and possibly just showing an entire state if the map is zoomed out far enough. I might also work on only loading line segments instead of the entire county outline if it’s warranted. There’s no point in loading an entire high-res county if we’re zoomed in on a little corner, is there?

Safari is slow, BTW.

2 Responses to “PostGIS + Rails + ActiveRecord + AJAX + JSON + GMaps = Awesome”

  1. rinajlis Says:

    This looks really exciting! Would you be willing to share any of the code? I would be interested to see how you got this going.

    Thanks a lot

  2. Tony Says:

    Hi rinajlis,

    This post is pretty old, and I don’t have any of the old code laying around. There are, however, a few ways to interact with various mapping services and Rails:

    http://rubyforge.org/projects/ym4r/

    By far the easiest way to hook up Rails/ActiveRecord with geospatial data is to use PostGIS, GeoRuby and spatial_adapter:

    http://georuby.rubyforge.org/

Leave a Reply

You must be logged in to post a comment.