diff --git a/sample/mapview/Rakefile b/sample/mapview/Rakefile new file mode 100644 index 00000000..da2e3695 --- /dev/null +++ b/sample/mapview/Rakefile @@ -0,0 +1,7 @@ +$:.unshift('../../lib') +require 'rubixir/rake' + +Rubixir::CONFIG.app_name = 'mapview' +Rubixir::CONFIG.frameworks << 'CoreLocation' +Rubixir::CONFIG.frameworks << 'MapKit' +Rubixir::CONFIG.frameworks << 'AddressBook' diff --git a/sample/mapview/app/main.rb b/sample/mapview/app/main.rb new file mode 100644 index 00000000..8d6ff937 --- /dev/null +++ b/sample/mapview/app/main.rb @@ -0,0 +1,38 @@ +class Beer + def initialize(lat, long, name) + @name = name + @coordinate = CLLocationCoordinate2D.new + @coordinate.latitude = lat + @coordinate.longitude = long + end + + def title; @name; end + def coordinate; @coordinate; end +end + +class AppDelegate + def application(application, didFinishLaunchingWithOptions:launchOptions) + window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.applicationFrame) + + mvrect = window.bounds + mv = MKMapView.alloc.initWithFrame(mvrect) + mv.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth + + # Center on Brussels. + region = MKCoordinateRegionMake(CLLocationCoordinate2D.new(50.85, 4.35), MKCoordinateSpanMake(3.1, 3.1)) + mv.setRegion(region) + + beers = [ + Beer.new(50.016667, 4.316667, 'Chimay'), + Beer.new(49.639722, 5.348889, 'Orval'), + Beer.new(50.178162, 5.219879, 'Rochefort'), + Beer.new(51.284720, 4.656670, 'Westmalle'), + Beer.new(50.895942, 2.721262, 'Westvleteren'), + Beer.new(51.298800, 5.488570, 'Achel') + ] + beers.each { |beer| mv.addAnnotation(beer) } + + window.addSubview(mv) + window.makeKeyAndVisible + end +end