release: 1.0.9, add map language support
This commit is contained in:
parent
b582025ac7
commit
4602f30730
|
@ -1,3 +1,7 @@
|
|||
## 1.0.9
|
||||
2024-08-24
|
||||
* 设置地图语言,支持中文、英文(按SDK描述:1、不能和自定义地图样式同时使用;2、英文状态只在标准地图生效)
|
||||
|
||||
## 1.0.8
|
||||
2024-07-29.
|
||||
* 升级amap android sdk版本 10.0.800_loc6.4.5_sea9.7.2 | 2024-07-19
|
||||
|
|
|
@ -215,6 +215,9 @@ class AMapWidget extends StatefulWidget {
|
|||
|
||||
///拓展插件,提供更多定制化功能
|
||||
final List<AMapExtension> extensions;
|
||||
|
||||
/// 设置地图语言
|
||||
final MapLanguage? mapLanguage;
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
@ -51,6 +51,8 @@ class AMapOptionsBuilder implements AMapOptionsSink, UISettingsSink {
|
|||
|
||||
private Object initialPolygons;
|
||||
|
||||
private String mapLanguage;
|
||||
|
||||
AMapPlatformView build(int id,
|
||||
Context context,
|
||||
BinaryMessenger binaryMessenger,
|
||||
|
@ -107,6 +109,8 @@ class AMapOptionsBuilder implements AMapOptionsSink, UISettingsSink {
|
|||
List<Object> polygonList = (List<Object>) initialPolygons;
|
||||
aMapPlatformView.getPolygonsController().addByList(polygonList);
|
||||
}
|
||||
|
||||
aMapPlatformView.getMapController().setMapLanguage(mapLanguage);
|
||||
return aMapPlatformView;
|
||||
} catch (Throwable e) {
|
||||
LogUtil.e(CLASS_NAME, "build", e);
|
||||
|
@ -242,5 +246,9 @@ class AMapOptionsBuilder implements AMapOptionsSink, UISettingsSink {
|
|||
this.initialPolygons = polygonsObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMapLanguage(String mapLanguage) {
|
||||
this.mapLanguage = mapLanguage;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -58,4 +58,11 @@ public interface AMapOptionsSink extends UISettingsSink {
|
|||
public void setInitialPolylines(Object initialPolylines);
|
||||
|
||||
public void setInitialPolygons(Object initialPolygons);
|
||||
|
||||
/**
|
||||
* 设置地图语言
|
||||
*
|
||||
* @param mapLanguage {@link com.amap.api.maps.AMap#CHINESE }, {@link com.amap.api.maps.AMap#ENGLISH }
|
||||
*/
|
||||
void setMapLanguage(String mapLanguage);
|
||||
}
|
||||
|
|
|
@ -355,6 +355,13 @@ public class MapController
|
|||
//不实现
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMapLanguage(String mapLanguage) {
|
||||
if (null != amap) {
|
||||
amap.setMapLanguage(mapLanguage);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setLogoPosition(int logoPosition) {
|
||||
|
|
|
@ -293,6 +293,11 @@ public class ConvertUtil {
|
|||
if (null != logoLeftMargin) {
|
||||
sink.setLogoLeftMargin(toInt(logoLeftMargin));
|
||||
}
|
||||
|
||||
final Object mapLanguage = data.get("mapLanguage");
|
||||
if (null != mapLanguage) {
|
||||
sink.setMapLanguage(toString(mapLanguage));
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
LogUtil.e(CLASS_NAME, "interpretAMapOptions", e);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
PODS:
|
||||
- AMap3DMap (10.0.800):
|
||||
- AMapFoundation (>= 1.8.0)
|
||||
- amap_map (1.0.3):
|
||||
- amap_map (1.0.8):
|
||||
- AMap3DMap
|
||||
- Flutter
|
||||
- AMapFoundation (1.8.2)
|
||||
|
@ -29,7 +29,7 @@ EXTERNAL SOURCES:
|
|||
|
||||
SPEC CHECKSUMS:
|
||||
AMap3DMap: 6761e0381f517978312e4f795ce77b2b9f6781a6
|
||||
amap_map: 8773e5cacc760edf208b1e6e61000241d26385fa
|
||||
amap_map: 5be213f350872f6ea406be964031572ab9a0d6e1
|
||||
AMapFoundation: 9885c48fc3a78fdfb84a0299a2293e56ea3c9fec
|
||||
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
|
||||
permission_handler_apple: 9878588469a2b0d0fc1e048d9f43605f92e6cec2
|
||||
|
|
|
@ -2,6 +2,7 @@ import 'dart:collection';
|
|||
|
||||
import 'package:amap_map_example/main.dart';
|
||||
import 'package:amap_map_example/pages/interactive/map_ui_options.dart';
|
||||
import 'package:amap_map_example/pages/map/change_map_lang.dart';
|
||||
import 'package:amap_map_example/pages/map/limit_map_bounds.dart';
|
||||
import 'package:amap_map_example/pages/map/map_my_location.dart';
|
||||
import 'package:amap_map_example/pages/map/map_with_extension_page.dart';
|
||||
|
@ -47,6 +48,14 @@ List<Demo> mapDemos() {
|
|||
configurations: [
|
||||
DemoConfiguration(buildRoute: (context) => LimitMapBoundsPage())
|
||||
]),
|
||||
Demo(
|
||||
title: '地图显示语言',
|
||||
category: DemoCategory.basic,
|
||||
subtitle: '演示限定手机屏幕显示地图的范围',
|
||||
slug: 'map-lang',
|
||||
configurations: [
|
||||
DemoConfiguration(buildRoute: (context) => ChangeMapLangPage())
|
||||
]),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import 'package:amap_map_example/widgets/amap_radio_group.dart';
|
|||
import 'package:amap_map_example/widgets/amap_switch_button.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:x_amap_base/x_amap_base.dart';
|
||||
import 'package:x_common/utils/logger.dart';
|
||||
|
||||
class MapUIDemoPage extends StatefulWidget {
|
||||
MapUIDemoPage({Key? key}) : super(key: key);
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
// Copyright 2024 kuloud
|
||||
|
||||
// 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,
|
||||
|
||||
import 'package:amap_map/amap_map.dart';
|
||||
import 'package:amap_map_example/widgets/amap_radio_group.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ChangeMapLangPage extends StatefulWidget {
|
||||
ChangeMapLangPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_PageBodyState createState() => _PageBodyState();
|
||||
}
|
||||
|
||||
class _PageBodyState extends State<ChangeMapLangPage> {
|
||||
MapLanguage? _mapLang;
|
||||
final Map<String, MapLanguage> _radioValueMap = {
|
||||
'中文': MapLanguage.chinese,
|
||||
'English': MapLanguage.english,
|
||||
};
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_mapLang = MapLanguage.chinese;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
//创建地图
|
||||
final AMapWidget map = AMapWidget(
|
||||
mapLanguage: _mapLang,
|
||||
);
|
||||
return Container(
|
||||
height: MediaQuery.of(context).size.height,
|
||||
width: MediaQuery.of(context).size.width,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Container(
|
||||
height: MediaQuery.of(context).size.height * 0.6,
|
||||
width: MediaQuery.of(context).size.width,
|
||||
child: map,
|
||||
),
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
child: Container(
|
||||
child: AMapRadioGroup(
|
||||
groupLabel: '地图语言',
|
||||
groupValue: _mapLang,
|
||||
radioValueMap: _radioValueMap,
|
||||
onChanged: (value) => {
|
||||
setState(() {
|
||||
_mapLang = value;
|
||||
})
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -13,8 +13,6 @@
|
|||
// import 'package:amap_map_extensions/amap_map_extensions.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:amap_map/amap_map.dart';
|
||||
|
||||
class MapWithExtensionPage extends StatefulWidget {
|
||||
|
|
|
@ -12,8 +12,8 @@ dependencies:
|
|||
flutter:
|
||||
sdk: flutter
|
||||
|
||||
permission_handler: ^11.3.0
|
||||
flutter_plugin_android_lifecycle: ^2.0.17
|
||||
permission_handler: ^11.3.1
|
||||
flutter_plugin_android_lifecycle: ^2.0.21
|
||||
|
||||
amap_map:
|
||||
# When depending on this package from a real application you should use:
|
||||
|
@ -23,6 +23,7 @@ dependencies:
|
|||
# the parent directory to use the current plugin's version.
|
||||
path: ../
|
||||
x_common: ^1.0.4
|
||||
x_amap_base: ^1.0.3
|
||||
|
||||
# amap_map_extensions: ^0.0.1
|
||||
# amap_map_extensions:
|
||||
|
|
|
@ -262,6 +262,15 @@
|
|||
|
||||
// 设置logo的位置
|
||||
self.logoCenter = logoCenter;
|
||||
|
||||
// 设置地图语言
|
||||
NSString *mapLanguage = dict[@"mapLanguage"];
|
||||
// 中文:@0: 英文:@1. 英文使用注意事项:1、不能和自定义地图样式同时使用;2、英文状态只在MAMapTypeStandard生效
|
||||
if ([mapLanguage isEqualToString:@"zh_cn"]) {
|
||||
self.mapLanguage = @0;
|
||||
} else if ([mapLanguage isEqualToString:@"en"]) {
|
||||
self.mapLanguage = @1;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -24,7 +24,6 @@ import 'package:flutter/foundation.dart';
|
|||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:x_common/utils/logger.dart';
|
||||
|
||||
export 'package:amap_map/src/types/types.dart';
|
||||
|
||||
|
|
|
@ -108,6 +108,9 @@ class AMapWidget extends StatefulWidget {
|
|||
|
||||
final List<AMapExtension> extensions;
|
||||
|
||||
/// 设置地图语言
|
||||
final MapLanguage? mapLanguage;
|
||||
|
||||
/// 创建一个展示高德地图的widget
|
||||
///
|
||||
/// 在app首次启动时必须传入高德合规声明配置[privacyStatement],后续如果没有变化不需要重复设置
|
||||
|
@ -150,6 +153,7 @@ class AMapWidget extends StatefulWidget {
|
|||
this.polylines = const <Polyline>{},
|
||||
this.polygons = const <Polygon>{},
|
||||
this.extensions = const [],
|
||||
this.mapLanguage,
|
||||
this.logoPosition,
|
||||
this.logoBottomMargin,
|
||||
this.logoLeftMargin})
|
||||
|
@ -380,47 +384,51 @@ class _AMapOptions {
|
|||
final int? logoBottomMargin;
|
||||
final int? logoLeftMargin;
|
||||
|
||||
_AMapOptions({
|
||||
this.mapType = MapType.normal,
|
||||
this.buildingsEnabled,
|
||||
this.customStyleOptions,
|
||||
this.myLocationStyleOptions,
|
||||
this.compassEnabled,
|
||||
this.labelsEnabled,
|
||||
this.limitBounds,
|
||||
this.minMaxZoomPreference,
|
||||
this.scaleEnabled,
|
||||
this.touchPoiEnabled,
|
||||
this.trafficEnabled,
|
||||
this.rotateGesturesEnabled,
|
||||
this.scrollGesturesEnabled,
|
||||
this.tiltGesturesEnabled,
|
||||
this.zoomGesturesEnabled,
|
||||
this.logoPosition,
|
||||
this.logoBottomMargin,
|
||||
this.logoLeftMargin,
|
||||
});
|
||||
final MapLanguage? mapLanguage;
|
||||
|
||||
_AMapOptions(
|
||||
{this.mapType = MapType.normal,
|
||||
this.buildingsEnabled,
|
||||
this.customStyleOptions,
|
||||
this.myLocationStyleOptions,
|
||||
this.compassEnabled,
|
||||
this.labelsEnabled,
|
||||
this.limitBounds,
|
||||
this.minMaxZoomPreference,
|
||||
this.scaleEnabled,
|
||||
this.touchPoiEnabled,
|
||||
this.trafficEnabled,
|
||||
this.rotateGesturesEnabled,
|
||||
this.scrollGesturesEnabled,
|
||||
this.tiltGesturesEnabled,
|
||||
this.zoomGesturesEnabled,
|
||||
this.logoPosition,
|
||||
this.logoBottomMargin,
|
||||
this.logoLeftMargin,
|
||||
this.mapLanguage});
|
||||
|
||||
static _AMapOptions fromWidget(AMapWidget map) {
|
||||
return _AMapOptions(
|
||||
mapType: map.mapType,
|
||||
buildingsEnabled: map.buildingsEnabled,
|
||||
compassEnabled: map.compassEnabled,
|
||||
labelsEnabled: map.labelsEnabled,
|
||||
limitBounds: map.limitBounds,
|
||||
minMaxZoomPreference: map.minMaxZoomPreference,
|
||||
scaleEnabled: map.scaleEnabled,
|
||||
touchPoiEnabled: map.touchPoiEnabled,
|
||||
trafficEnabled: map.trafficEnabled,
|
||||
rotateGesturesEnabled: map.rotateGesturesEnabled,
|
||||
scrollGesturesEnabled: map.scrollGesturesEnabled,
|
||||
tiltGesturesEnabled: map.tiltGesturesEnabled,
|
||||
zoomGesturesEnabled: map.zoomGesturesEnabled,
|
||||
customStyleOptions: map.customStyleOptions?.clone(),
|
||||
myLocationStyleOptions: map.myLocationStyleOptions?.clone(),
|
||||
logoPosition: map.logoPosition?.index,
|
||||
logoBottomMargin: map.logoBottomMargin,
|
||||
logoLeftMargin: map.logoLeftMargin);
|
||||
mapType: map.mapType,
|
||||
buildingsEnabled: map.buildingsEnabled,
|
||||
compassEnabled: map.compassEnabled,
|
||||
labelsEnabled: map.labelsEnabled,
|
||||
limitBounds: map.limitBounds,
|
||||
minMaxZoomPreference: map.minMaxZoomPreference,
|
||||
scaleEnabled: map.scaleEnabled,
|
||||
touchPoiEnabled: map.touchPoiEnabled,
|
||||
trafficEnabled: map.trafficEnabled,
|
||||
rotateGesturesEnabled: map.rotateGesturesEnabled,
|
||||
scrollGesturesEnabled: map.scrollGesturesEnabled,
|
||||
tiltGesturesEnabled: map.tiltGesturesEnabled,
|
||||
zoomGesturesEnabled: map.zoomGesturesEnabled,
|
||||
customStyleOptions: map.customStyleOptions?.clone(),
|
||||
myLocationStyleOptions: map.myLocationStyleOptions?.clone(),
|
||||
logoPosition: map.logoPosition?.index,
|
||||
logoBottomMargin: map.logoBottomMargin,
|
||||
logoLeftMargin: map.logoLeftMargin,
|
||||
mapLanguage: map.mapLanguage,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
|
@ -449,6 +457,7 @@ class _AMapOptions {
|
|||
addIfNonNull('logoPosition', logoPosition);
|
||||
addIfNonNull('logoBottomMargin', logoBottomMargin);
|
||||
addIfNonNull('logoLeftMargin', logoLeftMargin);
|
||||
addIfNonNull('mapLanguage', mapLanguage?.value);
|
||||
return optionsMap;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,15 @@ enum MapType {
|
|||
bus,
|
||||
}
|
||||
|
||||
/// 地图底图语言,目前支持中文底图和英文底图
|
||||
enum MapLanguage {
|
||||
chinese('zh_cn'),
|
||||
english('en');
|
||||
|
||||
final String value;
|
||||
const MapLanguage(this.value);
|
||||
}
|
||||
|
||||
// 设置摄像机的边界.
|
||||
class CameraTargetBounds {
|
||||
/// 使用指定的边界框或空值创建摄影机目标边界
|
||||
|
|
Loading…
Reference in New Issue