Sha256: c9573b64bcbe759559806f14016dc0ec8c592ca748fec67e4bec4c37f77dd2bd

Contents?: true

Size: 1.18 KB

Versions: 2

Compression:

Stored size: 1.18 KB

Contents

require 'bundler'

Bundler.setup
Bundler.require

$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
require 'smappy'

namespace :smappy do
  desc "Generate an example static map"
  task :generate_example do
    # Compare this image to:
    #
    #  * Google Maps:   http://maps.google.com/maps/api/staticmap?size=500x350&sensor=false&center=50.9985099,5.857652&zoom=15
    #  * OpenStreetMap: http://staticmap.openstreetmap.de/staticmap.php?center=50.9985099,5.857652&zoom=15
    #
    map = Smappy::StaticMap.new(center: [50.9985099, 5.857652], zoomlevel: 15)
    
    # Cloudmade tiles:
    map.tile_url_template = 'http://a.tile.cloudmade.com/ed3b3505052b442dba7baff14f1ad671/47664/256/%{zoomlevel}/%{x}/%{y}.png'
    
    # Google Maps tiles:
    # map.tile_url_template = 'http://mt1.google.com/vt/x=%{x}&y=%{y}&z=%{zoomlevel}'
    
    canvas  = map.to_image
    drawing = Magick::Draw.new
      
    marker   = Smappy::Marker.new(map.center.latitude, map.center.longitude)
    position = marker.position_on_map(map)
      
    drawing.composite(position[0], position[1], marker.width, marker.height, marker.marker_image)
    drawing.draw(canvas)
      
    canvas.write 'tmp/map.png'
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
smappy-0.0.2 Rakefile
smappy-0.0.1 Rakefile