这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ Sets the center of the map. `animated` property defaults to `true`.

Shows the user's location on the map.

#### look_up_location(CLLocation) { |placemark, error| }

This method takes a CLLocation object and will return one to many CLPlacemark to represent nearby data.

##### iOS 8 Location Requirements

iOS 8 introduced stricter location services requirements. You are now required to add a few key/value pairs to the `Info.plist`. Add these two lines to your `Rakefile` (with your descriptions, obviously):
Expand Down
10 changes: 10 additions & 0 deletions lib/ProMotion/map/map_screen_module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,16 @@ def look_up_address(args={}, &callback)
return geocoder.geocodeAddressString(args[:address].to_s, inRegion:args[:region].to_s, completionHandler: callback) if args[:region]
end

def look_up_location(location, &callback)
if location.kind_of?(CLLocation)
geocoder = CLGeocoder.new
geocoder.reverseGeocodeLocation(location, completionHandler: callback)
else
PM.logger.info("You're trying to reverse geocode something that isn't a CLLocation")
callback.call nil, nil
end
end

########## Cocoa touch methods #################
def mapView(map_view, viewForAnnotation:annotation)
annotation_view(map_view, annotation)
Expand Down
16 changes: 16 additions & 0 deletions spec/func_map_screen_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,20 @@ def add_image_annotation
map_screen.map.isRotateEnabled.should == false
end

it "can lookup a location" do
location = CLLocation.alloc.initWithLatitude(-34.226082, longitude: 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