apple_maps_flutter
一个 Flutter 插件,提供了一个 Apple Maps widget。
该插件依赖于 Flutter 嵌入 Android 和 iOS 视图的机制。由于该机制目前处于开发者预览阶段,因此该插件也应被视为开发者预览版本。
该插件基于 google_maps_flutter 插件。为了避免重复造轮子,它也使用了 google_maps_flutter 插件的 Flutter 实现。这样做也是为了简化将 google_maps_flutter 插件与 apple_maps_flutter 结合使用的过程,以创建名为 flutter_platform_maps 的跨平台 Android/iOS 实现。
截图
| 示例 1 | 示例 2 |
|---|---|
![]() |
![]() |
iOS
要在 iOS 上使用此插件,您需要通过在应用的 Info.plist 文件中添加一个布尔属性来选择加入嵌入式视图预览,该属性的键为 io.flutter.embedded_views_preview,值为 YES。您还必须添加 Privacy - Location When In Use Usage Description 键,并为其提供您的使用说明。
Android
目前没有 Android 实现,但将有一个包结合 apple_maps_flutter 和 google_maps_flutter 插件,以实现典型的 Android/iOS 地图功能(即将推出)。
示例用法
class AppleMapsExample extends StatelessWidget {
AppleMapController mapController;
void _onMapCreated(AppleMapController controller) {
mapController = controller;
}
@override
Widget build(BuildContext context) {
return Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Expanded(
child: Container(
child: AppleMap(
onMapCreated: _onMapCreated,
initialCameraPosition: const CameraPosition(
target: LatLng(0.0, 0.0),
),
),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Column(
children: <Widget>[
FlatButton(
onPressed: () {
mapController.moveCamera(
CameraUpdate.newCameraPosition(
const CameraPosition(
heading: 270.0,
target: LatLng(51.5160895, -0.1294527),
pitch: 30.0,
zoom: 17,
),
),
);
},
child: const Text('newCameraPosition'),
),
FlatButton(
onPressed: () {
mapController.moveCamera(
CameraUpdate.newLatLngZoom(
const LatLng(37.4231613, -122.087159),
11.0,
),
);
},
child: const Text('newLatLngZoom'),
),
],
),
Column(
children: <Widget>[
FlatButton(
onPressed: () {
mapController.moveCamera(
CameraUpdate.zoomIn(),
);
},
child: const Text('zoomIn'),
),
FlatButton(
onPressed: () {
mapController.moveCamera(
CameraUpdate.zoomOut(),
);
},
child: const Text('zoomOut'),
),
FlatButton(
onPressed: () {
mapController.moveCamera(
CameraUpdate.zoomTo(16.0),
);
},
child: const Text('zoomTo'),
),
],
),
],
)
],
);
}
}
TODO:
- [x] 添加 zoomLevelBounds
- [x] 添加 zoomBy 功能
- [x] 添加可见地图区域的 getter
- [ ] 添加设置 LatLngBounds 到地图的功能
- [ ] 添加为地图添加内边距的功能
- [ ] 添加 scrollBy 功能
- [ ] 添加放置折线的功能
- [ ] 添加放置多边形的功能
- [ ] 添加放置圆的功能
- [ ] . . .
随时欢迎提出建议和 PR 来改进此插件。

