flutter_plugin_mapbox 0.0.8

Flutter Mapbox Plugin #

Mapbox 没有Flutter插件,所以就封装了一个,实现了基本的定位功能,基本上是按照公司的需求来封装的,所以可定制性并不是很好,等有时间在好好抽出来一下 实现了 基本的定位功能, 设置当前的定位点, 添加大头针, 划线, 调用原生地图导航(iOS) 基本功能

mapbox.gif

Install #

Android #

需要添加Mapbox的token android/app/src/main/AndroidManifest.xml:

    <meta-data android:name="com.mapbox.token" android:value="YOUR_TOKEN_HERE" />
iOS #

iOS需要在info.plist 里面添加定位权限和mapbox的token还有显示插件的一句代码

<key>MGLMapboxAccessToken</key>
	<string>mapbox token</string>
	<key>NSLocationWhenInUseUsageDescription</key>
	<string>允许使用位置</string>
	<key>io.flutter.embedded_views_preview</key>
	<true/>
	<key>NSAppTransportSecurity</key>
	<dict>
		<key>NSAllowsArbitraryLoads</key>
		<true/>
	</dict>
使用 #

需要先定义一个MapboxMapController 用来调用地图的相关方法

 MapboxMapController _mapboxMapController;
  //地图初始化完成的回调
  void onCreateMap(MapboxMapController controller){
    _mapboxMapController = controller;
    
  }
  
   MapboxMap(
              initialCameraPosition: CameraPosition(
                zoom: 11,
                target: LatLng(39.911337,116.410625),
              ),
              myLocationEnabled: true,
              symbolShowIndex: false,
              onMapCreated: onCreateMap,
            ),

可用方法列表

//添加大头一组大头针
 Future<List<dynamic>> addSymbolList(List<SymbolOptions> optionsList) 
 //画线
 Future<Line> addLine(LineOptions options)
 //设置选中某个大头针
Future<Symbol> selectSymbol(SymbolOptions options)

0.0.1 #

  • TODO: Describe initial release.

example/README.md

flutter_plugin_mapbox_example #

Demonstrates how to use the flutter_plugin_mapbox plugin.

Getting Started #

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_plugin_mapbox: ^0.0.8

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:flutter_plugin_mapbox/flutter_plugin_mapbox.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
37
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
66
Learn more about scoring.

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

  • Dart: 2.7.1
  • pana: 0.13.5
  • Flutter: 1.12.13+hotfix.7

Health suggestions

Fix lib/mapbox/camera.dart. (-0.50 points)

Analysis of lib/mapbox/camera.dart reported 1 hint:

line 191 col 11: The declaration '_toJson' isn't referenced.

Fix lib/mapbox/controller.dart. (-0.50 points)

Analysis of lib/mapbox/controller.dart reported 1 hint:

line 67 col 13: The value of the field '_id' isn't used.

Fix lib/mapbox/mapbox_map.dart. (-0.50 points)

Analysis of lib/mapbox/mapbox_map.dart reported 1 hint:

line 143 col 19: The declaration 'pointToArray' isn't referenced.

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.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
Dev dependencies
flutter_test