base_mapview 0.0.6

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 59

base_mapview #

A new Flutter MapView plugin.

高德地图插件 #

image

Getting Started #

集成高德地图android版本 #

1、先申请一个apikey http://lbs.amap.com/api/android-sdk/guide/create-project/get-key

2、在AndroidManifest.xml中增加

 <meta-data
            android:name="com.amap.api.v2.apikey"
            android:value="你的Key" />

3、增加对应的权限:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.CHANGE_CONFIGURATION" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />

How to use #

先导入dart包 修改pubspec.yaml,增加依赖:

dependencies:
  base_mapview: ^0.0.3

在要用的地方导入:

import 'package:base_mapview/base_mapview.dart';

然后就可以使用了

 import 'package:base_mapview/local_weather_live.dart';
 import 'package:base_mapview/regeocode_address.dart';
 import 'package:base_mapview/tip.dart';
 import 'package:base_mapview/lat_lng.dart';
 import 'package:flutter/material.dart';
 import 'package:base_mapview/wms.dart';
 import 'package:base_mapview/amap_view.dart';

 void main() => runApp(MyApp());

 class MyApp extends StatefulWidget {
   @override
   _MyAppState createState() => _MyAppState();
 }

 class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
   List _list = [
     LatLng(43.99791, 125.397968).toMap(),
     LatLng(39.833876, 116.301886).toMap(),
     LatLng(39.823862, 116.295385).toMap(),
     LatLng(39.823734, 116.296299).toMap(),
     LatLng(39.823083, 116.294776).toMap()
   ];

   List _polylinelist = [
     LatLng(39.82588, 116.30102).toMap(),
     LatLng(39.825847, 116.302554).toMap(),
     LatLng(39.823853, 116.300612).toMap(),
   ];

   List _polygonlist = [
     LatLng(39.823862, 116.295385).toMap(),
     LatLng(39.823734, 116.296299).toMap(),
     LatLng(39.823083, 116.294776).toMap(),
   ];

   Wms _wms = Wms(true, true, true, true, true, true);

   Key _key0;

   @override
   void initState() {
     _key0 = AMapView.createKey(_key0);
     super.initState();
   }

   @override
   Widget build(BuildContext context) {
     var mywidget = Column(
       crossAxisAlignment: CrossAxisAlignment.start,
       children: <Widget>[
         AMapView(
           key: _key0,
           mapType: MapType.satellite,
           centerCoordinate: LatLng(43.99791, 125.397968),
           zoomLevel: 10,
           onLocationChange: (LatLng latlng) {
             //print(latlng.toString());
           },
           onGetInputtips: (List<Tip> datalist) {
             for (Tip tip in datalist) {
               print("flutter提示信息:$tip");
             }
           },
           onCameraChange: (LatLng latlng) {
             print("中心点:" + latlng.toString());
           },
           onRegeocodeSearched: (RegeocodeAddress address) {
             print(address.toString());

             //获取天气信息
             AMapView.channel.invokeMethod("queryWeatherbyCity", {
               "mapView": {"city": address.city}
             });
           },
           onWeatherLiveSearched: (LocalWeatherLive weather) {
             print("实时天气:" +
                 weather.city +
                 "-温度" +
                 weather.temperature +
                 "-天气" +
                 weather.weather);
           },
           onMarkerClick: (LatLng latlng) {
             print("marker click:" + latlng.toString());
           },
           wms: _wms,
           widthPercent: 0.6,
           heightPercent: 0.8,
         ),
         Wrap(
           children: <Widget>[
             RaisedButton(
               onPressed: () {
                 AMapView.channel.invokeMethod("location");
               },
               child: Text(
                 "定位",
                 style: TextStyle(color: Colors.red),
               ),
             ),
             RaisedButton(
               onPressed: () {
                 AMapView.channel.invokeMethod(
                   "addmarker",
                   {
                     "mapView": {"markerlist": _list}
                   },
                 );
               },
               child: Text(
                 "添加marker",
                 style: TextStyle(color: Colors.red),
               ),
             ),
             RaisedButton(
               onPressed: () {
                 AMapView.channel.invokeMethod("removemarker");
               },
               child: Text(
                 "移除marker",
                 style: TextStyle(color: Colors.red),
               ),
             ),
             RaisedButton(
               onPressed: () {
                 AMapView.channel.invokeMethod(
                   "drawcircle",
                   {
                     "mapView": {
                       "roundcenter": LatLng(39.825262, 116.297241).toMap(),
                       "radius": 100.0,
                     }
                   },
                 );
               },
               child: Text(
                 "绘制圆形",
                 style: TextStyle(color: Colors.red),
               ),
             ),
             RaisedButton(
               onPressed: () {
                 AMapView.channel.invokeMethod(
                   "drawpolylin",
                   {
                     "mapView": {"polylinlist": _polylinelist}
                   },
                 );
               },
               child: Text(
                 "绘制线",
                 style: TextStyle(color: Colors.red),
               ),
             ),
             RaisedButton(
               onPressed: () {
                 AMapView.channel.invokeMethod(
                   "drawPolygon",
                   {
                     "mapView": {"polygonlist": _polygonlist}
                   },
                 );
               },
               child: Text(
                 "绘制多边形",
                 style: TextStyle(color: Colors.red),
               ),
             ),
             RaisedButton(
               onPressed: () {
                 AMapView.channel.invokeMethod(
                   "setMapType",
                   {
                     "mapView": {"mapType": 2}
                   },
                 );
               },
               child: Text(
                 "卫星图层",
                 style: TextStyle(color: Colors.red),
               ),
             ),
             RaisedButton(
               onPressed: () {
                 AMapView.channel.invokeMethod(
                   "setMapType",
                   {
                     "mapView": {"mapType": 1}
                   },
                 );
               },
               child: Text(
                 "正常图层",
                 style: TextStyle(color: Colors.red),
               ),
             ),
             RaisedButton(
               onPressed: () {
                 AMapView.channel.invokeMethod("zoomOut");
               },
               child: Text(
                 "放大地图",
                 style: TextStyle(color: Colors.red),
               ),
             ),
             RaisedButton(
               onPressed: () {
                 AMapView.channel.invokeMethod("zoomIn");
               },
               child: Text(
                 "缩小地图",
                 style: TextStyle(color: Colors.red),
               ),
             ),
             RaisedButton(
               onPressed: () {
                 AMapView.channel.invokeMethod(
                   "queryInputeData",
                   {
                     "mapView": {"keyword": "北京"}
                   },
                 );
               },
               child: Text(
                 "搜索提示",
                 style: TextStyle(color: Colors.red),
               ),
             ),
             RaisedButton(
               onPressed: () {
                 Wms wms = Wms(true, true, true, true, true, true);
                 AMapView.channel.invokeMethod(
                   "initWms",
                   {"mapView": wms.toMap()},
                 );
               },
               child: Text(
                 "添加wms图层",
                 style: TextStyle(color: Colors.red),
               ),
             ),
           ],
         )
       ],
     );

     return MaterialApp(
       home: Scaffold(
         body:SingleChildScrollView(
           child: mywidget,
         )
       ),
     );
   }
 }

特性 #

  • [x] android支持
  • [x] 不需要添加任何支持即可显示地图,无需Activity和Controller
  • [x] 3D地图的显示
  • [x] 地图的定位
  • [x] 添加marker,移除marker
  • [x] 绘制圆形,绘制线,绘制多边形
  • [x] 设置地图缩放层级,放大地图,缩放地图
  • [x] 添加wms图层
  • [x] 获取POI数据
  • [x] 获取天气数据
  • [ ] 更多api

[0.0.1] - 03-07-2019

  • android支持
  • 不需要添加任何支持即可显示地图,无需Activity和Controller
  • 3D地图的显示
  • 地图的定位
  • 添加marker,移除marker
  • 绘制圆形,绘制线,绘制多边形
  • 设置地图缩放层级,放大地图,缩放地图

[0.0.2] - 03-07-2019

  • readme.md文件修改

[0.0.3] - 03-08-2019

  • 绘制圆形,线段,多边形添加参数支持
  • 增加地图获取位置权限,写入外部存储权限处理

[0.0.4] - 03-11-2019

  • 逆地理编码
  • 查询天气
  • 搜索关键字内容提示列表

[0.0.5] - 03-12-2019

  • marker点击事件
  • wms图层添加

[0.0.6] - 03-13-2019

  • ASMapView组件宽度和高度百分比控制

example/README.md

base_mapview_example #

Demonstrates how to use the base_mapview 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:
  base_mapview: ^0.0.6

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:base_mapview/base_mapview.dart';
  
Version Uploaded Documentation Archive
0.0.6 Mar 14, 2019 Go to the documentation of base_mapview 0.0.6 Download base_mapview 0.0.6 archive
0.0.5 Mar 13, 2019 Go to the documentation of base_mapview 0.0.5 Download base_mapview 0.0.5 archive
0.0.4 Mar 12, 2019 Go to the documentation of base_mapview 0.0.4 Download base_mapview 0.0.4 archive
0.0.3 Mar 11, 2019 Go to the documentation of base_mapview 0.0.3 Download base_mapview 0.0.3 archive
0.0.2 Mar 8, 2019 Go to the documentation of base_mapview 0.0.2 Download base_mapview 0.0.2 archive
0.0.1 Mar 7, 2019 Go to the documentation of base_mapview 0.0.1 Download base_mapview 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
25
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
85
Overall:
Weighted score of the above. [more]
59
Learn more about scoring.

We analyzed this package on Jun 26, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.3.2
  • pana: 0.12.18
  • Flutter: 1.5.4-hotfix.2

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Format lib/amap_view.dart.

Run flutter format to format lib/amap_view.dart.

Format lib/generated/i18n.dart.

Run flutter format to format lib/generated/i18n.dart.

Format lib/tip.dart.

Run flutter format to format lib/tip.dart.

Format lib/wms.dart.

Run flutter format to format lib/wms.dart.

Maintenance issues and suggestions

Support latest dependencies. (-5 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency.

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
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8