# Get Started

## Functions and structure

To keep applications lightweight we divided framework to 3 major components: **GLMap**, **GLRoute**, **GLSearch**. No need to include navigation or search into your project if you don't use it.

On iOS to make application fast each component published as dynamic framework and as static library. Names of static pods is **GLMapStatic**, **GLRouteStatic**, **GLSearchStatic**. When linked with static library, linker is able to remove all unused code and optimize application even further.

Swift modules and Android native libraries is always compiled as dynamic libraries.

Some sytax sugar for Swift is added as **GLMapSwift** extension. It is open source and available on github: <https://github.com/GLMap/GLMapSwift>&#x20;

## iOS <a href="#ios" id="ios"></a>

### Cocoapods

* Run `pod repo update` to make CocoaPods aware of the latest available GLMap versions.
* Add `GLMap` into your Podfile

{% code title="Podfile" %}

```ruby
platform :ios, '8.0'
use_frameworks!

target 'TargetName' do
    pod 'GLMap'
    pod 'GLRoute' # if you need navgation
    pod 'GLSearch' # if you need search 
end
```

{% endcode %}

* Run `pod install` in project directory
* Use the **.xcworkspace** file generated by CocoaPods to work on your project.&#x20;

### Carthage

All components is published in Carthage as binary-only frameworks.

To add it into your project just add binary dependency into your `Cartfile`

{% code title="Cartfile" %}

```
binary "https://user.getyourmap.com/downloads/free/GLMap.json"
binary "https://user.getyourmap.com/downloads/free/GLRoute.json" # if you need navigation
binary "https://user.getyourmap.com/downloads/free/GLSearch.json" # if you need search
```

{% endcode %}

Unfortunately there is no way to add resource dependencies into Carhage, and you'll need to add them manually into your project.

GLMap requires **world map** and **default style** to work correctly. Download links to **GLMapWorldMap** and **GLMapDefaultStyle** you could find inside .json files and in [user cabinet](https://user.getyourmap.com/changelogs).

For convenience we published all releases info json files:

```swift
https://user.getyourmap.com/downloads/free/GLMap.json
https://user.getyourmap.com/downloads/free/GLMapStatic.json
https://user.getyourmap.com/downloads/free/GLRoute.json
https://user.getyourmap.com/downloads/free/GLRouteStatic.json
https://user.getyourmap.com/downloads/free/GLSearch.json
https://user.getyourmap.com/downloads/free/GLSearchStatic.json
https://user.getyourmap.com/downloads/free/GLMapDefaultStyle.json
https://user.getyourmap.com/downloads/free/GLMapWorldMap.json
```

### Use framework from Objective-C

Initialize `GLMapManager` inside `AppDelegate`. And set your API key from [user cabinet](https://user.getyourmap.com/apps).

{% code title="AppDelegate.m" %}

```objectivec
#import <GLMap/GLMap.h>
@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [GLMapManager sharedManager].apiKey = <#API key#>;
    return YES;
}
```

{% endcode %}

Then add `GLMapView` into view hierarchy from code or using Interface Builder.

{% code title="ViewController.m" %}

```objectivec
#import <GLMap/GLMap.h>

@implementation ViewController
-(void)viewDidLoad {
    GLMapView *mapView = [[GLMapView alloc] initWithFrame:self.view.bounds];
    [self.view addSubview:mapView];
}
```

{% endcode %}

Now you're ready to write your app with GLMap framework. Consider our Demo App as source of examples and code snippets.

[Objective-C Demo App](https://github.com/GLMap/examples-ios/tree/master/ObjCDemo) / [iOS API Documentation](https://getyourmap.com/docs/objc/api/latest/)

### Use framework from Swift

Initialize `GLMapManager` inside `AppDelegate`. And set your API key from [user cabinet](https://user.getyourmap.com/apps).

{% code title="AppDelegate.swift" %}

```swift
import GLMap
import GLMapSwift

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        GLMapManager.shared.apiKey = <#API key#>
        return true
    }
}
```

{% endcode %}

Then add `GLMapView` into view hierarchy from code or using Interface Builder.

{% code title="ViewController.swift" %}

```swift
class ViewController: UIViewController {    
    override func viewDidLoad() {
        super.viewDidLoad()

        let mapView = GLMapView(frame: self.view.bounds)
        self.view.addSubview(mapView)
    }
}
```

{% endcode %}

Now you're ready to write your app with GLMap framework. Consider our Demo App as source of examples and code snippets.

[Swift Demo App](https://github.com/GLMap/examples-ios/tree/master/SwiftDemo) / [iOS API Documentation](https://getyourmap.com/docs/objc/api/latest/) / [Swift Extenstion API Documentation](https://getyourmap.com/docs/swift/api/latest/)

## Android <a href="#android" id="android"></a>

### Maven

Add repository and dependency into module level build.gradle file.

{% code title="build.gradle" %}

```ruby
repositories {
    // Any other repositories
    maven { url 'https://maven.getyourmap.com/artifactory/libs' }
}

dependencies {
    // Any other dependencies
    implementation'com.getyourmap:glmap:1.1.0'
    implementation'com.getyourmap:glroute:1.1.0' // if you need navigation
    implementation'com.getyourmap:glsearch:1.1.0' // if you need search
}
```

{% endcode %}

### Use framework from Java

Add `GLMapView` into layout file

```ruby
<com.getyourmap.glmap.GLMapView
    android:id="@+id/map_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:keepScreenOn="true"/>
```

Initialize `GLMapManager` inside `Application` subclass. And set your API key from [user cabinet](https://user.getyourmap.com/apps).

{% code title="YourApp.java" %}

```java
public class YourApp extends Application
{
@Override
    public void onCreate()
    {
        super.onCreate();
        GLMapManager.Initialize(this, <API_KEY>, null);
        
        // If you're going to use GLSearch you should also call 
        // GLSearch.Initialize(this); 
        // to let it load it's resources. 
    }
}
```

{% endcode %}

Then configure `GLMapView`.

{% code title="YourActivity.java" %}

```java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // set asset manager, and load style from bundle inside assets
    GLMapView mapView = (GLMapView) this.findViewById(R.id.map_view);
    mapView.loadStyle(this.getAssets(), "DefaultStyle.bundle");
}
```

{% endcode %}

Now you're ready to write your app with GLMap framework. Consider our Demo App as source of examples and code snippets.

[Android Demo App](https://github.com/GLMap/examples-android/) / [Android API Documentation](https://getyourmap.com/docs/java/api/latest/)
