kidd3166 d41004f7cf 1.4 update | %!s(int64=2) %!d(string=hai) anos | |
---|---|---|
.. | ||
android | %!s(int64=2) %!d(string=hai) anos | |
ios | %!s(int64=2) %!d(string=hai) anos | |
lib | %!s(int64=2) %!d(string=hai) anos | |
res | %!s(int64=2) %!d(string=hai) anos | |
.gitignore | %!s(int64=2) %!d(string=hai) anos | |
.metadata | %!s(int64=2) %!d(string=hai) anos | |
CHANGELOG.md | %!s(int64=2) %!d(string=hai) anos | |
LICENSE | %!s(int64=2) %!d(string=hai) anos | |
README.md | %!s(int64=2) %!d(string=hai) anos | |
pubspec.yaml | %!s(int64=2) %!d(string=hai) anos |
基于高德开放平台地图SDK的flutter插件
使用Flutter插件,请参考在Flutter里使用Packages, 添加amap_flutter_map的引用
iOS端插件使用特殊配置:Flutter 1.22.0 之前(之后的版本可以不添加该配置),iOS端的UiKitView还只是preview状态, 默认是不支持的, 需要手动打开开关, 需要在iOS工程的info.plist添加如下配置:
<key>io.flutter.embedded_views_preview</key>
<string>YES</string>
import 'package:amap_flutter_map_example/base_page.dart';
import 'package:flutter/material.dart';
import 'package:amap_flutter_map/amap_flutter_map.dart';
import 'package:amap_flutter_base/amap_flutter_base.dart';
class ShowMapPage extends BasePage {
ShowMapPage(String title, String subTitle) : super(title, subTitle);
@override
Widget build(BuildContext context) {
return _ShowMapPageBody();
}
}
class _ShowMapPageBody extends StatefulWidget {
@override
State<StatefulWidget> createState() => _ShowMapPageState();
}
class _ShowMapPageState extends State<_ShowMapPageBody> {
static final CameraPosition _kInitialPosition = const CameraPosition(
target: LatLng(39.909187, 116.397451),
zoom: 10.0,
);
List<Widget> _approvalNumberWidget = List<Widget>();
@override
Widget build(BuildContext context) {
final AMapWidget map = AMapWidget(
initialCameraPosition: _kInitialPosition,
onMapCreated: onMapCreated,
);
return ConstrainedBox(
constraints: BoxConstraints.expand(),
child: Stack(
alignment: Alignment.center,
children: [
Container(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
child: map,
),
Positioned(
right: 10,
bottom: 15,
child: Container(
alignment: Alignment.centerLeft,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: _approvalNumberWidget),
))
],
),
);
}
AMapController _mapController;
void onMapCreated(AMapController controller) {
setState(() {
_mapController = controller;
getApprovalNumber();
});
}
/// 获取审图号
void getApprovalNumber() async {
//普通地图审图号
String mapContentApprovalNumber =
await _mapController?.getMapContentApprovalNumber();
//卫星地图审图号
String satelliteImageApprovalNumber =
await _mapController?.getSatelliteImageApprovalNumber();
setState(() {
if (null != mapContentApprovalNumber) {
_approvalNumberWidget.add(Text(mapContentApprovalNumber));
}
if (null != satelliteImageApprovalNumber) {
_approvalNumberWidget.add(Text(satelliteImageApprovalNumber));
}
});
print('地图审图号(普通地图): $mapContentApprovalNumber');
print('地图审图号(卫星地图): $satelliteImageApprovalNumber');
}
}