/flutter_2d_amap_yuexi

岳西

Primary LanguageDartApache License 2.0Apache-2.0

非原创,原创请去https://github.com/simplezhli/flutter_2d_amap,只是原创那边没有tag版本,我需要老的版本适应老版本的flutter,特此说明一下

flutter_2d_amap

本插件主要服务于 flutter_deer。仅保持现有功能,需要的功能可自行拓展。

高德2D地图插件(已支持1.12版本新的android插件api)

效果展示

实现功能包括

使用方式

flutter_2d_amap:
    git:
      url: https://github.com/simplezhli/flutter_2d_amap.git

import 'package:flutter_2d_amap/flutter_2d_amap.dart';


AMap2DView(
  onPoiSearched: (result) {

  },
  onAMap2DViewCreated: (controller) {

  },
)

Android

AndroidManifest.xml 中添加:

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

如果你的targetSdkVersion为27以上,则需要做以下配置来支持http明文请求(具体可以看demo),否则会导致地图加载不出:

AndroidManifest.xml 中添加:

<application
  android:networkSecurityConfig="@xml/network_security_config"
/>

在 res 下新增一个 xml 目录,然后创建一个名为:network_security_config.xml 文件:

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <base-config cleartextTrafficPermitted="true" />
</network-security-config>

iOS

使用前设置key:

Flutter2dAMap.setApiKey("配置你的key");

在info.plist中增加:

<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>地图功能需要您的定位服务,否则无法使用,如果您需要使用后台定位功能请选择“始终允许”。</string>

<key>NSLocationAlwaysUsageDescription</key>
<string>地图功能需要您的定位服务,否则无法使用。</string>

<key>NSLocationWhenInUseUsageDescription</key>
<string>地图功能需要您的定位服务,否则无法使用。</string>

<key>io.flutter.embedded_views_preview</key>
<true/>

Web

index.html中添加(在main.dart.js之前):

<script src="https://webapi.amap.com/loader.js"></script>

使用AMap2DView时添加 webKey

AMap2DView(
  webKey: 'xxx',
)

License

Copyright 2019 simplezhli

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.