GithubHelp home page GithubHelp logo

starikovvm / yandex_mapkit Goto Github PK

View Code? Open in Web Editor NEW

This project forked from unact/yandex_mapkit

0.0 1.0 0.0 546 KB

License: MIT License

Java 26.44% Ruby 0.85% Swift 20.39% Objective-C 0.11% Dart 52.20%

yandex_mapkit's Introduction

yandex_mapkit

A flutter plugin for displaying yandex maps on iOS and Android.

Disclaimer: This project uses Yandex Mapkit which belongs to Yandex
When using Mapkit refer to these terms of use

Getting Started

Generate your API Key

  1. Go to https://developer.tech.yandex.com
  2. Create a MapKit mobile SDK key

Initializing for iOS

  1. Add import YandexMapsMobile to ios/Runner/AppDelegate.swift
  2. Add YMKMapKit.setApiKey("YOUR_API_KEY") inside func application in ios/Runner/AppDelegate.swift
  3. Specify your API key in the application delegate ios/Runner/AppDelegate.swift
  4. For Flutter version less than 1.22 add <key>io.flutter.embedded_views_preview</key> <true/> inside <dict> tag in ios/Runner/Info.plist
  5. Uncomment platform :ios, '9.0' in ios/Podfile

ios/Runner/AppDelegate.swift:

For Swift 4.0 and lesser

import UIKit
import Flutter
import YandexMapsMobile

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?
  ) -> Bool {
    YMKMapKit.setLocale("YOUR_LOCALE") // Your preferred language. Not required, defaults to system language
    YMKMapKit.setApiKey("YOUR_API_KEY") // Your generated API key
    GeneratedPluginRegistrant.register(with: self)
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}

For Swift 4.2 and greater

import UIKit
import Flutter
import YandexMapsMobile

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    YMKMapKit.setLocale("YOUR_LOCALE") // Your preferred language. Not required, defaults to system language
    YMKMapKit.setApiKey("YOUR_API_KEY") // Your generated API key
    GeneratedPluginRegistrant.register(with: self)
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}

Initializing for Android

  1. Add dependency implementation 'com.yandex.android:maps.mobile:4.0.0-full' to android/app/build.gradle
  2. Add permissions <uses-permission android:name="android.permission.INTERNET"/> and <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> to android/app/src/main/AndroidManifest.xml
  3. Add import com.yandex.mapkit.MapKitFactory; to android/app/src/main/.../MainActivity.java/android/app/src/main/.../MainActivity.kt
  4. MapKitFactory.setApiKey("YOUR_API_KEY"); inside method onCreate in android/app/src/main/.../MainActivity.java/android/app/src/main/.../MainActivity.kt
  5. Specify your API key in the application delegate android/app/src/main/.../MainActivity.java/android/app/src/main/.../MainActivity.kt

android/app/build.gradle:

dependencies {
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    implementation 'com.yandex.android:maps.mobile:4.0.0-full'
}

For Java projects

android/app/src/main/.../MainActivity.java:

import androidx.annotation.NonNull;
import io.flutter.embedding.android.FlutterActivity;
import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.plugins.GeneratedPluginRegistrant;
import com.yandex.mapkit.MapKitFactory;

public class MainActivity extends FlutterActivity {
  @Override
  public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
    MapKitFactory.setLocale("YOUR_LOCALE"); // Your preferred language. Not required, defaults to system language
    MapKitFactory.setApiKey("YOUR_API_KEY"); // Your generated API key
    super.configureFlutterEngine(flutterEngine);
  }
}

For Kotlin projects

android/app/src/main/.../MainActivity.kt

import androidx.annotation.NonNull
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugins.GeneratedPluginRegistrant
import com.yandex.mapkit.MapKitFactory

class MainActivity: FlutterActivity() {
  override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
    MapKitFactory.setLocale("YOUR_LOCALE") // Your preferred language. Not required, defaults to system language
    MapKitFactory.setApiKey("YOUR_API_KEY") // Your generated API key
    super.configureFlutterEngine(flutterEngine)
  }
}

Usage

For usage examples refer to example app

image

Additional remarks

This project only supports Android V2 embedding. V1 support has been completly dropped. If you are creating a new flutter project then you are automatically using V2 and don't have to worry. Other projects are strongly recommended to migrate to V2. See this page for more details.

YandexMapkit always works with one language only.
Due to native constraints after the application is launched it can't be changed.

iOS

Currently native library doesn't support Silicon Mac.
If you receive this type of error

ld: in /.../ios/Pods/YandexMapsMobile/YandexMapsMobile.framework/YandexMapsMobile(YMKRouteView_Binding.mm.o), building for iOS Simulator, but linking in object file built for iOS, file '/.../ios/Pods/YandexMapsMobile/YandexMapsMobile.framework/YandexMapsMobile' for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Add in your projects Build Settings in section Excluded Architectures for Debug this line - arm64
This way XCode won't try to build for Silicon Macs iOS Simulators

Features

  • iOS Support
  • Android Support
  • Working with Placemarks/Polylines/Polygons/Circles - adding, updating, removing, tap events, styling
  • Working with collections of map objects
  • Working with clusters
  • Moving around the map
  • Setting map bounds
  • Showing current user location
  • Styling the map
  • Address suggestions
  • Basic driving routing
  • Basic address direct/reverse search

yandex_mapkit's People

Contributors

cream-cheeze avatar dcrow avatar elisar4 avatar goolpe avatar ilagent avatar ishokov-dzhafar avatar lazydev96 avatar ryufitreet avatar starikovvm avatar tatianabelova avatar tumist76 avatar umcherrel avatar vanyasem avatar

Watchers

 avatar

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.