| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
MAPS.ME (MapsWithMe) offline maps API for iOS (hereinafter referred to as API) provides an interface for other applications to perform the following tasks:
For API version 1 (supported by MapsWithMe 2.4+)
In general it is possible to establish a one way or two way communication between MapsWithMe and your app.
Please check our offline travel guide apps as an API integration example.
First step is to clone repository or download it as an archive.
When your are done you find two folders: api and capitals-example. First one contains .h and .m files which you need to include into your project. You can always modify them according to your needs.
If you want to get results of API calls, please add unique URL scheme to your app. You can do it with XCode or by editing Info.plist file in your project. To make things simple, use mapswithme keyword in scheme ID, like my_mapswithme_scheme, and create an unique scheme name (or use your existing one). mapswithme keyword in scheme ID simply helps API code to detect it automatically. See more details in Apple's documentation.
MAPS.ME (MapsWithMe) supports two schemes: "mapswithme://" and "mapswithmepro://"
iOS9+ note: you need to add LSApplicationQueriesSchemes key into your plist with value mapswithme to correctly query if MAPS.ME is installed.
capitals-example folder contains sample application which demonstrates part of API features.
NOTE: If you are using Automatic References Counting (ARC) in your project, you can use this solution or simply fix code by yourself.
Simply opens MapsWithMe app:
+ (BOOL)showMap;
Example:
[MWMApi showMap];
Displays given point on a map:
+ (BOOL)showLat:(double)lat lon:(double)lon title:(NSString *)title and:(NSString *)idOrUrl;
The same as above but using pin wrapper:
+ (BOOL)showPin:(MWMPin *)pin;
Pin wrapper is a simple helper to wrap pins displayed on the map:
@interface MWMPin : NSObject @property (nonatomic, assign) double lat; @property (nonatomic, assign) double lon; @property (nonatomic, retain) NSString * title; @property (nonatomic, retain) NSString * idOrUrl; - (id)initWithLat:(double)lat lon:(double)lon title:(NSString *)title and:(NSString *)idOrUrl; @end
Example:
[MWMApi showLat:53.9 lon:27.56667 title:@"Minsk - the capital of Belarus" and:@"http://wikipedia.org/wiki/Minsk"]; … MWMPin * goldenGate = [[MWMPin alloc] init] autorelease]; goldenGate.lat = 37.8195; goldenGate.lon = -122.4785; goldenGate.title = @"Golden Gate in San Francisco"; goldenGate.idOrUrl = @"any number or string here you want to receive back in your app, or any url you want to be opened from MapsWithMe"; [MWMApi showPin:goldenGate];
+ (BOOL)showPins:(NSArray *)pins;
When users presses Back button in MapsWithMe, or selects More Info button, he is redirected back to your app. Here are helper methods to obtain API call results:
Returns YES if url is received from MapsWithMe and can be parsed:
+ (BOOL)isMapsWithMeUrl:(NSURL *)url;
Returns nil if user didn't select any pin and simply pressed Back button:
+ (MWMPin *)pinFromUrl:(NSURL *)url;
Example:
if ([MWMApi isMapsWithMeUrl:url])
{
// Good, here we know that your app was opened from MapsWithMe
MWMPin * pin = [MWMApi pinFromUrl:url];
if (pin)
{
// User selected specific pin, and we can get it's properties
}
else
{
// User pressed "Back" button and didn't select any pin
}
}
Note, that you can simply check that sourceApplication contains com.mapswithme. substring to detect that your app is opened from MapsWithMe.
Returns NO if MapsWithMe is not installed or outdated version doesn't support API calls:
+ (BOOL)isApiSupported;
With this method you can check that user needs to install MapsWithMe and display your custom UI. Alternatively, you can do nothing and use built-in dialog which will offer users to install MapsWithMe.
+ (void)setOpenUrlOnBalloonClick:(BOOL)value;
If you prefer to use API on your own, here are some details about the implementation.
Applications "talk" to each other using URL Scheme. API v1 supports the following parameters to the URL Scheme:
mapswithme://map?v=1&ll=54.32123,12.34562&n=Point%20Name&id=AnyStringOrEncodedUrl&backurl=UrlToCallOnBackButton&appname=TitleToDisplayInNavBar
Note that you can display as many pins as you want, the only rule is that ll parameter comes before n and id for each point.
When user selects a pin, your app is called like this:
YourAppUniqueUrlScheme://pin?ll=lat,lon&n=PinName&id=PinId
Copyright (c) 2019, MY.COM B.V. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
| Back | FazBrowse Home | New Git URL |