Code Monkey home page Code Monkey logo

api-ios's Introduction

MAPS.ME iOS API: Getting Started

Introduction

MAPS.ME (MapsWithMe) offline maps API for iOS (hereinafter referred to as API) provides an interface for other applications to perform the following tasks:

For API version 1 (supported by MapsWithMe 2.4+)

  • Open MapsWithMe Application
  • Check that MapsWithMe is installed
  • Show one or more points on an offline map of MapsWithMe 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 MapsWithMe
  • 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
  • Automatically display Download MapsWithMe dialog if MapsWithMe is not installed.

In general it is possible to establish a one way or two way communication between MapsWithMe and your app.

Please check our offline travel guide apps as an API integration example.

Prerequisites

  • Your application must target at least iOS version 5.0
  • For two way communication, you should add unique URL scheme to your app (see below)

Integration

First step is to clone repository or download it as an archive.

When your are done you find two folders: api and capitals-example. First one contains .h and .m files which you need to include into your project. You can always modify them according to your needs.

If you want to get results of API calls, please add unique URL scheme to your app. You can do it with XCode or by editing Info.plist file in your project. To make things simple, use mapswithme keyword in scheme ID, like my_mapswithme_scheme, and create an unique scheme name (or use your existing one). mapswithme keyword in scheme ID simply helps API code to detect it automatically. See more details in Apple's documentation.

MAPS.ME (MapsWithMe) supports two schemes: "mapswithme://" and "mapswithmepro://"

iOS9+ note: you need to add LSApplicationQueriesSchemes key into your plist with value mapswithme to correctly query if MAPS.ME is installed.

capitals-example folder contains sample application which demonstrates part of API features.

NOTE: If you are using Automatic References Counting (ARC) in your project, you can use this solution or simply fix code by yourself.

API Calls Overview and HOW TO

  • 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: method

Simply opens MapsWithMe app:

+ (BOOL)showMap;

Example:

[MWMApi showMap];

Show specified location on the map

Displays given point on a map:

+ (BOOL)showLat:(double)lat lon:(double)lon title:(NSString *)title and:(NSString *)idOrUrl;

The same as above but using pin wrapper:

+ (BOOL)showPin:(MWMPin *)pin;

Pin wrapper is a simple helper to wrap pins displayed on the map:

@interface MWMPin : NSObject
  @property (nonatomic, assign) double lat;
  @property (nonatomic, assign) double lon;
  @property (nonatomic, retain) NSString * title;
  @property (nonatomic, retain) NSString * idOrUrl;
  - (id)initWithLat:(double)lat lon:(double)lon title:(NSString *)title and:(NSString *)idOrUrl;
@end

Example:

[MWMApi showLat:53.9 lon:27.56667 title:@"Minsk - the capital of Belarus" and:@"http://wikipedia.org/wiki/Minsk"];
…
MWMPin * goldenGate = [[MWMPin alloc] init] autorelease];
goldenGate.lat = 37.8195;
goldenGate.lon = -122.4785;
goldenGate.title = @"Golden Gate in San Francisco";
goldenGate.idOrUrl = @"any number or string here you want to receive back in your app, or any url you want to be opened from MapsWithMe";
[MWMApi showPin:goldenGate];

Show any number of pins on the map

+ (BOOL)showPins:(NSArray *)pins;

Receiving results of API calls

When users presses Back button in MapsWithMe, or selects More Info button, he is redirected back to your app. Here are helper methods to obtain API call results:

Returns YES if url is received from MapsWithMe and can be parsed:

+ (BOOL)isMapsWithMeUrl:(NSURL *)url;

Returns nil if user didn't select any pin and simply pressed Back button:

+ (MWMPin *)pinFromUrl:(NSURL *)url;

Example:

if ([MWMApi isMapsWithMeUrl:url])
{
  // Good, here we know that your app was opened from MapsWithMe
  MWMPin * pin = [MWMApi pinFromUrl:url];
  if (pin)
  {
    // User selected specific pin, and we can get it's properties
  }
  else
  {
    // User pressed "Back" button and didn't select any pin
  }
}

Note, that you can simply check that sourceApplication contains com.mapswithme. substring to detect that your app is opened from MapsWithMe.

Check that MapsWithMe is installed

Returns NO if MapsWithMe is not installed or outdated version doesn't support API calls:

+ (BOOL)isApiSupported;

With this method you can check that user needs to install MapsWithMe and display your custom UI. Alternatively, you can do nothing and use built-in dialog which will offer users to install MapsWithMe.

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 on your own, here are some details about the implementation.

Applications "talk" to each other using URL Scheme. API v1 supports the following parameters to the URL Scheme:

mapswithme://map?v=1&ll=54.32123,12.34562&n=Point%20Name&id=AnyStringOrEncodedUrl&backurl=UrlToCallOnBackButton&appname=TitleToDisplayInNavBar
  • 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 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.

When user selects a pin, your app is called like this:

YourAppUniqueUrlScheme://pin?ll=lat,lon&n=PinName&id=PinId

API Code is licensed under the BSD 2-Clause License

Copyright (c) 2019, MY.COM B.V. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • 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.

api-ios's People

Contributors

biodranik avatar gogosapiens avatar melnichek avatar readmecritic avatar vmihaylenko avatar vng avatar zhdanovich avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

api-ios's Issues

ios 9.1

[MWMApi isApiSupported] in ios9.1 returns NO
is was working in ios 9.0
please check!

API link doesn't show pin on the map

I'm trying to open following link from iPhone:

mapswithme://map?v=1&ll=6.2443382,-75.573553&n=Point

It detects maps.me app offering to open it, but once I hit open I don't see pin on the map =(

MWM - Application View

Hi there!

Is there a possibility you extend your API from just launching MAPS.ME to proprietary MapView that can be actually incorporated into 3rd party app?

Regards,
Michael

I can't import .m and .h

Sorry for this stupid question, but I am not able to import files .... it is my first IOS project

  • I read documentation and tried to learn how import .m and .h with reference.
  • I checked your example "Capitals" and it works ...
  • files had been added to my project - MapsWithMeAPI.m MapsWithMeAPI.h
  • Some frameworks lib had been imported too
    screen shot 2017-10-21 at 10 32 18 odp

I got many reference errors after build:
screen shot 2017-10-21 at 10 33 17 odp

Share pin

Hello

Can I share pin from maps.me application to my app? How I should configure my application?

[Question] Localization supported?

I downloaded an app from the AppStore for reference.
However, the language is set to the language of the country in the map and not to the language settings of my iOS.

Is there a language switch feature?

If possible, I'd like to download a map that follows a specific language, not the iOS settings.

Back button no longer appears

In version 8.1.2.1 the back or more info button no longer appears when showing a point in the map, some versions ago it only appeared if you had the map downloaded, now it does not appear at all.

img_3576

It works on android.
f06f90b6-1b79-4f69-aa25-8cd2ed68f78a

new Api for routing

Is it possible to add new api for routing like

  • (BOOL)navigateToPin:(MWMPin *)pin

Latest version of maps.me url-scheme not working

Hey guys,

Huge fan of maps.me! It's integrated with my app, iOverlander. I'm using the url scheme like this:

mapswithme://map?v=1&ll=X,Y&n=SomeName

I've had multiple users report that this is no longer working.

Are you guys aware of the issue? We're seeing it on Android and iOS.

thanks!
sam

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.