Redmaps

Once upon a time there was a rather nice looking object called Ruby.
It was renowned throughout the lands as being rather nice looking. As
it turns out, the internets is not kind to said shapely object and
hasn’t gone and given Ruby glasses to everybody so they can look at
her. As a replacement, poor old Ruby dressed up as a donkey, so that
all the simpletons could see her, albeit as a different beast.

Riding said beast was Maps, a square looking fellow who liked to zoom
and pan his way thoroughout the countryside. Poor Maps jumped on
confused Ruby’s back and rode into the apparently dangerous land of
programming language translation.

Furthermore, I have jumped on Red’s back and rode into the apparently
dangerous land of crappy little library making. Here’s a little
library for interacting with Google Maps from Red.

> HERE! <

Good luck!

I did learn some Maps stuff, so it isn’t all bad. It also needs a new
name. Idea!

Free sample time!


  require 'maps.red'

  Document.ready? do

    Google::Coordinates.geocode("Brisbane, Australia") do |point|
      map = Google::Map.new(Document["#map_canvas"], 
                            :width => 600, 
                            :height => 400)

      map.center = point
      map.zoom = 13

      map.controls << Google::Control.new(:small_map, :position => :top_left)
      map.controls << Google::Control.new(:map_type)

      marker = Google::Marker.new(point, :color => :orange)
      marker.upon(:click) do
        `alert("Why did you click the marker?")`
      end
      map.overlays << marker

      map.upon(:click) do |coordinates|
        # Also fires when the marker is clicked
        `alert(#{coordinates.to_s})`
      end
    end
  end

Aah, the light!