Route Me is an alternative to the integrated Google Maps control from iPhone SDK 3.0+
I'm already tired of the limitations of the built-in card control, or rather, of fastening the crutches. Wait an example: Google Maps app knows how to show a route, a control doesn't know how. You have to draw on your own over the map.
Now I have a specific task: I need to add a display of the route traveled and its export (share) to my modest GPS Speed application, which, by the way, has been hanging in the Top 30 of the American App Store in the Navigation section for some time now . The reason for me remains a mystery, because the application is average and unique does not shine. ')
Returning to the problem. The necessary functionality has already been implemented Almost working crutches for Google Maps have already been made, but this is a good chance to shed light on the Google Maps alternatives for the iPhone SDK.
Mat part
Even when there was no official card control, I worked with such “substitutes”:
part of a large project and has an official development team (I will take this opportunity and say hello to Dima;), because it potentially has greater integration with Cloud Made cards
has many themes (color sets) for cards
used in the spring, it was still raw
I want to start a series of articles with something simple, for example, embed maps into an application and give the user the opportunity to choose the source of maps. I prefer Route Me, because, apart from everything else, it can also show Cloud Made.
Training
Open xCode and create a new project. I chose the View-Based Application and called it RouteMeSourceSelection
Add a UIView (subview) to an existing one and define it as RMMapView
We connect IBOutlet from our UIViewController with the newly created RMMapView
I understand that it is difficult to perceive such a text. In short, it should look like this:
Now, running the application, you should see a map with the default source - Open Street Maps. I see this, I hope you too:
It was all very easy. Let's give the user the opportunity to choose the source of the map. To do this, place the UIPickerView control and link it to our UIViewController.
UIPickerView to select the map source (code)
We open the controller's header and add two UIPickerViewDelegate and UIPickerViewDataSource protocols, and several IBOutlet: @interface RouteMeSourceSelectionViewController : UIViewController <RMMapViewDelegate, UIPickerViewDelegate, UIPickerViewDataSource> { IBOutlet RMMapView *mapView; IBOutlet UIPickerView *mapSourcePicker; IBOutlet UIBarButtonItem *mapSettingsBarButton; }
- (IBAction) showMapsSettings;
@end
Now we implement several required methods for UIPickerView. This is simple, but will be useful for those who have not done it yet:
And now the most important thing is the method for changing the source of the map. If they were attentive, they saw that it was called in “showMapsSettings”. There is a small trick: the map is not updated automatically when you change the source, so you have to shift and return to the previous position. It is invisible to the user. At the very end, we save the selected source number to the general settings of the application.