README.md in ProMotion-mapbox-0.1.3 vs README.md in ProMotion-mapbox-0.2.0
- old
+ new
@@ -1,10 +1,10 @@
# ProMotion-mapbox
[![Gem Version](https://badge.fury.io/rb/ProMotion-mapbox.svg)](http://badge.fury.io/rb/ProMotion-mapbox)
-ProMotion-mapbox provides a PM::MapScreen, forked from the
+ProMotion-mapbox provides a PM::MapScreen that users [Mapbox](https://www.mapbox.com) as the map provider. Forked from the
popular RubyMotion gem [ProMotion-map](https://github.com/clearsightstudio/ProMotion-map).
## Installation
```ruby
@@ -21,56 +21,54 @@
*Has all the methods of PM::Screen*
```ruby
class MyMapScreen < PM::MapScreen
- mapbox_setup access_token: "YOU_MAPBOX_ACCESS_TOKEN",
- tile_source: "mylogin.map"
-
title "My Map"
start_position latitude: 35.090648651123, longitude: -82.965972900391, radius: 4
tap_to_add
def annotation_data
[{
longitude: -82.965972900391,
latitude: 35.090648651123,
title: "Rainbow Falls",
subtitle: "Nantahala National Forest",
- action: :show_forest,
+ left_action: :show_forest,
pin_color: :green
},{
longitude: -82.966093558105,
latitude: 35.092520895652,
title: "Turtleback Falls",
subtitle: "Nantahala National Forest",
- action: :show_forest,
- pin_color: :purple]
+ left_action: :show_forest,
+ left_action_button_type: UIButtonTypeContactAdd,
+ pin_color: :red
},{
longitude: -82.95916,
latitude: 35.07496,
title: "Windy Falls",
- action: :show_forest
+ left_action: :show_forest
},{
longitude: -82.943031505056,
latitude: 35.102516828489,
title: "Upper Bearwallow Falls",
subtitle: "Gorges State Park",
- action: :show_forest
+ left_action: :show_forest
},{
longitude: -82.956244328014,
latitude: 35.085548421623,
title: "Stairway Falls",
subtitle: "Gorges State Park",
your_param: "CustomWhatever",
- action: :show_forest
- }, {
- coordinate: CLLocationCoordinate2DMake(35.090648651123, -82.965972900391)
+ right_action: :show_forest
+ },{
+ coordinate: CLLocationCoordinate2DMake(35.090648651123, -82.965972900391),
title: "Rainbow Falls",
subtitle: "Nantahala National Forest",
image: UIImage.imageNamed("custom-pin"),
- action: :show_forest
+ left_action: :show_forest
}]
end
def show_forest
selected = selected_annotations.first
@@ -81,11 +79,11 @@
Here's a neat way to zoom into a specific marker in an animated fashion and then select the marker:
```ruby
def zoom_to_marker(marker)
- set_region region(coordinate: marker.coordinate, radius: 5) # Radius are specified in nautical miles.
+ set_region region(coordinate: marker.coordinate, radius: 5) # Radius are specified in nautical miles.
select_annotation marker
end
```
---
@@ -108,11 +106,11 @@
coordinate: CLLocationCoordinate2DMake(35.085548421623, -82.956244328014)
title: "Stairway Falls", # REQUIRED
subtitle: "Gorges State Park",
image: "my_custom_image",
- pin_color: :red, # Defaults to :red. Other options are :green or :purple or any UIColor
+ pin_color: :red, # Defaults to :red. Other options are :green or :purple. Here as a placeholder only. Modifying a marker color is not yet supported by the Mapbox GL SDK.
left_accessory: my_button,
right_accessory: my_other_button,
action: :my_action, # Overrides :right_accessory
action_button_type: UIButtonTypeContactAdd # Defaults to UIButtonTypeDetailDisclosure
}
@@ -122,10 +120,12 @@
Use `:image` to specify a custom image. Pass in a string to conserve memory and it will be converted using `UIImage.imageNamed(your_string)`. If you pass in a `UIImage`, we'll use that, but keep in mind that there will be another unnecessary copy of the UIImage in memory.
Use `:left_accessory` and `:right_accessory` to specify a custom accessory, like a button.
+Use `:left_action` and `:right_action` to specify an action for the left or right accessory view. These properties will create a button for you, and should not be used in conjunction with `:left_accessory` or `:right_accessory`. The type of the button can be specified with the optional parameter `:right_action_button_type`, and defaults to UIButtonTypeDetailDisclosure if not specified.
+
You can access annotation data you've arbitrarily stored in the hash by calling `annotation_instance.params[:your_param]`.
The `:action` parameter specifies a method that should be run when the detail button is tapped on the annotation. It automatically adds a `UIButtonTypeDetailDisclosure` button to the `:left_accessory`. In your method you can find out which annotation's accessory was tapped by calling `selected_annotations.first`.
#### update_annotation_data
@@ -185,17 +185,17 @@
#### select_annotation_at(annotation_index, animated=true)
Selects a single annotation using the annotation at the index of your `annotation_data` array.
-#### selected_annotation
+#### selected_annotations
-Returns the annotation that is selected. If no annotation is selected, returns `nil`.
+Returns an array of annotations that are selected. If no annotations are selected, returns `nil`.
-#### deselect_annotation(animated=false)
+#### deselect_annotations(animated=false)
-Deselects any selected annotation.
+Deselects all selected annotations.
#### add_annotation(annotation)
Adds a new annotation to the map. Refer to `annotation_data` (above) for hash properties.
@@ -215,20 +215,19 @@
Sets the region of the `MapScreen`. `region` should be an instance of `MKCoordinateRegion`.
#### region(center_location,radius=10)
-Mapbox API doesn't have the concept of a region. Instead, we can zoom to a virtual bounding box defined by its Sourthwest and Northeast
+Mapbox doesn't use the concept of regions. Instead, we can zoom to a virtual bounding box defined by its Sourthwest and Northeast
corners.
The ```region``` methods takes a ```center_location``` and a radius. The distance from the center to the corners (and thus the zoom level) will be the ```radius``` times 1820 meters (1 Nautical mile)
```ruby
my_region = region({
CLLocationCoordinate2D.new(35.0906,-82.965),
radius: 11
})
-```
---
### Class Methods
@@ -291,12 +290,12 @@
def annotations
[]
end
def will_appear
- NSNotificationCenter.defaultCenter.addObserver(self, selector:"pin_adding:") , name:"ProMotionMapWillAddPin", object:nil)
- NSNotificationCenter.defaultCenter.addObserver(self, selector:"pin_added:") , name:"ProMotionMapAddedPin", object:nil)
+ NSNotificationCenter.defaultCenter.addObserver(self, selector:"pin_adding:", name:"ProMotionMapWillAddPin", object:nil)
+ NSNotificationCenter.defaultCenter.addObserver(self, selector:"pin_added:", name:"ProMotionMapAddedPin", object:nil)
end
def will_disappear
NSNotificationCenter.defaultCenter.removeObserver(self)
end
@@ -362,10 +361,10 @@
### Accessors
#### `map` or `mapview`
-Reference to the created RMMapView.
+Reference to the created MLGMapView.
## Contributing
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)