Sha256: 6a1415c1c64a03ab85f71b2b5c9673a101224107c92cda82a0c2e9ef2b9b15b1

Contents?: true

Size: 1.12 KB

Versions: 2

Compression:

Stored size: 1.12 KB

Contents

require 'bundler'

Bundler.setup
Bundler.require

Bundler::GemHelper.install_tasks

$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}'
    
    image = map.to_image
      
    marker   = Smappy::Marker.new(map.center.latitude, map.center.longitude)
    position = marker.position_on_map(map)
    
    image.compose!(marker.marker_image, position[0], position[1])
    
    image.save 'tmp/map.png'
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
smappy-0.0.4 Rakefile
smappy-0.0.3 Rakefile