├── .github
└── FUNDING.yml
├── capitals-example
├── Capitals
│ ├── 29x29.png
│ ├── 50x50.png
│ ├── 57x57.png
│ ├── 58x58.png
│ ├── 72x72.png
│ ├── 100x100.png
│ ├── 114x114.png
│ ├── 144x144.png
│ ├── Default.png
│ ├── Default@2x.png
│ ├── Default-568h@2x.png
│ ├── MasterViewController.xib
│ ├── main.m
│ ├── Capitals-Prefix.pch
│ ├── MasterViewController.h
│ ├── AppDelegate.h
│ ├── CityDetailViewController.h
│ ├── Capitals-Info.plist
│ ├── AppDelegate.m
│ ├── MasterViewController.m
│ ├── CityDetailViewController.m
│ ├── CityDetailViewController.xib
│ └── capitals.plist
└── Capitals.xcodeproj
│ ├── project.xcworkspace
│ └── contents.xcworkspacedata
│ └── project.pbxproj
├── site-resources
├── download_mwm_dialog.png
└── add_custom_url_scheme.png
├── .gitignore
├── api
├── MapsWithMeAPI.h
└── MapsWithMeAPI.m
└── README.md
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | github: organicmaps
2 | liberapay: OrganicMaps
3 | custom: ["https://organicmaps.app/donate"]
4 |
--------------------------------------------------------------------------------
/capitals-example/Capitals/29x29.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/organicmaps/api-ios/HEAD/capitals-example/Capitals/29x29.png
--------------------------------------------------------------------------------
/capitals-example/Capitals/50x50.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/organicmaps/api-ios/HEAD/capitals-example/Capitals/50x50.png
--------------------------------------------------------------------------------
/capitals-example/Capitals/57x57.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/organicmaps/api-ios/HEAD/capitals-example/Capitals/57x57.png
--------------------------------------------------------------------------------
/capitals-example/Capitals/58x58.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/organicmaps/api-ios/HEAD/capitals-example/Capitals/58x58.png
--------------------------------------------------------------------------------
/capitals-example/Capitals/72x72.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/organicmaps/api-ios/HEAD/capitals-example/Capitals/72x72.png
--------------------------------------------------------------------------------
/capitals-example/Capitals/100x100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/organicmaps/api-ios/HEAD/capitals-example/Capitals/100x100.png
--------------------------------------------------------------------------------
/capitals-example/Capitals/114x114.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/organicmaps/api-ios/HEAD/capitals-example/Capitals/114x114.png
--------------------------------------------------------------------------------
/capitals-example/Capitals/144x144.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/organicmaps/api-ios/HEAD/capitals-example/Capitals/144x144.png
--------------------------------------------------------------------------------
/capitals-example/Capitals/Default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/organicmaps/api-ios/HEAD/capitals-example/Capitals/Default.png
--------------------------------------------------------------------------------
/site-resources/download_mwm_dialog.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/organicmaps/api-ios/HEAD/site-resources/download_mwm_dialog.png
--------------------------------------------------------------------------------
/capitals-example/Capitals/Default@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/organicmaps/api-ios/HEAD/capitals-example/Capitals/Default@2x.png
--------------------------------------------------------------------------------
/site-resources/add_custom_url_scheme.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/organicmaps/api-ios/HEAD/site-resources/add_custom_url_scheme.png
--------------------------------------------------------------------------------
/capitals-example/Capitals/Default-568h@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/organicmaps/api-ios/HEAD/capitals-example/Capitals/Default-568h@2x.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | capitals-example/Capitals.xcodeproj/project.xcworkspace/xcshareddata/
2 | capitals-example/Capitals.xcodeproj/project.xcworkspace/xcuserdata/
3 | capitals-example/Capitals.xcodeproj/xcuserdata/
4 |
--------------------------------------------------------------------------------
/capitals-example/Capitals.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/capitals-example/Capitals/MasterViewController.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/capitals-example/Capitals/main.m:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 |
3 | Copyright (c) 2013, MapsWithMe GmbH
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions are met:
8 |
9 | * Redistributions of source code must retain the above copyright notice, this
10 | list of conditions and the following disclaimer.
11 |
12 | * Redistributions in binary form must reproduce the above copyright notice,
13 | this list of conditions and the following disclaimer in the documentation
14 | and/or other materials provided with the distribution.
15 |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 |
27 | ******************************************************************************/
28 |
29 | #import
30 |
31 | #import "AppDelegate.h"
32 |
33 | int main(int argc, char * argv[])
34 | {
35 | @autoreleasepool
36 | {
37 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/capitals-example/Capitals/Capitals-Prefix.pch:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 |
3 | Copyright (c) 2013, MapsWithMe GmbH
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions are met:
8 |
9 | * Redistributions of source code must retain the above copyright notice, this
10 | list of conditions and the following disclaimer.
11 |
12 | * Redistributions in binary form must reproduce the above copyright notice,
13 | this list of conditions and the following disclaimer in the documentation
14 | and/or other materials provided with the distribution.
15 |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 |
27 | ******************************************************************************/
28 |
29 | #import
30 |
31 | #ifndef __IPHONE_4_3
32 | #warning "This project uses features only available in iOS SDK 4.3 and later."
33 | #endif
34 |
35 | #ifdef __OBJC__
36 | #import
37 | #import
38 | #endif
39 |
--------------------------------------------------------------------------------
/capitals-example/Capitals/MasterViewController.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 |
3 | Copyright (c) 2013, MapsWithMe GmbH
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions are met:
8 |
9 | * Redistributions of source code must retain the above copyright notice, this
10 | list of conditions and the following disclaimer.
11 |
12 | * Redistributions in binary form must reproduce the above copyright notice,
13 | this list of conditions and the following disclaimer in the documentation
14 | and/or other materials provided with the distribution.
15 |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 |
27 | ******************************************************************************/
28 |
29 | #import
30 |
31 | @class CityDetailViewController;
32 |
33 | @interface MasterViewController : UITableViewController
34 |
35 | @property (strong, nonatomic) CityDetailViewController * detailViewController;
36 | @property (strong, nonatomic) NSArray * capitals;
37 |
38 | @end
39 |
--------------------------------------------------------------------------------
/capitals-example/Capitals/AppDelegate.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 |
3 | Copyright (c) 2013, MapsWithMe GmbH
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions are met:
8 |
9 | * Redistributions of source code must retain the above copyright notice, this
10 | list of conditions and the following disclaimer.
11 |
12 | * Redistributions in binary form must reproduce the above copyright notice,
13 | this list of conditions and the following disclaimer in the documentation
14 | and/or other materials provided with the distribution.
15 |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 |
27 | ******************************************************************************/
28 |
29 | #import
30 |
31 | @interface AppDelegate : UIResponder
32 |
33 | @property (strong, nonatomic) UIWindow * window;
34 |
35 | @property (strong, nonatomic) UINavigationController * navigationController;
36 |
37 | @property (strong, nonatomic) UISplitViewController * splitViewController;
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/capitals-example/Capitals/CityDetailViewController.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 |
3 | Copyright (c) 2013, MapsWithMe GmbH
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions are met:
8 |
9 | * Redistributions of source code must retain the above copyright notice, this
10 | list of conditions and the following disclaimer.
11 |
12 | * Redistributions in binary form must reproduce the above copyright notice,
13 | this list of conditions and the following disclaimer in the documentation
14 | and/or other materials provided with the distribution.
15 |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 |
27 | ******************************************************************************/
28 |
29 | #import
30 |
31 | @interface CityDetailViewController : UITableViewController
32 |
33 | @property (nonatomic, assign) NSInteger cityIndex;
34 | @property (strong, nonatomic) NSDictionary * city;
35 | @property (strong, nonatomic) UIPopoverController * masterPopoverController;
36 |
37 | @end
38 |
--------------------------------------------------------------------------------
/capitals-example/Capitals/Capitals-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDisplayName
6 | ${PRODUCT_NAME}
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIconFiles
10 |
11 | 114x114.png
12 | 144x144.png
13 | 100x100.png
14 | 72x72.png
15 | 58x58.png
16 | 57x57.png
17 | 50x50.png
18 | 29x29.png
19 |
20 | CFBundleIdentifier
21 | $(PRODUCT_BUNDLE_IDENTIFIER)
22 | CFBundleInfoDictionaryVersion
23 | 6.0
24 | CFBundleName
25 | ${PRODUCT_NAME}
26 | CFBundlePackageType
27 | APPL
28 | CFBundleShortVersionString
29 | 1.0
30 | CFBundleSignature
31 | ????
32 | CFBundleURLTypes
33 |
34 |
35 | CFBundleTypeRole
36 | Viewer
37 | CFBundleURLName
38 | com.mapswithme.maps
39 | CFBundleURLSchemes
40 |
41 | MapsWithMeApiExampleCapitals
42 |
43 |
44 |
45 | CFBundleVersion
46 | 1.0
47 | LSApplicationQueriesSchemes
48 |
49 | mapswithme
50 |
51 | LSRequiresIPhoneOS
52 |
53 | UIPrerenderedIcon
54 |
55 | UIRequiredDeviceCapabilities
56 |
57 | armv7
58 |
59 | UIStatusBarTintParameters
60 |
61 | UINavigationBar
62 |
63 | Style
64 | UIBarStyleDefault
65 | Translucent
66 |
67 |
68 |
69 | UISupportedInterfaceOrientations
70 |
71 | UIInterfaceOrientationPortrait
72 | UIInterfaceOrientationLandscapeLeft
73 | UIInterfaceOrientationLandscapeRight
74 | UIInterfaceOrientationPortraitUpsideDown
75 |
76 | UISupportedInterfaceOrientations~ipad
77 |
78 | UIInterfaceOrientationPortrait
79 | UIInterfaceOrientationPortraitUpsideDown
80 | UIInterfaceOrientationLandscapeLeft
81 | UIInterfaceOrientationLandscapeRight
82 |
83 |
84 |
85 |
--------------------------------------------------------------------------------
/api/MapsWithMeAPI.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 |
3 | Copyright (c) 2014, MapsWithMe GmbH
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions are met:
8 |
9 | * Redistributions of source code must retain the above copyright notice, this
10 | list of conditions and the following disclaimer.
11 |
12 | * Redistributions in binary form must reproduce the above copyright notice,
13 | this list of conditions and the following disclaimer in the documentation
14 | and/or other materials provided with the distribution.
15 |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 |
27 | ******************************************************************************/
28 |
29 | #import
30 |
31 | #if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_7_0
32 | #error "maps.me supports iOS >= 7.0 only"
33 | #endif
34 |
35 | // Wrapper for a pin on a map
36 | @interface MWMPin : NSObject
37 | /// [required] pin latitude
38 | @property (nonatomic) double lat;
39 | /// [required] pin longitude
40 | @property (nonatomic) double lon;
41 | /// [optional] pin title
42 | @property (nullable, copy, nonatomic) NSString * title;
43 | /// [optional] passed back to the app when pin is clicked, OR, if it's a valid url,
44 | /// it will be opened from MapsWithMe after selecting "More Details..." for the pin
45 | @property (nullable, copy, nonatomic) NSString * idOrUrl;
46 |
47 | - (nullable instancetype)initWithLat:(double)lat
48 | lon:(double)lon
49 | title:(nullable NSString *)title
50 | idOrUrl:(nullable NSString *)idOrUrl;
51 |
52 | @end
53 |
54 |
55 | // MapsWithMe API interface
56 | @interface MWMApi : NSObject
57 |
58 | /// returns YES if url is received from MapsWithMe and can be parsed
59 | + (BOOL)isMapsWithMeUrl:(nonnull NSURL *)url;
60 | /// returns nil if user didn't select any pin and simply pressed "Back" button
61 | + (nullable MWMPin *)pinFromUrl:(nonnull NSURL *)url;
62 | /// returns NO if MapsWithMe is not installed or outdated version doesn't support API calls
63 | + (BOOL)isApiSupported;
64 | /// Simply opens MapsWithMe app
65 | + (BOOL)showMap;
66 | /// Displays given point on a map, title and id are optional.
67 | /// If id contains valid url, it will be opened from MapsWithMe after selecting "More Details..." for the pin
68 | + (BOOL)showLat:(double)lat lon:(double)lon title:(nullable NSString *)title idOrUrl:(nullable NSString *)idOrUrl;
69 | /// The same as above but using pin wrapper
70 | + (BOOL)showPin:(nullable MWMPin *)pin;
71 | /// Displays any number of pins
72 | + (BOOL)showPins:(nonnull NSArray *)pins;
73 | //
74 | + (void)showMapsWithMeIsNotInstalledDialog;
75 | /// Set value = YES if you want to open pin URL on balloon click, default value is NO
76 | + (void)setOpenUrlOnBalloonClick:(BOOL)value;
77 |
78 | @end
79 |
--------------------------------------------------------------------------------
/capitals-example/Capitals/AppDelegate.m:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 |
3 | Copyright (c) 2013, MapsWithMe GmbH
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions are met:
8 |
9 | * Redistributions of source code must retain the above copyright notice, this
10 | list of conditions and the following disclaimer.
11 |
12 | * Redistributions in binary form must reproduce the above copyright notice,
13 | this list of conditions and the following disclaimer in the documentation
14 | and/or other materials provided with the distribution.
15 |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 |
27 | ******************************************************************************/
28 |
29 | #import "AppDelegate.h"
30 | #import "MasterViewController.h"
31 | #import "CityDetailViewController.h"
32 |
33 | #import "MapsWithMeAPI.h"
34 |
35 | @implementation AppDelegate
36 |
37 | // MapsWithMe API entry point, when user comes back to your app
38 | - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
39 | {
40 | if ([MWMApi isMapsWithMeUrl:url])
41 | {
42 | // if we got nil, it means that Back button was pressed without selecting any pin
43 | MWMPin * pin = [MWMApi pinFromUrl:url];
44 | if (pin)
45 | {
46 | NSInteger const cityId = [pin.idOrUrl integerValue];
47 | // display selected page based on passed id
48 | if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone)
49 | {
50 | [self.navigationController popToRootViewControllerAnimated:NO];
51 | MasterViewController * masterVC = self.navigationController.viewControllers[0];
52 | if (!masterVC.detailViewController)
53 | masterVC.detailViewController = [[CityDetailViewController alloc] initWithNibName:@"CityDetailViewController" bundle:nil];
54 | masterVC.detailViewController.city = masterVC.capitals[cityId];
55 | masterVC.detailViewController.cityIndex = cityId;
56 | [masterVC.navigationController pushViewController:masterVC.detailViewController animated:YES];
57 | }
58 | else
59 | {
60 | CityDetailViewController * detailVC = (CityDetailViewController *)self.splitViewController.delegate;
61 | detailVC.cityIndex = cityId;
62 | }
63 | }
64 | return YES;
65 | }
66 | return NO;
67 | }
68 |
69 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
70 | {
71 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
72 |
73 | if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone)
74 | {
75 | MasterViewController * masterViewController = [[MasterViewController alloc] initWithNibName:@"MasterViewController" bundle:nil];
76 | self.navigationController = [[UINavigationController alloc] initWithRootViewController:masterViewController];
77 | self.window.rootViewController = self.navigationController;
78 | }
79 | else
80 | {
81 | MasterViewController * masterViewController = [[MasterViewController alloc] initWithNibName:@"MasterViewController" bundle:nil];
82 | UINavigationController * masterNavigationController = [[UINavigationController alloc] initWithRootViewController:masterViewController];
83 |
84 | CityDetailViewController * detailViewController = [[CityDetailViewController alloc] initWithNibName:@"CityDetailViewController" bundle:nil];
85 | UINavigationController * detailNavigationController = [[UINavigationController alloc] initWithRootViewController:detailViewController];
86 |
87 | masterViewController.detailViewController = detailViewController;
88 |
89 | self.splitViewController = [[UISplitViewController alloc] init];
90 | self.splitViewController.delegate = detailViewController;
91 | self.splitViewController.viewControllers = @[masterNavigationController, detailNavigationController];
92 |
93 | self.window.rootViewController = self.splitViewController;
94 | }
95 |
96 | [self.window makeKeyAndVisible];
97 | return YES;
98 | }
99 |
100 | @end
101 |
--------------------------------------------------------------------------------
/capitals-example/Capitals/MasterViewController.m:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 |
3 | Copyright (c) 2013, MapsWithMe GmbH
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions are met:
8 |
9 | * Redistributions of source code must retain the above copyright notice, this
10 | list of conditions and the following disclaimer.
11 |
12 | * Redistributions in binary form must reproduce the above copyright notice,
13 | this list of conditions and the following disclaimer in the documentation
14 | and/or other materials provided with the distribution.
15 |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 |
27 | ******************************************************************************/
28 |
29 | #import "MasterViewController.h"
30 | #import "CityDetailViewController.h"
31 |
32 | #import "MapsWithMeAPI.h"
33 |
34 | @implementation MasterViewController
35 |
36 | - (CityDetailViewController *)detailViewController
37 | {
38 | if (!_detailViewController)
39 | _detailViewController = [[CityDetailViewController alloc] initWithNibName:@"CityDetailViewController" bundle:nil];
40 | return _detailViewController;
41 | }
42 |
43 | - (NSArray *)capitals
44 | {
45 | if (!_capitals)
46 | {
47 | NSString * path = [[NSBundle mainBundle] pathForResource:@"capitals" ofType:@"plist"];
48 | _capitals = [NSArray arrayWithContentsOfFile:path];
49 | }
50 | return _capitals;
51 | }
52 |
53 | - (void)showAllCitiesOnTheMap:(id)sender
54 | {
55 | NSMutableArray * array = [[NSMutableArray alloc] initWithCapacity:[self.capitals count]];
56 |
57 | for (NSInteger i = 0; i < [self.capitals count]; ++i)
58 | {
59 | NSString * pinId = [NSString stringWithFormat:@"%@", @(i)];
60 | // Note that url is empty - it means "More details" button for a pin in MapsWithMe will lead back to this example app
61 | NSDictionary * city = self.capitals[i];
62 | MWMPin * pin = [[MWMPin alloc] initWithLat:[city[@"lat"] doubleValue] lon:[city[@"lon"] doubleValue] title:city[@"name"] idOrUrl:pinId];
63 | [array addObject:pin];
64 | }
65 | // Your should hide any top view objects like UIPopoverController before calling +showPins:
66 | // If user does not installed MapsWithMe app, a popup dialog will be shown
67 | [self.detailViewController.masterPopoverController dismissPopoverAnimated:YES];
68 |
69 | [MWMApi showPins:array];
70 | }
71 |
72 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
73 | {
74 | self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
75 | if (self)
76 | {
77 | self.title = NSLocalizedString(@"World Capitals", nil);
78 | if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad)
79 | {
80 | self.clearsSelectionOnViewWillAppear = NO;
81 | self.preferredContentSize = CGSizeMake(320.0, 600.0);
82 | }
83 | }
84 | return self;
85 | }
86 |
87 | - (void)viewDidLoad
88 | {
89 | [super viewDidLoad];
90 |
91 | UIBarButtonItem * showMapButton = [[UIBarButtonItem alloc] initWithTitle:@"Show All" style:UIBarButtonItemStyleDone target:self action:@selector(showAllCitiesOnTheMap:)];
92 | self.navigationItem.rightBarButtonItem = showMapButton;
93 | }
94 |
95 | #pragma mark - Table View
96 |
97 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
98 | {
99 | return 1;
100 | }
101 |
102 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
103 | {
104 | return [self.capitals count];
105 | }
106 |
107 | - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
108 | {
109 | UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 240, tableView.rowHeight)];
110 | label.text = [MWMApi isApiSupported] ? @"MapsWithMe is installed" : @"MapsWithMe is not installed";
111 | label.textAlignment = NSTextAlignmentCenter;
112 | label.backgroundColor = [UIColor clearColor];
113 | return label;
114 | }
115 |
116 | - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
117 | {
118 | return tableView.rowHeight / 2;
119 | }
120 |
121 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
122 | {
123 | static NSString * cellId = @"MasterCell";
124 |
125 | UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellId];
126 | if (cell == nil)
127 | {
128 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
129 | if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone)
130 | cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
131 | }
132 |
133 | cell.textLabel.text = self.capitals[indexPath.row][@"name"];
134 | return cell;
135 | }
136 |
137 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
138 | {
139 | self.detailViewController.city = self.capitals[indexPath.row];
140 | self.detailViewController.cityIndex = indexPath.row;
141 | if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone)
142 | [self.navigationController pushViewController:self.detailViewController animated:YES];
143 | }
144 |
145 | @end
146 |
--------------------------------------------------------------------------------
/capitals-example/Capitals/CityDetailViewController.m:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 |
3 | Copyright (c) 2013, MapsWithMe GmbH
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions are met:
8 |
9 | * Redistributions of source code must retain the above copyright notice, this
10 | list of conditions and the following disclaimer.
11 |
12 | * Redistributions in binary form must reproduce the above copyright notice,
13 | this list of conditions and the following disclaimer in the documentation
14 | and/or other materials provided with the distribution.
15 |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 |
27 | ******************************************************************************/
28 |
29 | #import "CityDetailViewController.h"
30 |
31 | #import "MapsWithMeAPI.h"
32 |
33 | @interface CityDetailViewController ()
34 |
35 | - (void)configureView;
36 |
37 | @end
38 |
39 |
40 | @implementation CityDetailViewController
41 |
42 | - (NSString *)urlEncode:(NSString *)str
43 | {
44 | return (__bridge_transfer NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)str, NULL, CFSTR("!$&'()*+,-./:;=?@_~"), kCFStringEncodingUTF8);
45 | }
46 |
47 | - (void)showCapitalOnTheMap:(BOOL)withLink
48 | {
49 | NSString * pinId;
50 | if (withLink)
51 | pinId = [NSString stringWithFormat:@"http://en.wikipedia.org/wiki/%@", [self urlEncode:self.city[@"name"]]];
52 | else
53 | pinId = [NSString stringWithFormat:@"%@", @(_cityIndex)];
54 | [MWMApi showLat:[self.city[@"lat"] doubleValue] lon:[self.city[@"lon"] doubleValue] title:self.city[@"name"] idOrUrl:pinId];
55 | }
56 |
57 | - (void)setCityIndex:(NSInteger)newCityIndex
58 | {
59 | if (_cityIndex != newCityIndex)
60 | {
61 | _cityIndex = newCityIndex;
62 | // Update the view.
63 | [self configureView];
64 | }
65 |
66 | if (self.masterPopoverController)
67 | [self.masterPopoverController dismissPopoverAnimated:YES];
68 | }
69 |
70 | - (void)configureView
71 | {
72 | self.title = self.city[@"name"];
73 | [self.tableView reloadData];
74 | }
75 |
76 | - (void)viewDidLoad
77 | {
78 | [super viewDidLoad];
79 | [self configureView];
80 | }
81 |
82 | #pragma mark - Table view data source
83 |
84 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
85 | {
86 | return 3;
87 | }
88 |
89 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
90 | {
91 | return section == 0 ? 5 : 1;
92 | }
93 |
94 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
95 | {
96 | NSString * cellId = [NSString stringWithFormat:@"%@%@", @(indexPath.section), @(indexPath.row)];
97 | UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellId];
98 | if (cell == nil)
99 | {
100 | if (indexPath.section == 0)
101 | {
102 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellId];
103 | cell.selectionStyle = UITableViewCellSelectionStyleNone;
104 | switch (indexPath.row)
105 | {
106 | case 0: cell.textLabel.text = @"Latitude"; break;
107 | case 1: cell.textLabel.text = @"Longitude"; break;
108 | case 2: cell.textLabel.text = @"Country Code"; break;
109 | case 3: cell.textLabel.text = @"Population"; break;
110 | case 4: cell.textLabel.text = @"Time Zone"; break;
111 | default: break;
112 | }
113 | }
114 | else
115 | {
116 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
117 | cell.textLabel.textAlignment = NSTextAlignmentCenter;
118 | if (indexPath.section == 1)
119 | cell.textLabel.text = @"Show map and come back";
120 | else
121 | cell.textLabel.text = @"Show map and read Wikipedia";
122 | }
123 | }
124 |
125 | if (indexPath.section == 0)
126 | {
127 | switch (indexPath.row)
128 | {
129 | case 0: cell.detailTextLabel.text = [self.city[@"lat"] stringValue]; break;
130 | case 1: cell.detailTextLabel.text = [self.city[@"lon"] stringValue]; break;
131 | case 2: cell.detailTextLabel.text = self.city[@"countryCode"]; break;
132 | case 3: cell.detailTextLabel.text = [self.city[@"population"] stringValue]; break;
133 | case 4: cell.detailTextLabel.text = self.city[@"timeZone"]; break;
134 | default: break;
135 | }
136 | }
137 | return cell;
138 | }
139 |
140 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
141 | {
142 | [self.tableView deselectRowAtIndexPath:indexPath animated:YES];
143 | switch (indexPath.section)
144 | {
145 | case 1: [self showCapitalOnTheMap:NO]; break;
146 | case 2: [self showCapitalOnTheMap:YES]; break;
147 | default: break;
148 | }
149 | }
150 |
151 | #pragma mark - Split view
152 |
153 | - (void)splitViewController:(UISplitViewController *)splitController willHideViewController:(UIViewController *)viewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController:(UIPopoverController *)popoverController
154 | {
155 | barButtonItem.title = NSLocalizedString(@"World Capitals", nil);
156 | [self.navigationItem setLeftBarButtonItem:barButtonItem animated:YES];
157 | self.masterPopoverController = popoverController;
158 | }
159 |
160 | - (void)splitViewController:(UISplitViewController *)splitController willShowViewController:(UIViewController *)viewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem
161 | {
162 | // Called when the view is shown again in the split view, invalidating the button and popover controller.
163 | [self.navigationItem setLeftBarButtonItem:nil animated:YES];
164 | self.masterPopoverController = nil;
165 | }
166 |
167 | @end
168 |
--------------------------------------------------------------------------------
/capitals-example/Capitals/CityDetailViewController.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 1552
5 | 12E55
6 | 3084
7 | 1187.39
8 | 626.00
9 |
13 |
14 | IBProxyObject
15 | IBUITableView
16 |
17 |
18 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin
19 |
20 |
24 |
25 |
29 |
33 |
78 |
79 |
80 |
81 |
82 |
83 | view
84 |
85 |
86 |
87 | 11
88 |
89 |
90 |
91 | dataSource
92 |
93 |
94 |
95 | 9
96 |
97 |
98 |
99 | delegate
100 |
101 |
102 |
103 | 10
104 |
105 |
106 |
107 |
108 |
109 | 0
110 |
111 |
112 |
113 |
114 |
115 | -1
116 |
117 |
118 | File's Owner
119 |
120 |
121 | -2
122 |
123 |
124 |
125 |
126 | 8
127 |
128 |
129 |
130 |
131 |
132 |
133 | CityDetailViewController
134 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin
135 | UIResponder
136 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin
137 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin
138 |
139 |
140 |
141 |
142 |
143 | 11
144 |
145 |
146 |
147 |
148 | CityDetailViewController
149 | UITableViewController
150 |
151 | IBProjectSource
152 | ./Classes/CityDetailViewController.h
153 |
154 |
155 |
156 |
157 | 0
158 | IBIPadFramework
159 | YES
160 | 3
161 | YES
162 | 2083
163 |
164 |
165 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## MAPS.ME iOS API: Getting Started
2 |
3 | ### Introduction
4 |
5 | MAPS.ME (MapsWithMe) offline maps API for iOS (hereinafter referred to as *API*) provides an interface for other applications to perform the following tasks:
6 |
7 | For API version 1 (supported by MapsWithMe 2.4+)
8 | * Open [MapsWithMe Application][linkMwm]
9 | * Check that [MapsWithMe][linkMwm] is installed
10 | * Show one or more points on an offline map of [MapsWithMe][linkMwm] with *Back* button and client app name in the title
11 | * Return the user back to the client application:
12 | * after pressing *Back* button on the map
13 | * after selecting specific point on the map if user asks for more information by pressing *More Info* button in [MapsWithMe][linkMwm]
14 | * 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]
15 | * Automatically display [*Download MapsWithMe*][linkDownloadMWMDialog] dialog if [MapsWithMe][linkMwm] is not installed.
16 |
17 | In general it is possible to establish a one way or two way communication between MapsWithMe and your app.
18 |
19 | Please check our [offline travel guide apps][linkTravelGuides] as an API integration example.
20 |
21 | ### Prerequisites
22 |
23 | * Your application must target at least *iOS version 5.0*
24 | * For two way communication, you should add unique [URL scheme][linkAppleCustomUrlSchemes] to your app (see below)
25 |
26 | ### Integration
27 |
28 | First step is to clone [repository][linkRepo] or download it as an archive.
29 |
30 | When your are done you find two folders: *api* and *capitals-example*.
31 | First one contains .h and .m files which you need to include into your project. You can always modify them according to your needs.
32 |
33 | 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).
34 | *mapswithme* keyword in scheme ID simply helps API code to detect it automatically. See more details in [Apple's documentation][linkAppleCustomUrlSchemes].
35 |
36 | MAPS.ME (MapsWithMe) supports two schemes: "mapswithme://" and "mapswithmepro://"
37 |
38 | iOS9+ note: you need to add LSApplicationQueriesSchemes key into your plist with value mapswithme to correctly query if MAPS.ME is installed.
39 |
40 | *capitals-example* folder contains sample application which demonstrates part of API features.
41 |
42 | *NOTE: If you are using Automatic References Counting (ARC) in your project, you can use [this solution][linkFixARC] or simply fix code by yourself.*
43 |
44 | ### API Calls Overview and HOW TO
45 |
46 | * All methods are static for *MWMApi* class, *BOOL* methods return *NO* if call is failed.
47 | * If id for given pin contains valid url, it will be opened from MapsWithMe after selecting *More Info* button.
48 | For any other content, id will be simply passed back to the caller's [*AppDelegate application:openURL:sourceApplication:annotation:*][linkAppleDelegate] method
49 |
50 | #### Open [MapsWithMe Application][linkMwm]
51 |
52 | Simply opens MapsWithMe app:
53 |
54 | + (BOOL)showMap;
55 |
56 | Example:
57 |
58 | [MWMApi showMap];
59 |
60 | #### Show specified location on the map
61 |
62 | Displays given point on a map:
63 |
64 | + (BOOL)showLat:(double)lat lon:(double)lon title:(NSString *)title and:(NSString *)idOrUrl;
65 |
66 | The same as above but using pin wrapper:
67 |
68 | + (BOOL)showPin:(MWMPin *)pin;
69 |
70 | Pin wrapper is a simple helper to wrap pins displayed on the map:
71 |
72 | @interface MWMPin : NSObject
73 | @property (nonatomic, assign) double lat;
74 | @property (nonatomic, assign) double lon;
75 | @property (nonatomic, retain) NSString * title;
76 | @property (nonatomic, retain) NSString * idOrUrl;
77 | - (id)initWithLat:(double)lat lon:(double)lon title:(NSString *)title and:(NSString *)idOrUrl;
78 | @end
79 |
80 | Example:
81 |
82 | [MWMApi showLat:53.9 lon:27.56667 title:@"Minsk - the capital of Belarus" and:@"http://wikipedia.org/wiki/Minsk"];
83 | …
84 | MWMPin * goldenGate = [[MWMPin alloc] init] autorelease];
85 | goldenGate.lat = 37.8195;
86 | goldenGate.lon = -122.4785;
87 | goldenGate.title = @"Golden Gate in San Francisco";
88 | 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";
89 | [MWMApi showPin:goldenGate];
90 |
91 | #### Show any number of pins on the map
92 |
93 | + (BOOL)showPins:(NSArray *)pins;
94 |
95 | #### Receiving results of API calls
96 |
97 | When users presses *Back* button in MapsWithMe, or selects *More Info* button, he is redirected back to your app.
98 | Here are helper methods to obtain API call results:
99 |
100 | Returns YES if url is received from MapsWithMe and can be parsed:
101 |
102 | + (BOOL)isMapsWithMeUrl:(NSURL *)url;
103 |
104 | Returns nil if user didn't select any pin and simply pressed *Back* button:
105 |
106 | + (MWMPin *)pinFromUrl:(NSURL *)url;
107 |
108 | Example:
109 |
110 | if ([MWMApi isMapsWithMeUrl:url])
111 | {
112 | // Good, here we know that your app was opened from MapsWithMe
113 | MWMPin * pin = [MWMApi pinFromUrl:url];
114 | if (pin)
115 | {
116 | // User selected specific pin, and we can get it's properties
117 | }
118 | else
119 | {
120 | // User pressed "Back" button and didn't select any pin
121 | }
122 | }
123 |
124 | Note, that you can simply check that *sourceApplication* contains *com.mapswithme.* substring to detect that your app is opened from MapsWithMe.
125 |
126 | #### Check that MapsWithMe is installed
127 |
128 | Returns NO if MapsWithMe is not installed or outdated version doesn't support API calls:
129 |
130 | + (BOOL)isApiSupported;
131 |
132 | With this method you can check that user needs to install MapsWithMe and display your custom UI.
133 | Alternatively, you can do nothing and use built-in dialog which will offer users to install MapsWithMe.
134 |
135 | ### Set value if you want to open pin URL on balloon click (Available in 2.4.5)
136 |
137 | + (void)setOpenUrlOnBalloonClick:(BOOL)value;
138 |
139 | ### Under the hood
140 |
141 | If you prefer to use API on your own, here are some details about the implementation.
142 |
143 | Applications "talk" to each other using URL Scheme. API v1 supports the following parameters to the URL Scheme:
144 |
145 | mapswithme://map?v=1&ll=54.32123,12.34562&n=Point%20Name&id=AnyStringOrEncodedUrl&backurl=UrlToCallOnBackButton&appname=TitleToDisplayInNavBar
146 |
147 | * **v** - API version, currently *1*
148 | * **ll** - pin latitude and longitude, comma-separated
149 | * **n** - pin title
150 | * **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
151 | * **backurl** - usually, your unique app scheme to open back your app
152 | * **appname** - string to display in navigation bar on top of the map in MAPS.ME
153 | * **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)
154 |
155 | 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.
156 |
157 | When user selects a pin, your app is called like this:
158 |
159 | YourAppUniqueUrlScheme://pin?ll=lat,lon&n=PinName&id=PinId
160 |
161 | ------------------------------------------------------------------------------------------
162 | ### API Code is licensed under the BSD 2-Clause License
163 |
164 | Copyright (c) 2019, MY.COM B.V.
165 | All rights reserved.
166 |
167 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
168 |
169 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
170 | * 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.
171 |
172 | 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.
173 |
174 | [linkMwm]: https://maps.me/ "MAPS.ME - offline maps of the world"
175 | [linkRepo]: https://github.com/mapsme/api-ios "GitHub Repository"
176 | [linkAddUrlScheme]: https://raw.github.com/mapswithme/api-ios/site-resources/add_custom_url_scheme.png "How to add url scheme in XCode"
177 | [linkDownloadMWMDialog]: https://raw.github.com/mapswithme/api-ios/site-resources/download_mwm_dialog.png "Donwload MAPS.ME Dialog"
178 | [linkIssues]: https://github.com/mapsme/api-ios/issues "Post a bug or feature request"
179 | [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"
180 | [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"
181 | [linkFixARC]: http://stackoverflow.com/a/6658549/1209392 "How to compile non-ARC code in ARC projects"
182 | [linkTravelGuides]: http://guidewithme.com "Offline Travel Guides"
183 |
--------------------------------------------------------------------------------
/api/MapsWithMeAPI.m:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 |
3 | Copyright (c) 2014, MapsWithMe GmbH
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions are met:
8 |
9 | * Redistributions of source code must retain the above copyright notice, this
10 | list of conditions and the following disclaimer.
11 |
12 | * Redistributions in binary form must reproduce the above copyright notice,
13 | this list of conditions and the following disclaimer in the documentation
14 | and/or other materials provided with the distribution.
15 |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 |
27 | ******************************************************************************/
28 |
29 | #import "MapsWithMeAPI.h"
30 |
31 | #define MAPSWITHME_API_VERSION 1.1
32 |
33 | static NSString * const kMWMUrlScheme = @"mapswithme://";
34 | static BOOL kOpenUrlOnBalloonClick = NO;
35 |
36 | @implementation MWMPin
37 |
38 | - (nullable instancetype)init
39 | {
40 | self = [super init];
41 | if (self)
42 | {
43 | _lat = INFINITY;
44 | _lon = INFINITY;
45 | }
46 | return self;
47 | }
48 |
49 | - (nullable instancetype)initWithLat:(double)lat
50 | lon:(double)lon
51 | title:(nullable NSString *)title
52 | idOrUrl:(nullable NSString *)idOrUrl
53 | {
54 | self = [super init];
55 | if (self)
56 | {
57 | _lat = lat;
58 | _lon = lon;
59 | _title = title;
60 | _idOrUrl = idOrUrl;
61 | }
62 | return self;
63 | }
64 |
65 | @end
66 |
67 | // Utility class to automatically handle "MapsWithMe is not installed" situations
68 | @interface MWMNViewController : UIViewController
69 |
70 | @end
71 |
72 | @implementation MWMNViewController
73 |
74 | // HTML page for users who didn't install MapsWithMe
75 | static NSString * const mapsWithMeIsNotInstalledPage =
76 | @"" \
77 | "" \
78 | "Please install MAPS.ME - offline maps of the World" \
79 | "" \
80 | "" \
81 | "" \
89 | "" \
90 | "" \
91 | "
Offline maps are required to proceed. We have partnered with MAPS.ME to provide you with offline maps of the entire world.