Compare commits

..

1 commit

Author SHA1 Message Date
Alexander Borsuk
7b95e1e24c
Create FUNDING.yml 2022-06-06 08:14:51 +02:00
23 changed files with 451 additions and 157 deletions

3
.github/FUNDING.yml vendored Normal file
View file

@ -0,0 +1,3 @@
github: organicmaps
liberapay: OrganicMaps
custom: ["https://organicmaps.app/donate"]

108
README.md
View file

@ -1,23 +1,26 @@
## Organic Maps iOS API: Getting Started
## MAPS.ME iOS API: Getting Started
### Introduction
Organic Maps offline maps API for iOS (hereinafter referred to as *API*) provides an interface for other applications to perform the following tasks (even while in offline):
MAPS.ME (MapsWithMe) offline maps API for iOS (hereinafter referred to as *API*) provides an interface for other applications to perform the following tasks:
* Open [Organic Maps Application][linkOm]
* Check that [Organic Maps][linkOm] is installed
* Show one or more points on an offline map of [Organic Maps][linkOm] with *Back* button and client app name in the title
For API version 1 (supported by MapsWithMe 2.4+)
* Open [MapsWithMe Application][linkMwm]
* Check that [MapsWithMe][linkMwm] is installed
* Show one or more points on an offline map of [MapsWithMe][linkMwm] with *Back* button and client app name in the title
* Return the user back to the client application:
* after pressing *Back* button on the map
* after selecting specific point on the map if user asks for more information by pressing *More Info* button in [Organic Maps][linkOm]
* Open any given url or url scheme after selecting specific point on the map if user asks for more information by pressing *More Info* button in [Organic Maps][linkOm]
* Automatically display [*Download Organic Maps*][linkDownloadOMDialog] dialog if [Organic Maps][linkOm] is not installed.
* after selecting specific point on the map if user asks for more information by pressing *More Info* button in [MapsWithMe][linkMwm]
* Open any given url or url scheme after selecting specific point on the map if user asks for more information by pressing *More Info* button in [MapsWithMe][linkMwm]
* Automatically display [*Download MapsWithMe*][linkDownloadMWMDialog] dialog if [MapsWithMe][linkMwm] is not installed.
In general it is possible to establish a one way or two way communication between *Organic Maps* and your app.
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][linkTravelGuides] as an API integration example.
### Prerequisites
* Your application must target *iOS version 12.0* or above.
* Your application must target at least *iOS version 5.0*
* For two way communication, you should add unique [URL scheme][linkAppleCustomUrlSchemes] to your app (see below)
### Integration
@ -27,32 +30,32 @@ First step is to clone [repository][linkRepo] 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][linkAddUrlScheme] or by editing Info.plist file in your project. To make things simple, use *om* keyword in scheme ID, like *my_om_scheme*, and create an unique scheme name (or use your existing one).
*om* keyword in scheme ID simply helps API code to detect it automatically. See more details in [Apple's documentation][linkAppleCustomUrlSchemes].
If you want to get results of API calls, please add unique URL scheme to your app. You can do it with [XCode][linkAddUrlScheme] 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][linkAppleCustomUrlSchemes].
Organic Maps supports one API scheme: "om://"
MAPS.ME (MapsWithMe) supports two schemes: "mapswithme://" and "mapswithmepro://"
You also need to add [LSApplicationQueriesSchemes][linkAppleLSApplicationQueriesSchemes] key into your plist with value *om* to correctly query if Organic Maps is already installed.
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 some API features.
*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][linkFixARC] or simply fix code by yourself.*
### API Calls Overview and HOW TO
* All methods are static for *OMApi* class, *BOOL* methods return *NO* if call is failed.
* If id for given pin contains valid url, it will be opened from Organic Maps after selecting *More Info* button.
* All methods are static for *MWMApi* class, *BOOL* methods return *NO* if call is failed.
* If id for given pin contains valid url, it will be opened from MapsWithMe after selecting *More Info* button.
For any other content, id will be simply passed back to the caller's [*AppDelegate application:openURL:sourceApplication:annotation:*][linkAppleDelegate] method
#### Open [Organic Maps Application][linkOm]
#### Open [MapsWithMe Application][linkMwm]
Simply opens Organic Maps app:
Simply opens MapsWithMe app:
+ (BOOL)showMap;
Example:
[OMApi showMap];
[MWMApi showMap];
#### Show specified location on the map
@ -62,11 +65,11 @@ Displays given point on a map:
The same as above but using pin wrapper:
+ (BOOL)showPin:(OMPin *)pin;
+ (BOOL)showPin:(MWMPin *)pin;
Pin wrapper is a simple helper to wrap pins displayed on the map:
@interface OMPin : NSObject
@interface MWMPin : NSObject
@property (nonatomic, assign) double lat;
@property (nonatomic, assign) double lon;
@property (nonatomic, retain) NSString * title;
@ -76,14 +79,14 @@ Pin wrapper is a simple helper to wrap pins displayed on the map:
Example:
[OMApi showLat:53.9 lon:27.56667 title:@"Minsk - the capital of Belarus" and:@"http://wikipedia.org/wiki/Minsk"];
[MWMApi showLat:53.9 lon:27.56667 title:@"Minsk - the capital of Belarus" and:@"http://wikipedia.org/wiki/Minsk"];
OMPin * goldenGate = [[OMPin alloc] init] autorelease];
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 Organic Maps";
[OMApi showPin:goldenGate];
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];
#### Show any number of pins on the map
@ -91,23 +94,23 @@ Example:
#### Receiving results of API calls
When users presses *Back* button in Organic Maps, or selects *More Info* button, he is redirected back to your app.
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 Organic Maps and can be parsed:
Returns YES if url is received from MapsWithMe and can be parsed:
+ (BOOL)isOrganicMapsUrl:(NSURL *)url;
+ (BOOL)isMapsWithMeUrl:(NSURL *)url;
Returns nil if user didn't select any pin and simply pressed *Back* button:
+ (OMPin *)pinFromUrl:(NSURL *)url;
+ (MWMPin *)pinFromUrl:(NSURL *)url;
Example:
if ([OMApi isOrganicMapsUrl:url])
if ([MWMApi isMapsWithMeUrl:url])
{
// Good, here we know that your app was opened from Organic Maps
OMPin * pin = [OMApi pinFromUrl: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
@ -118,38 +121,38 @@ Example:
}
}
Note, that you can simply check that *sourceApplication* contains *app.organicmaps* substring to detect that your app is opened from Organic Maps.
Note, that you can simply check that *sourceApplication* contains *com.mapswithme.* substring to detect that your app is opened from MapsWithMe.
#### Check that Organic Maps is installed
#### Check that MapsWithMe is installed
Returns NO if Organic Maps is not installed or outdated version doesn't support API calls:
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 Organic Maps and display your custom UI.
Alternatively, you can do nothing and use built-in dialog which will offer users to install Organic Maps.
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.
### Set value if you want to open pin URL on balloon click
### Set value if you want to open pin URL on balloon click (Available in 2.4.5)
+ (void)setOpenUrlOnBalloonClick:(BOOL)value;
### Under the hood
If you prefer to use API directly, here are some details about the implementation.
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 in the URL Scheme:
Applications "talk" to each other using URL Scheme. API v1 supports the following parameters to the URL Scheme:
om://map?v=1&ll=54.32123,12.34562&n=Point%20Name&id=AnyStringOrEncodedUrl&backurl=UrlToCallOnBackButton&appname=TitleToDisplayInNavBar
mapswithme://map?v=1&ll=54.32123,12.34562&n=Point%20Name&id=AnyStringOrEncodedUrl&backurl=UrlToCallOnBackButton&appname=TitleToDisplayInNavBar
* **v** - API version, currently *1*
* **ll** - pin latitude and longitude, comma-separated
* **n** - pin title
* **id** - any string you want to receive back in your app, OR alternatively, any valid URL which will be opened on *More Info* button click
* **backurl** - usually, your unique app scheme to open back your app
* **appname** - string to display in navigation bar on top of the map in Organic Maps
* **balloonAction** - pass openUrlOnBalloonClick as a parameter, if you want to open pin url on balloon click (usually pin url opens when "Show more info" button is pressed).
* **appname** - string to display in navigation bar on top of the map in MAPS.ME
* **balloonAction** - pass openUrlOnBalloonClick as a parameter, if you want to open pin url on balloon click(Usually pin url opens when "Show more info" button is pressed). (Available in 2.4.5)
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.
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:
@ -158,7 +161,6 @@ When user selects a pin, your app is called like this:
------------------------------------------------------------------------------------------
### API Code is licensed under the BSD 2-Clause License
Copyright (c) 2022, Organic Maps OÜ
Copyright (c) 2019, MY.COM B.V.
All rights reserved.
@ -169,12 +171,12 @@ Redistribution and use in source and binary forms, with or without modification,
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.
[linkOm]: https://organicmaps.app/ "Organic Maps: free, privacy-focused, fast and detailed offline maps app"
[linkRepo]: https://github.com/organicmaps/api-ios "GitHub Repository"
[linkAddUrlScheme]: https://raw.github.com/organicmaps/api-ios/site-resources/add_custom_url_scheme.png "How to add url scheme in XCode"
[linkDownloadOMDialog]: https://raw.github.com/organicmaps/api-ios/site-resources/download_om_dialog.png "Donwload Organic Maps Dialog"
[linkIssues]: https://github.com/organicmaps/api-ios/issues "Post a bug or feature request"
[linkMwm]: https://maps.me/ "MAPS.ME - offline maps of the world"
[linkRepo]: https://github.com/mapsme/api-ios "GitHub Repository"
[linkAddUrlScheme]: https://raw.github.com/mapswithme/api-ios/site-resources/add_custom_url_scheme.png "How to add url scheme in XCode"
[linkDownloadMWMDialog]: https://raw.github.com/mapswithme/api-ios/site-resources/download_mwm_dialog.png "Donwload MAPS.ME Dialog"
[linkIssues]: https://github.com/mapsme/api-ios/issues "Post a bug or feature request"
[linkAppleCustomUrlSchemes]: https://developer.apple.com/library/ios/#DOCUMENTATION/iPhone/Conceptual/iPhoneOSProgrammingGuide/AdvancedAppTricks/AdvancedAppTricks.html#//apple_ref/doc/uid/TP40007072-CH7-SW50 "Custom URL Scheme Apple documentation"
[linkAppleDelegate]: https://developer.apple.com/library/ios/documentation/uikit/reference/UIApplicationDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intfm/UIApplicationDelegate/application:openURL:sourceApplication:annotation: "AppDelegate Handle custom URL Schemes"
[linkFixARC]: http://stackoverflow.com/a/6658549/1209392 "How to compile non-ARC code in ARC projects"
[linkAppleLSApplicationQueriesSchemes]: https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/LaunchServicesKeys.html#//apple_ref/doc/uid/TP40009250-SW14 "LSApplicationQueriesSchemes"
[linkTravelGuides]: http://guidewithme.com "Offline Travel Guides"

78
api/MapsWithMeAPI.h Normal file
View file

@ -0,0 +1,78 @@
/*******************************************************************************
Copyright (c) 2014, MapsWithMe GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
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.
******************************************************************************/
#import <Foundation/Foundation.h>
#if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_7_0
#error "maps.me supports iOS >= 7.0 only"
#endif
// Wrapper for a pin on a map
@interface MWMPin : NSObject
/// [required] pin latitude
@property (nonatomic) double lat;
/// [required] pin longitude
@property (nonatomic) double lon;
/// [optional] pin title
@property (nullable, copy, nonatomic) NSString * title;
/// [optional] passed back to the app when pin is clicked, OR, if it's a valid url,
/// it will be opened from MapsWithMe after selecting "More Details..." for the pin
@property (nullable, copy, nonatomic) NSString * idOrUrl;
- (nullable instancetype)initWithLat:(double)lat
lon:(double)lon
title:(nullable NSString *)title
idOrUrl:(nullable NSString *)idOrUrl;
@end
// MapsWithMe API interface
@interface MWMApi : NSObject
/// returns YES if url is received from MapsWithMe and can be parsed
+ (BOOL)isMapsWithMeUrl:(nonnull NSURL *)url;
/// returns nil if user didn't select any pin and simply pressed "Back" button
+ (nullable MWMPin *)pinFromUrl:(nonnull NSURL *)url;
/// returns NO if MapsWithMe is not installed or outdated version doesn't support API calls
+ (BOOL)isApiSupported;
/// Simply opens MapsWithMe app
+ (BOOL)showMap;
/// Displays given point on a map, title and id are optional.
/// If id contains valid url, it will be opened from MapsWithMe after selecting "More Details..." for the pin
+ (BOOL)showLat:(double)lat lon:(double)lon title:(nullable NSString *)title idOrUrl:(nullable NSString *)idOrUrl;
/// The same as above but using pin wrapper
+ (BOOL)showPin:(nullable MWMPin *)pin;
/// Displays any number of pins
+ (BOOL)showPins:(nonnull NSArray<MWMPin *> *)pins;
//
+ (void)showMapsWithMeIsNotInstalledDialog;
/// Set value = YES if you want to open pin URL on balloon click, default value is NO
+ (void)setOpenUrlOnBalloonClick:(BOOL)value;
@end

262
api/MapsWithMeAPI.m Normal file
View file

@ -0,0 +1,262 @@
/*******************************************************************************
Copyright (c) 2014, MapsWithMe GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
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.
******************************************************************************/
#import "MapsWithMeAPI.h"
#define MAPSWITHME_API_VERSION 1.1
static NSString * const kMWMUrlScheme = @"mapswithme://";
static BOOL kOpenUrlOnBalloonClick = NO;
@implementation MWMPin
- (nullable instancetype)init
{
self = [super init];
if (self)
{
_lat = INFINITY;
_lon = INFINITY;
}
return self;
}
- (nullable instancetype)initWithLat:(double)lat
lon:(double)lon
title:(nullable NSString *)title
idOrUrl:(nullable NSString *)idOrUrl
{
self = [super init];
if (self)
{
_lat = lat;
_lon = lon;
_title = title;
_idOrUrl = idOrUrl;
}
return self;
}
@end
// Utility class to automatically handle "MapsWithMe is not installed" situations
@interface MWMNViewController : UIViewController <UIWebViewDelegate>
@end
@implementation MWMNViewController
// HTML page for users who didn't install MapsWithMe
static NSString * const mapsWithMeIsNotInstalledPage =
@"<html>" \
"<head>" \
"<title>Please install MAPS.ME - offline maps of the World</title>" \
"<meta name='viewport' content='width=device-width, initial-scale=1.0'/>" \
"<meta charset='UTF-8'/>" \
"<style type='text/css'>" \
"body { font-family: Roboto,Helvetica; background-color:#fafafa; text-align: center;}" \
".description { text-align: center; font-size: 0.85em; margin-bottom: 1em; }" \
".button { -moz-border-radius: 20px; -webkit-border-radius: 20px; -khtml-border-radius: 20px; border-radius: 20px; padding: 10px; text-decoration: none; display:inline-block; margin: 0.5em; }" \
".shadow { -moz-box-shadow: 3px 3px 5px 0 #444; -webkit-box-shadow: 3px 3px 5px 0 #444; box-shadow: 3px 3px 5px 0 #444; }" \
".pro { color: white; background-color: green; }" \
".mwm { color: green; text-decoration: none; }" \
"</style>" \
"</head>" \
"<body>" \
"<div class='description'>Offline maps are required to proceed. We have partnered with <a href='http://maps.me' target='_blank' class='mwm'>MAPS.ME</a> to provide you with offline maps of the entire world.</div>" \
"<div class='description'>To continue please download the app:</div>" \
"<a href='http://mapswith.me/get?api' class='pro button shadow'>Download&nbsp;MAPS.ME</a>" \
"</body>" \
"</html>";
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
[(UIWebView *)self.view loadHTMLString:mapsWithMeIsNotInstalledPage baseURL:[NSURL URLWithString:@"http://maps.me/"]];
}
- (void)onCloseButtonClicked:(id)sender
{
[self dismissViewControllerAnimated:YES completion:nil];
}
@end
@implementation MWMApi
+ (NSString *)urlEncode:(NSString *)str
{
return (__bridge_transfer NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)str, NULL, CFSTR("!$&'()*+,-./:;=?@_~"), kCFStringEncodingUTF8);
}
+ (BOOL)isMapsWithMeUrl:(nonnull NSURL *)url
{
NSString * appScheme = [MWMApi detectBackUrlScheme];
return appScheme && [url.scheme isEqualToString:appScheme];
}
+ (nullable MWMPin *)pinFromUrl:(nonnull NSURL *)url
{
if (![MWMApi isMapsWithMeUrl:url])
return nil;
MWMPin * pin = nil;
if ([url.host isEqualToString:@"pin"])
{
pin = [[MWMPin alloc] init];
for (NSString * param in [url.query componentsSeparatedByString:@"&"])
{
NSArray<NSString *> * values = [param componentsSeparatedByString:@"="];
if ([values count] == 2)
{
NSString * key = values[0];
if ([key isEqualToString:@"ll"])
{
NSArray<NSString *> * coords = [values[1] componentsSeparatedByString:@","];
if ([coords count] == 2)
{
pin.lat = [[NSDecimalNumber decimalNumberWithString:coords[0]] doubleValue];
pin.lon = [[NSDecimalNumber decimalNumberWithString:coords[1]] doubleValue];
}
}
else if ([key isEqualToString:@"n"])
pin.title = [values[1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
else if ([key isEqualToString:@"id"])
pin.idOrUrl = [values[1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
else
NSLog(@"Unsupported url parameters: %@", values);
}
}
// do not accept invalid coordinates
if (pin.lat > 90. || pin.lat < -90. || pin.lon > 180. || pin.lon < -180.)
pin = nil;
}
return pin;
}
+ (BOOL)isApiSupported
{
return [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:kMWMUrlScheme]];
}
+ (BOOL)showMap
{
return [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[kMWMUrlScheme stringByAppendingFormat:@"map?v=%f", MAPSWITHME_API_VERSION]]];
}
+ (BOOL)showLat:(double)lat lon:(double)lon title:(nullable NSString *)title idOrUrl:(nullable NSString *)idOrUrl
{
MWMPin * pin = [[MWMPin alloc] initWithLat:lat lon:lon title:title idOrUrl:idOrUrl];
return [MWMApi showPin:pin];
}
+ (BOOL)showPin:(nullable MWMPin *)pin
{
return pin ? [MWMApi showPins:@[pin]] : NO;
}
+ (BOOL)showPins:(nonnull NSArray<MWMPin *> *)pins
{
// Automatic check that MapsWithMe is installed
if (![MWMApi isApiSupported])
{
// Display dialog with link to the app
[MWMApi showMapsWithMeIsNotInstalledDialog];
return NO;
}
NSString * appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"];
NSMutableString * str = [NSMutableString stringWithFormat:@"%@map?v=%f&appname=%@&",
kMWMUrlScheme,
MAPSWITHME_API_VERSION,
[self urlEncode:appName]];
NSString * backUrlScheme = [MWMApi detectBackUrlScheme];
if (backUrlScheme)
[str appendFormat:@"backurl=%@&", [self urlEncode:backUrlScheme]];
for (MWMPin * point in pins)
{
[str appendFormat:@"ll=%f,%f&", point.lat, point.lon];
@autoreleasepool
{
if (point.title)
[str appendFormat:@"n=%@&", [self urlEncode:point.title]];
if (point.idOrUrl)
[str appendFormat:@"id=%@&", [self urlEncode:point.idOrUrl]];
}
}
if (kOpenUrlOnBalloonClick)
[str appendString:@"&balloonAction=kOpenUrlOnBalloonClick"];
NSURL * url = [NSURL URLWithString:str];
BOOL const result = [[UIApplication sharedApplication] openURL:url];
return result;
}
+ (NSString *)detectBackUrlScheme
{
for (NSDictionary * dict in [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleURLTypes"])
{
if ([dict[@"CFBundleURLName"] rangeOfString:@"mapswithme" options:NSCaseInsensitiveSearch].location != NSNotFound)
{
for (NSString * scheme in dict[@"CFBundleURLSchemes"])
{
// We use the first scheme in this list, you can change this behavior if needed
return scheme;
}
}
}
NSLog(@"WARNING: No com.mapswithme.maps url schemes are added in the Info.plist file. Please add them if you want API users to come back to your app.");
return nil;
}
+ (void)showMapsWithMeIsNotInstalledDialog
{
UIWebView * webView = [[UIWebView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame];
// check that we have Internet connection and display fresh online page if possible
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://maps.me/api_mwm_not_installed"]]];
MWMNViewController * webController = [[MWMNViewController alloc] init];
webView.delegate = webController;
webController.view = webView;
webController.title = @"Install MAPS.ME";
UINavigationController * navController = [[UINavigationController alloc] initWithRootViewController:webController];
navController.navigationBar.topItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Close" style:UIBarButtonItemStyleDone target:webController action:@selector(onCloseButtonClicked:)];
UIWindow * window = [[UIApplication sharedApplication].windows firstObject];
[window.rootViewController presentViewController:navController animated:YES completion:nil];
}
+ (void)setOpenUrlOnBalloonClick:(BOOL)value
{
kOpenUrlOnBalloonClick = value;
}
@end

View file

@ -8,7 +8,7 @@
/* Begin PBXBuildFile section */
97F3580C185F5BB200DDF84D /* capitals.plist in Resources */ = {isa = PBXBuildFile; fileRef = 97F3580B185F5BB200DDF84D /* capitals.plist */; };
FA0ADFF727B1561E00800A86 /* OrganicMapsAPI.m in Sources */ = {isa = PBXBuildFile; fileRef = FA0ADFF627B1561E00800A86 /* OrganicMapsAPI.m */; };
FA1792CE17784F000092B567 /* MapsWithMeAPI.m in Sources */ = {isa = PBXBuildFile; fileRef = FA1792CC17784F000092B567 /* MapsWithMeAPI.m */; };
FA776B4F17848A370023F7A0 /* MasterViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = FA776B4D17848A370023F7A0 /* MasterViewController.xib */; };
FAA484EA178108970027B232 /* 114x114.png in Resources */ = {isa = PBXBuildFile; fileRef = FAA484E2178108970027B232 /* 114x114.png */; };
FAA484EB178108970027B232 /* 144x144.png in Resources */ = {isa = PBXBuildFile; fileRef = FAA484E3178108970027B232 /* 144x144.png */; };
@ -33,8 +33,8 @@
/* Begin PBXFileReference section */
97F3580B185F5BB200DDF84D /* capitals.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = capitals.plist; sourceTree = "<group>"; };
FA0ADFF527B1561E00800A86 /* OrganicMapsAPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OrganicMapsAPI.h; path = ../api/OrganicMapsAPI.h; sourceTree = "<group>"; };
FA0ADFF627B1561E00800A86 /* OrganicMapsAPI.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OrganicMapsAPI.m; path = ../api/OrganicMapsAPI.m; sourceTree = "<group>"; };
FA1792CC17784F000092B567 /* MapsWithMeAPI.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MapsWithMeAPI.m; path = ../api/MapsWithMeAPI.m; sourceTree = "<group>"; };
FA1792CD17784F000092B567 /* MapsWithMeAPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MapsWithMeAPI.h; path = ../api/MapsWithMeAPI.h; sourceTree = "<group>"; };
FA776B4D17848A370023F7A0 /* MasterViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MasterViewController.xib; sourceTree = "<group>"; };
FAA484E2178108970027B232 /* 114x114.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = 114x114.png; sourceTree = "<group>"; };
FAA484E3178108970027B232 /* 144x144.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = 144x144.png; sourceTree = "<group>"; };
@ -77,19 +77,19 @@
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
FA1792C7177843650092B567 /* Organic Maps API */ = {
FA1792C7177843650092B567 /* MapsWithMe API */ = {
isa = PBXGroup;
children = (
FA0ADFF527B1561E00800A86 /* OrganicMapsAPI.h */,
FA0ADFF627B1561E00800A86 /* OrganicMapsAPI.m */,
FA1792CD17784F000092B567 /* MapsWithMeAPI.h */,
FA1792CC17784F000092B567 /* MapsWithMeAPI.m */,
);
name = "Organic Maps API";
name = "MapsWithMe API";
sourceTree = "<group>";
};
FAD3DD42177221B500B0735B = {
isa = PBXGroup;
children = (
FA1792C7177843650092B567 /* Organic Maps API */,
FA1792C7177843650092B567 /* MapsWithMe API */,
FAD3DD54177221B500B0735B /* Capitals */,
FAD3DD4D177221B500B0735B /* Frameworks */,
FAD3DD4C177221B500B0735B /* Products */,
@ -178,16 +178,15 @@
FAD3DD43177221B500B0735B /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1320;
ORGANIZATIONNAME = "Organic Maps GmbH";
LastUpgradeCheck = 0720;
ORGANIZATIONNAME = "MapsWithMe GmbH";
};
buildConfigurationList = FAD3DD46177221B500B0735B /* Build configuration list for PBXProject "Capitals" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = en;
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = FAD3DD42177221B500B0735B;
productRefGroup = FAD3DD4C177221B500B0735B /* Products */;
@ -230,9 +229,9 @@
files = (
FAD3DD5B177221B500B0735B /* main.m in Sources */,
FAD3DD5F177221B500B0735B /* AppDelegate.m in Sources */,
FA0ADFF727B1561E00800A86 /* OrganicMapsAPI.m in Sources */,
FAD3DD68177221B500B0735B /* MasterViewController.m in Sources */,
FAD3DD8317724D4A00B0735B /* CityDetailViewController.m in Sources */,
FA1792CE17784F000092B567 /* MapsWithMeAPI.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -243,37 +242,18 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LIBRARY = "compiler-default";
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_CXX_LIBRARY = "libstdc++";
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "iPhone Distribution";
COPY_PHASE_STRIP = YES;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
PRODUCT_NAME = "";
PROVISIONING_PROFILE = "";
@ -290,7 +270,8 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Capitals/Capitals-Prefix.pch";
INFOPLIST_FILE = "Capitals/Capitals-Info.plist";
PRODUCT_BUNDLE_IDENTIFIER = app.organicmaps.api.example.Capitals;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
PRODUCT_BUNDLE_IDENTIFIER = com.mapswithme.api.example.Capitals;
PRODUCT_NAME = "World Capitals";
WRAPPER_EXTENSION = app;
};
@ -300,45 +281,26 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LIBRARY = "compiler-default";
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_CXX_LIBRARY = "libstdc++";
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
COPY_PHASE_STRIP = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
ONLY_ACTIVE_ARCH = YES;
PRODUCT_NAME = "";
SDKROOT = iphoneos;
@ -350,37 +312,18 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LIBRARY = "compiler-default";
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_CXX_LIBRARY = "libstdc++";
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
COPY_PHASE_STRIP = YES;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
PRODUCT_NAME = "";
SDKROOT = iphoneos;
@ -396,7 +339,8 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Capitals/Capitals-Prefix.pch";
INFOPLIST_FILE = "Capitals/Capitals-Info.plist";
PRODUCT_BUNDLE_IDENTIFIER = app.organicmaps.api.example.Capitals;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
PRODUCT_BUNDLE_IDENTIFIER = com.mapswithme.api.example.Capitals;
PRODUCT_NAME = "World Capitals";
WRAPPER_EXTENSION = app;
};
@ -409,7 +353,8 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Capitals/Capitals-Prefix.pch";
INFOPLIST_FILE = "Capitals/Capitals-Info.plist";
PRODUCT_BUNDLE_IDENTIFIER = app.organicmaps.api.example.Capitals;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
PRODUCT_BUNDLE_IDENTIFIER = com.mapswithme.api.example.Capitals;
PRODUCT_NAME = "World Capitals";
WRAPPER_EXTENSION = app;
};

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.4 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.6 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 8.8 KiB

View file

@ -1,6 +1,6 @@
/*******************************************************************************
Copyright (c) 2022, Organic Maps OU
Copyright (c) 2013, MapsWithMe GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without

View file

@ -1,6 +1,6 @@
/*******************************************************************************
Copyright (c) 2022, Organic Maps OU
Copyright (c) 2013, MapsWithMe GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without
@ -30,17 +30,17 @@
#import "MasterViewController.h"
#import "CityDetailViewController.h"
#import "OrganicMapsAPI.h"
#import "MapsWithMeAPI.h"
@implementation AppDelegate
// Organic Maps API entry point, when user comes back to your app
// MapsWithMe API entry point, when user comes back to your app
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
if ([OMApi isOrganicMapsUrl:url])
if ([MWMApi isMapsWithMeUrl:url])
{
// if we got nil, it means that Back button was pressed without selecting any pin
OMPin * pin = [OMApi pinFromUrl:url];
MWMPin * pin = [MWMApi pinFromUrl:url];
if (pin)
{
NSInteger const cityId = [pin.idOrUrl integerValue];

View file

@ -35,10 +35,10 @@
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>CFBundleURLName</key>
<string>app.organicmaps</string>
<string>com.mapswithme.maps</string>
<key>CFBundleURLSchemes</key>
<array>
<string>OMApiExampleCapitals</string>
<string>MapsWithMeApiExampleCapitals</string>
</array>
</dict>
</array>
@ -46,7 +46,7 @@
<string>1.0</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>om</string>
<string>mapswithme</string>
</array>
<key>LSRequiresIPhoneOS</key>
<true/>

View file

@ -1,6 +1,6 @@
/*******************************************************************************
Copyright (c) 2022, Organic Maps OÜ
Copyright (c) 2013, MapsWithMe GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without
@ -28,6 +28,10 @@
#import <Availability.h>
#ifndef __IPHONE_4_3
#warning "This project uses features only available in iOS SDK 4.3 and later."
#endif
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>

View file

@ -1,6 +1,6 @@
/*******************************************************************************
Copyright (c) 2022, Organic Maps
Copyright (c) 2013, MapsWithMe GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without

View file

@ -1,6 +1,6 @@
/*******************************************************************************
Copyright (c) 2022, Organic Maps OU
Copyright (c) 2013, MapsWithMe GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without
@ -28,7 +28,7 @@
#import "CityDetailViewController.h"
#import "OrganicMapsAPI.h"
#import "MapsWithMeAPI.h"
@interface CityDetailViewController ()
@ -51,7 +51,7 @@
pinId = [NSString stringWithFormat:@"http://en.wikipedia.org/wiki/%@", [self urlEncode:self.city[@"name"]]];
else
pinId = [NSString stringWithFormat:@"%@", @(_cityIndex)];
[OMApi showLat:[self.city[@"lat"] doubleValue] lon:[self.city[@"lon"] doubleValue] title:self.city[@"name"] idOrUrl:pinId];
[MWMApi showLat:[self.city[@"lat"] doubleValue] lon:[self.city[@"lon"] doubleValue] title:self.city[@"name"] idOrUrl:pinId];
}
- (void)setCityIndex:(NSInteger)newCityIndex

View file

@ -1,6 +1,6 @@
/*******************************************************************************
Copyright (c) 2022, Organic Maps OU
Copyright (c) 2013, MapsWithMe GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without

View file

@ -1,6 +1,6 @@
/*******************************************************************************
Copyright (c) 2022, Organic Maps OU
Copyright (c) 2013, MapsWithMe GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without
@ -29,7 +29,7 @@
#import "MasterViewController.h"
#import "CityDetailViewController.h"
#import "OrganicMapsAPI.h"
#import "MapsWithMeAPI.h"
@implementation MasterViewController
@ -52,21 +52,21 @@
- (void)showAllCitiesOnTheMap:(id)sender
{
NSMutableArray<OMPin *> * array = [[NSMutableArray alloc] initWithCapacity:[self.capitals count]];
NSMutableArray<MWMPin *> * array = [[NSMutableArray alloc] initWithCapacity:[self.capitals count]];
for (NSInteger i = 0; i < [self.capitals count]; ++i)
{
NSString * pinId = [NSString stringWithFormat:@"%@", @(i)];
// Note that url is empty - it means "More details" button for a pin in Organic Maps will lead back to this example app
// Note that url is empty - it means "More details" button for a pin in MapsWithMe will lead back to this example app
NSDictionary * city = self.capitals[i];
OMPin * pin = [[OMPin alloc] initWithLat:[city[@"lat"] doubleValue] lon:[city[@"lon"] doubleValue] title:city[@"name"] idOrUrl:pinId];
MWMPin * pin = [[MWMPin alloc] initWithLat:[city[@"lat"] doubleValue] lon:[city[@"lon"] doubleValue] title:city[@"name"] idOrUrl:pinId];
[array addObject:pin];
}
// Your should hide any top view objects like UIPopoverController before calling +showPins:
// If user does not installed Organic Maps app, a popup dialog will be shown
// If user does not installed MapsWithMe app, a popup dialog will be shown
[self.detailViewController.masterPopoverController dismissPopoverAnimated:YES];
[OMApi showPins:array];
[MWMApi showPins:array];
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
@ -107,7 +107,7 @@
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 240, tableView.rowHeight)];
label.text = [OMApi isApiSupported] ? @"Organic Maps is installed" : @"Organic Maps is not installed";
label.text = [MWMApi isApiSupported] ? @"MapsWithMe is installed" : @"MapsWithMe is not installed";
label.textAlignment = NSTextAlignmentCenter;
label.backgroundColor = [UIColor clearColor];
return label;

View file

@ -1,6 +1,6 @@
/*******************************************************************************
Copyright (c) 2022, Organic Maps OU
Copyright (c) 2013, MapsWithMe GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB