README.md in map-kit-wrapper-0.0.3 vs README.md in map-kit-wrapper-0.0.4

- old
+ new

@@ -1,9 +1,9 @@ MapKitWrapper ============= -This is a MapKit wrapper for RubyMotion. It's purpose is to make make dealing with MapKit less painful. +This is a MapKit wrapper for RubyMotion. It's purpose is to make dealing with MapKit less painful. MapKitWrapper is work in progress. Right now there are wrappers for the Map Kit Data Types and the Core Location Data Types. Those will save you a lot of typing. ## Installation ```ruby @@ -19,24 +19,30 @@ require 'map-kit-wrapper' ``` ## Example ```ruby +class FooViewController < UIViewController + include MapKit + def viewDidLoad + super -def loadView - self.view = UIView.alloc.initWithFrame(tabBarController.view.bounds) - map = MapView.new - map.frame = self.view.frame - map.delegate = self - region = CoordinateRegion.new([56, 10.6], [3.1, 3.1]) - map.region = region - # Alternatively use set_region - # map.set_region(region, :animated => true) - map.showsUserLocation = true - self.view.addSubview(map) - map.set_zoom_level = 3 + map = MapView.new + map.frame = self.view.frame + map.delegate = self + region = CoordinateRegion.new([56, 10.6], [3.1, 3.1]) + map.region = region + # Alternatively use set_region + # map.set_region(region, :animated => true) + map.showsUserLocation = true + view.addSubview(map) + end + + #... end + + ``` ## MapView: Convenient subclass of MKMapView Include the module @@ -108,25 +114,29 @@ ``` ## Wrappers for the CoreLocation data types Include the module + ```ruby include CoreLocation::DataTypes ``` ### LocationCoordinate: The wrapper for CLLocationCoordinate2D The `LocationCoordinate` initializer takes a variety of argument types + ```ruby LocationCoordinate.new(1,2) LocationCoordinate.new([1,2]) +LocationCoordinate.new({:latitude => 1, :longitude => 2}) LocationCoordinate.new(LocationCoordinate) LocationCoordinate.new(CLLocationCoordinate2D) ``` Methods on `LocationCoordinate` + ```ruby >> lc = LocationCoordinate.new(1, 2) => [1, 2] >> lc.latitude => 1 @@ -134,12 +144,14 @@ => 10 >> lc.longitude => 2 >> lc.longitude = 15 => 15 ->> lc.to_array +>> lc.to_a => [10, 15] +>> lc.to_h +=> {:latitude => 10, :longitude => 15} >> lc.sdk => CLLocationCoordinate2D ``` ## Wrappers for the MapKit data types @@ -155,10 +167,12 @@ The `CoordinateSpan` initializer takes a variety of argument types ```ruby CoordinateSpan.new(1, 2) CoordinateSpan.new([1, 2]) +CoordinateSpan.new({:latitude_delta => 1, :longitude_delta => 2}) +CoordinateSpan.new(CoordinateSpan) CoordinateSpan.new(MKCoordinateSpan) ``` Methods on `CoordinateSpan` @@ -167,12 +181,14 @@ => [1, 2] >> cs.latitude_delta => 1 >> cs.longitude_delta => 2 ->> cs.to_array +>> cs.to_a => [1, 2] +>> cs.to_h +=> {:latitude_delta => 1, :longitude_delta => 2} >> cs.sdk => MKCoordinateSpan ``` ### CoordinateRegion: The wrapper for MKCoordinateRegion @@ -181,12 +197,13 @@ ```ruby CoordinateRegion.new(CoordinateRegion) CoordinateRegion.new(MKCoordinateRegion) CoordinateRegion.new([56, 10.6], [3.1, 3.1]) -CoordinateRegion.new(LocationCoordinate, CoordinateSpan) +CoordinateRegion.new({:center => {:latitude => 56, :longitude => 10.6}, :span => {:latitude_delta => 3.1, :longitude_delta => 5.1}}) CoordinateRegion.new(CLLocationCoordinate2D, MKCoordinateSpan) +CoordinateRegion.new(LocationCoordinate, CoordinateSpan) ``` Methods on `CoordinateRegion` ```ruby @@ -194,12 +211,12 @@ => {:center => [56, 10.6], :span => [3.1, 5.1]} >> cs.center => LocationCoordinate([56, 10.6]) >> cs.region => CoordinateSpan([3.1, 5.1]) ->> cs.to_hash -=> {:center => [56, 10.6], :span => [3.1, 5.1]} +>> cs.to_h +=> {:center => {:latitude => 56, :longitude => 10.6}, :span => {:latitude_delta => 3.1, :longitude_delta => 5.1}} >> cs.sdk => MKCoordinateRegion ``` ### MapPoint: The wrapper for MKMapPoint @@ -207,11 +224,13 @@ The `MapPoint` initializer takes a variety of argument types ```ruby MapPoint.new(50, 45) MapPoint.new([50, 45]) +MapPoint.new({:x => 50, :y => 45}) MapPoint.new(MKMapPoint) +MapPoint.new(MapPoint) ``` Methods on `MapPoint` ```ruby @@ -219,12 +238,14 @@ => [50, 45] >> mp.x => 50 >> mp.y => 45 ->> mp.to_array +>> mp.to_a => [50, 45] +>> mp.to_h +=> {:x => 50, :y => 45} >> mp.sdk => MKMapPoint ``` ### MapSize: The wrapper for MKMapSize @@ -232,11 +253,13 @@ The `MapSize` initializer takes a variety of argument types ```ruby MapSize.new(10, 12) MapSize.new([10, 12]) +MapSize.new({:width => 50, :height => 45}) MapSize.new(MKMapSize) +MapSize.new(MapSize) ``` Methods on `MapSize` ```ruby @@ -244,12 +267,14 @@ => [10, 12] >> ms.width => 10 >> ms.height => 12 ->> ms.to_array +>> ms.to_a => [50, 45] +>> ms.to_h +=> {:width => 50, :height => 45} >> ms.sdk => MKMapSize ``` ### MapRect: The wrapper for MKMapRect @@ -257,12 +282,15 @@ The `MapRect` initializer takes a variety of argument types ```ruby MapRect.new(x, y, width, height) MapRect.new([x, y], [width, height]) +MapRect.new({:origin => {:x => 2, :y => 3}, :size => {:width => 10, :height => 12}}) MapRect.new(MapPoint, MapSize) MapRect.new(MKMapPoint, MKMapSize) +MapRect.new(MapRect) +MapRect.new(MKMapRect) ``` Methods on `MapRect` ```ruby @@ -270,11 +298,11 @@ => {:origin => [2, 3], :size => [10, 12]} >> mr.origin => MapRect([2, 3]) >> mr.size => MapSize([10, 12]) ->> mr.to_hash -=> {:origin => [2, 3], :size => [10, 12]} +>> mr.to_h +=> {:origin => {:x => 2, :y => 3}, :size => {:width => 10, :height => 12}} >> mr.sdk => MKMapRect ```