Code Monkey home page Code Monkey logo

dgis_map_kit's Introduction

Table of Contents
  1. About The Project
  2. Getting Started
  3. Location features
  4. Basic map usage
  5. Contact

About The Project

This Flutter 2Gis map plugin allows you to add a 2GIS map to your Flutter application, and one of its important features is the ability to work cross-platform. This provides universality and accessibility of your mapping functionality on various devices, making it more convenient for developers and users.

Packages using on platform-side:

(back to top)

Getting Started

These are instructions for integrating the package into your application.

Installation

Get it by running the following command:

  • With Flutter
     $ flutter pub add dgis_map_kit

(back to top)

Location features

Android

Add the ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION permission in the application manifest android/app/src/main/AndroidManifest.xml to enable location features in an Android application:

<manifest ...
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

Starting from Android API level 23 you also need to request it at runtime. This plugin does not handle this for you. The example app uses the flutter 'location' plugin for this.

iOS

To enable location features in an iOS application:

If you access your users' location, you should also add the following key to ios/Runner/Info.plist to explain why you need access to their location data:

xml ...
    <key>NSLocationWhenInUseUsageDescription</key>
    <string>[Your explanation here]</string>

(back to top)

Basic map usage

Here are examples of map usage during development.

To obtain the key file, please fill out the form on dev.2gis.ru

import "package:dgis_map_kit/dgis_map_kit.dart";

// Simple 2Gis map instantiating

return DGisMap(
  token: token,
  initialCameraPosition: CameraPosition(
    position: Position(
      lat: lat,
      long: long,
    ),
    zoom: 17.0,
  ),
  // ...
),

Using map events

import 'dart:developer' as log;

// Simple map events usage

return DGisMap(
  // ...
  onUserLocationChanged: (position) => log.log(
    "User location changed: ${position.lat} ${position.long}",
  ),
  markerOnTap: (marker, layerId) => log.log(
    "Marker on tapped event: ${marker.position.lat} ${marker.position.long}",
  ),
  // ...
),

(back to top)

Uploading markers on map

late MapController controller;
return DGisMap(
  // ...
  mapOnCreated: (controller) => this.controller = controller,
  mapOnReady: () => controller.addMarkers([ 
    // Uploading list of markers to the map.
    Marker(
      icon: icon,
      position: Position(
        lat: lat,
        long: long,
      ),
    ),
    Marker(
      icon: icon,
      position: Position(
        lat: lat,
        long: long,
      ),
    ),
  ]),
  // ...
),

 

(back to top)

Add markers clustering layer

return DGisMap(
  // ...
  layers: [
    // Declaring map layer with clustering
    MapLayer.withClustering(
      builder: (markers) => MapClusterer(
        icon: iconAsset,
        iconOptions: MapIconOptions(
          text: markers.length.toString() 
        ),
      ),
      maxZoom: 20.0,
      minDistance: 100.0,
    ),
  ],
  // ...
),

 

(back to top)

Camera moves

late MapController controller;
return DGisMap(
  // ...
  mapOnCreated: (controller) => this.controller = controller,
  // Simple camera movement to a marker on tap:
  markerOnTap: (marker) {
    controller.moveCamera(
      controller.currentCameraPosition.copyWith(
        position: marker.position,
      ),
      duration: const Duration(milliseconds: 300),
      animationType: CameraAnimationType.DEFAULT,
    );
  },
  // ...
),

 

(back to top)

Contact

jyahann - @jyahann - [email protected]

Project Link: https://github.com/jyahann/dgis_map_kit.git

dgis_map_kit's People

Contributors

jyahann avatar

Stargazers

Yura Movsesyan avatar Vik avatar

Watchers

 avatar

dgis_map_kit's Issues

Полилинии

Привет! Отличный пакет, но не хватает полилиний(

Навигатор

Привет! Отличный плагин. Хотел бы узнать будет ли расширение данного плагина до функционала навигатора внутри приложения?

Feature request

Привет.
Будет ли расширение функционала до полной версии API?

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.