addCircle method
添加圆
在点points
的位置添加线, 可以设置宽度width
和颜色strokeColor
Implementation
Future<void> addCircle(
LatLng point,
double radius, {
double width = 5,
Color fillColor = Colors.white,
Color strokeColor = Colors.black,
}) {
return platform(
android: (pool) async {
final map = await _androidController.getMap();
// 构造点
final latLng = await ObjectFactory_Android
.createcom_amap_api_maps_model_LatLng__double__double(
point.lat, point.lng);
// 构造参数
final circleOptions = await ObjectFactory_Android
.createcom_amap_api_maps_model_CircleOptions__();
// 添加参数
await circleOptions.center(latLng);
await circleOptions.radius(radius);
if (width != null) {
await circleOptions.strokeWidth(width);
}
if (strokeColor != null) {
await circleOptions
.strokeColor(Int32List.fromList([strokeColor.value])[0]);
}
if (fillColor != null)
await circleOptions
.fillColor(Int32List.fromList([fillColor.value])[0]);
// 设置参数
await map.addCircle(circleOptions);
pool..add(map)..add(circleOptions)..add(latLng);
},
ios: (pool) async {
await _iosController.set_delegate(_IOSMapDelegate());
final latLng = await ObjectFactory_iOS.createCLLocationCoordinate2D(
point.lat, point.lng);
// 参数
final circle =
await MACircle.circleWithCenterCoordinateRadius(latLng, radius);
// 宽度和颜色需要设置到STACK里去
if (width != null)
await ObjectFactory_iOS.pushStackJsonable('width', width);
if (strokeColor != null)
await ObjectFactory_iOS.pushStackJsonable(
'strokeColor', strokeColor.value);
if (fillColor != null)
await ObjectFactory_iOS.pushStackJsonable(
'fillColor', fillColor.value);
// 设置参数
await _iosController.addOverlay(circle);
pool..add(circle);
},
);
}