diff --git a/lib/ProMotion/map/map_screen_module.rb b/lib/ProMotion/map/map_screen_module.rb index 2309a12..ba0d80b 100644 --- a/lib/ProMotion/map/map_screen_module.rb +++ b/lib/ProMotion/map/map_screen_module.rb @@ -243,6 +243,8 @@ def look_up_address(args={}, &callback) end def look_up_location(location, &callback) + location = CLLocation.alloc.initWithLatitude(location.latitude, longitude:location.longitude) if location.is_a?(CLLocationCoordinate2D) + if location.kind_of?(CLLocation) geocoder = CLGeocoder.new geocoder.reverseGeocodeLocation(location, completionHandler: callback) diff --git a/spec/func_map_screen_spec.rb b/spec/func_map_screen_spec.rb index 47253a6..730cee0 100644 --- a/spec/func_map_screen_spec.rb +++ b/spec/func_map_screen_spec.rb @@ -241,7 +241,7 @@ def add_image_annotation map_screen.map.isRotateEnabled.should == false end - it "can lookup a location" do + it "can lookup a location with a CLLocation" do location = CLLocation.alloc.initWithLatitude(-34.226082, longitude: 150.668374) map_screen.look_up_location(location) do |placemarks, fetch_error| @@ -257,4 +257,21 @@ def add_image_annotation @placemark = nil end end + + it "can lookup a location with a CLLocationCoordinate2D" do + location = CLLocationCoordinate2DMake(-34.226082, 150.668374) + + map_screen.look_up_location(location) do |placemarks, fetch_error| + @error = fetch_error + @placemark = placemarks.first + resume + end + + wait do + @error.should == nil + @placemark.should.be.kind_of?(CLPlacemark) + @error = nil + @placemark = nil + end + end end