yandex_mapkit 0.3.7

  • Readme
  • Changelog
  • Example
  • Installing
  • 89

yandex_mapkit #

A flutter plugin for displaying yandex maps on iOS and Android. Now fully integrated with flutters widget tree.

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 YandexMapKit 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

ios/Runner/AppDelegate.swift:

import UIKit
import Flutter
import YandexMapKit

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?
  ) -> Bool {
    YMKMapKit.setApiKey("YOUR_API_KEY")
    GeneratedPluginRegistrant.register(with: self)
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }

Initializing for Android #

  1. Add dependency implementation 'com.yandex.android:mapkit:3.4.0' and implementation 'com.yandex.android:search:3.4.0' to android/app/build.gradle
  2. Add import com.yandex.mapkit.MapKitFactory; to android/app/src/main/.../MainActivity.java
  3. Add MapKitFactory.setApiKey("YOUR_API_KEY"); inside method onCreate in android/app/src/main/.../MainActivity.java
  4. Specify your API key in the application delegate android/app/src/main/.../MainActivity.java

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:mapkit:3.4.0'
    implementation 'com.yandex.android:search:3.4.0'
}

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

Flutter versions prior to 1.12

import io.flutter.app.FlutterActivity;
import io.flutter.plugins.GeneratedPluginRegistrant;
import com.yandex.mapkit.MapKitFactory;

public class MainActivity extends FlutterActivity {
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    MapKitFactory.setApiKey("YOUR_API_KEY");
    GeneratedPluginRegistrant.registerWith(this);
  }
}

Flutter versions after and including 1.12

import androidx.annotation.NonNull;
import io.flutter.embedding.android.FlutterActivity;
import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.plugins.GeneratedPluginRegistrant;

public class MainActivity extends FlutterActivity {
  @Override
  public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
    MapKitFactory.setApiKey("YOUR_API_KEY");
    GeneratedPluginRegistrant.registerWith(flutterEngine);
  }
}

Usage #

Example:

import 'package:yandex_mapkit/yandex_mapkit.dart';

void main() async {
  runApp(MyApp());
}

You can use a YandexMap which resizes itself to its parent size

Expanded(child: YandexMap())

For usage examples refer to example app

Features #

  • [X] iOS Support
  • [X] Android Support
  • [X] Adding and removing Placemarks
  • [X] Receive Placemark tap events
  • [X] Moving around the map
  • [X] Setting map bounds
  • [X] Showing current user location
  • [X] Styling the map
  • [X] Adding and removing Polylines
  • [X] Adding and removing Polygons
  • [X] Address suggestion

0.3.7 #

  • Add Polygon support [#36, umcherrel]
  • Add Placemark options [#36, umcherrel]
  • Add user location options [#36, umcherrel]
  • Implement MapkitSearch [#36, umcherrel]
  • Add camera tracing [#36, umcherrel]

0.3.6 #

  • Set minimum flutter version to 1.10.0
  • Update iOS and Android dependencies
  • Fix YandexMap not compiling on iOS
  • Fix YandexMap not showing when onMapCreated is not defined [#38, DCrow]
  • Minor fixes

0.3.5 #

  • Add Polyline support [#33, elisar4]
  • Add support for using binary image as Placemark icons [#30, elisar4]
  • Refactor example app [#31, DCrow]

0.3.4 #

  • Add getting target point(center point) [#27, Ishokov-Dzhafar]

0.3.3 #

  • Add linter and fix linter errors[#23, vanyasem]
  • Add location permission request messages to example app[#23, vanyasem]
  • Update and lock YandexMapkit version to 3.4 for iOS and Android[#23, vanyasem]
  • Update .gitignore[#25, DCrow]
  • Fix typos in README[#23, vanyasem]

0.3.2 #

  • Add styling functionality [#18, vanyasem]

0.3.1 #

  • Fix YandexMapController.addPlacemark sometimes not working on iOS [#13, Ishokov-Dzhafar]
  • Remove unused code

0.3.0 #

  • Breaking change. Changed iOS and Android Mapkit key initialization

0.2.1 #

  • Add zoom functionality [#10, Ishokov-Dzhafar]

0.2.0 #

  • Breaking change. Migrate from the deprecated original Android Support Library to AndroidX.

0.1.3+2 #

  • Fix some of pub.dartlang.com suggestions
  • Fix Xcode 10.1 SWIFT_VERSION error

0.1.3+1 #

0.1.3 #

  • Bump YandexMapkit version to 3.2 for ios and android

0.1.2 #

  • Change ios implementation to use UiKitView
  • Change AnroidView.gestureRecognizers to accept all gestures
  • Change method signature Future<Null> to Future<void>

0.1.1 #

  • Bugfixes

0.1.0 #

  • Change android implementation to use AndroidView
  • Change ios implementation to match android

0.0.2 #

  • Add functionality to show/hide current user location

0.0.1 #

  • Initial release

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:yandex_mapkit/yandex_mapkit.dart';
import 'package:yandex_mapkit_example/examples/layers_page.dart';
import 'package:yandex_mapkit_example/examples/map_controls_page.dart';
import 'package:yandex_mapkit_example/examples/page.dart';
import 'package:yandex_mapkit_example/examples/placemark_page.dart';
import 'package:yandex_mapkit_example/examples/polyline_page.dart';
import 'package:yandex_mapkit_example/examples/polygon_page.dart';
import 'package:yandex_mapkit_example/examples/target_page.dart';
import 'package:yandex_mapkit_example/examples/search_page.dart';

void main() {
  runApp(MaterialApp(home: MainPage()));
}

final List<Page> _allPages = <Page>[
  const LayersPage(),
  const MapControlsPage(),
  const PlacemarkPage(),
  const PolylinePage(),
  const PolygonPage(),
  const TargetPage(),
  const SearchPage(),
];

class MainPage extends StatelessWidget {
  void _pushPage(BuildContext context, Page page) {
    Navigator.push(
      context,
      MaterialPageRoute<void>(builder: (_) =>
        Scaffold(
          appBar: AppBar(title: Text(page.title)),
          body: Container(
            padding: const EdgeInsets.all(8),
            child: page
          )
        )
      )
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('YandexMap examples')),
      body: Column(
        children: <Widget>[
          Expanded(
            child: Container(
              padding: const EdgeInsets.all(8),
              child: const YandexMap()
            )
          ),
          Expanded(
            child: ListView.builder(
              itemCount: _allPages.length,
              itemBuilder: (_, int index) => ListTile(
                title: Text(_allPages[index].title),
                onTap: () => _pushPage(context, _allPages[index]),
              ),
            )
          )
        ]
      )
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  yandex_mapkit: ^0.3.7

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:yandex_mapkit/yandex_mapkit.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
77
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
89
Learn more about scoring.

We analyzed this package on Mar 31, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Health suggestions

Format lib/src/placemark.dart.

Run flutter format to format lib/src/placemark.dart.

Format lib/src/polygon.dart.

Run flutter format to format lib/src/polygon.dart.

Format lib/src/suggest_item.dart.

Run flutter format to format lib/src/suggest_item.dart.

Fix additional 4 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/src/yandex_map.dart (Run flutter format to format lib/src/yandex_map.dart.)
  • lib/src/yandex_map_controller.dart (Run flutter format to format lib/src/yandex_map_controller.dart.)
  • lib/src/yandex_search.dart (Run flutter format to format lib/src/yandex_search.dart.)
  • lib/yandex_mapkit.dart (Run flutter format to format lib/yandex_mapkit.dart.)

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8