release 1.0.7, Close Issue #10 , 添加Logo位置设置
This commit is contained in:
@ -1,3 +1,7 @@
|
|||||||
|
## 1.0.6
|
||||||
|
2024-07-28.
|
||||||
|
* Close Issue [#10](https://github.com/kuloud/amap_map/issues/10) 添加Logo位置设置,参见example: map_ui_options.dart
|
||||||
|
|
||||||
## 1.0.6
|
## 1.0.6
|
||||||
2024-06-27.
|
2024-06-27.
|
||||||
* 升级amap android sdk版本 V10.0.700_loc6.4.5_sea9.7.2 2024-05-13 看高德更新日志,应该是计划后续版本捆绑loc+search一起更新了
|
* 升级amap android sdk版本 V10.0.700_loc6.4.5_sea9.7.2 2024-05-13 看高德更新日志,应该是计划后续版本捆绑loc+search一起更新了
|
||||||
|
@ -34,5 +34,6 @@ android {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.amap.api:3dmap-location-search:10.0.700_loc6.4.5_sea9.7.2'
|
implementation 'com.amap.api:3dmap-location-search:10.0.700_loc6.4.5_sea9.7.2'
|
||||||
|
implementation 'androidx.annotation:annotation:1.8.1'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package com.amap.flutter.map;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
|
import androidx.annotation.IntRange;
|
||||||
import androidx.lifecycle.LifecycleOwner;
|
import androidx.lifecycle.LifecycleOwner;
|
||||||
|
|
||||||
import com.amap.api.maps.AMapOptions;
|
import com.amap.api.maps.AMapOptions;
|
||||||
@ -10,6 +11,7 @@ import com.amap.api.maps.model.CustomMapStyleOptions;
|
|||||||
import com.amap.api.maps.model.LatLngBounds;
|
import com.amap.api.maps.model.LatLngBounds;
|
||||||
import com.amap.api.maps.model.MyLocationStyle;
|
import com.amap.api.maps.model.MyLocationStyle;
|
||||||
import com.amap.flutter.map.core.AMapOptionsSink;
|
import com.amap.flutter.map.core.AMapOptionsSink;
|
||||||
|
import com.amap.flutter.map.core.UISettingsSink;
|
||||||
import com.amap.flutter.map.utils.LogUtil;
|
import com.amap.flutter.map.utils.LogUtil;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -22,7 +24,7 @@ import io.flutter.plugin.common.BinaryMessenger;
|
|||||||
* @mail hongming.whm@alibaba-inc.com
|
* @mail hongming.whm@alibaba-inc.com
|
||||||
* @since
|
* @since
|
||||||
*/
|
*/
|
||||||
class AMapOptionsBuilder implements AMapOptionsSink {
|
class AMapOptionsBuilder implements AMapOptionsSink, UISettingsSink {
|
||||||
private static final String CLASS_NAME = "AMapOptionsBuilder";
|
private static final String CLASS_NAME = "AMapOptionsBuilder";
|
||||||
private final AMapOptions options = new AMapOptions();
|
private final AMapOptions options = new AMapOptions();
|
||||||
private CustomMapStyleOptions customMapStyleOptions;
|
private CustomMapStyleOptions customMapStyleOptions;
|
||||||
@ -36,6 +38,10 @@ class AMapOptionsBuilder implements AMapOptionsSink {
|
|||||||
private boolean buildingsEnabled = true;
|
private boolean buildingsEnabled = true;
|
||||||
private boolean labelsEnabled = true;
|
private boolean labelsEnabled = true;
|
||||||
|
|
||||||
|
private int logoPosition = AMapOptions.LOGO_POSITION_BOTTOM_LEFT;
|
||||||
|
private int logoBottomMargin = 0;
|
||||||
|
private int logoLeftMargin = 0;
|
||||||
|
|
||||||
private float anchorX = 2.0F;
|
private float anchorX = 2.0F;
|
||||||
private float anchorY = 2.0F;
|
private float anchorY = 2.0F;
|
||||||
|
|
||||||
@ -82,6 +88,10 @@ class AMapOptionsBuilder implements AMapOptionsSink {
|
|||||||
aMapPlatformView.getMapController().setBuildingsEnabled(buildingsEnabled);
|
aMapPlatformView.getMapController().setBuildingsEnabled(buildingsEnabled);
|
||||||
aMapPlatformView.getMapController().setLabelsEnabled(labelsEnabled);
|
aMapPlatformView.getMapController().setLabelsEnabled(labelsEnabled);
|
||||||
|
|
||||||
|
aMapPlatformView.getMapController().setLogoPosition(logoPosition);
|
||||||
|
aMapPlatformView.getMapController().setLogoBottomMargin(logoBottomMargin);
|
||||||
|
aMapPlatformView.getMapController().setLogoLeftMargin(logoLeftMargin);
|
||||||
|
|
||||||
|
|
||||||
if (null != initialMarkers) {
|
if (null != initialMarkers) {
|
||||||
List<Object> markerList = (List<Object>) initialMarkers;
|
List<Object> markerList = (List<Object>) initialMarkers;
|
||||||
@ -195,6 +205,27 @@ class AMapOptionsBuilder implements AMapOptionsSink {
|
|||||||
options.scaleControlsEnabled(scaleEnabled);
|
options.scaleControlsEnabled(scaleEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setLogoPosition(@IntRange(from = AMapOptions.LOGO_POSITION_BOTTOM_LEFT, to = AMapOptions.LOGO_POSITION_BOTTOM_RIGHT) int logoPosition) {
|
||||||
|
options.logoPosition(logoPosition);
|
||||||
|
this.logoPosition = logoPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getLogoPosition() {
|
||||||
|
return options.getLogoPosition();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setLogoBottomMargin(int pixels) {
|
||||||
|
this.logoBottomMargin = pixels;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setLogoLeftMargin(int pixels) {
|
||||||
|
this.logoLeftMargin = pixels;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setInitialMarkers(Object markersObject) {
|
public void setInitialMarkers(Object markersObject) {
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package com.amap.flutter.map.core;
|
package com.amap.flutter.map.core;
|
||||||
|
|
||||||
|
import androidx.annotation.IntRange;
|
||||||
|
|
||||||
|
import com.amap.api.maps.AMapOptions;
|
||||||
import com.amap.api.maps.model.CameraPosition;
|
import com.amap.api.maps.model.CameraPosition;
|
||||||
import com.amap.api.maps.model.CustomMapStyleOptions;
|
import com.amap.api.maps.model.CustomMapStyleOptions;
|
||||||
import com.amap.api.maps.model.LatLngBounds;
|
import com.amap.api.maps.model.LatLngBounds;
|
||||||
@ -12,7 +15,7 @@ import com.amap.api.maps.model.MyLocationStyle;
|
|||||||
* @mail hongming.whm@alibaba-inc.com
|
* @mail hongming.whm@alibaba-inc.com
|
||||||
* @since
|
* @since
|
||||||
*/
|
*/
|
||||||
public interface AMapOptionsSink {
|
public interface AMapOptionsSink extends UISettingsSink {
|
||||||
|
|
||||||
void setCamera(CameraPosition camera);
|
void setCamera(CameraPosition camera);
|
||||||
|
|
||||||
@ -42,7 +45,6 @@ public interface AMapOptionsSink {
|
|||||||
|
|
||||||
public void setScaleEnabled(boolean scaleEnabled);
|
public void setScaleEnabled(boolean scaleEnabled);
|
||||||
|
|
||||||
|
|
||||||
public void setZoomGesturesEnabled(boolean zoomGesturesEnabled);
|
public void setZoomGesturesEnabled(boolean zoomGesturesEnabled);
|
||||||
|
|
||||||
public void setScrollGesturesEnabled(boolean scrollGesturesEnabled);
|
public void setScrollGesturesEnabled(boolean scrollGesturesEnabled);
|
||||||
|
@ -356,4 +356,29 @@ public class MapController
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setLogoPosition(int logoPosition) {
|
||||||
|
if (null != amap) {
|
||||||
|
amap.getUiSettings().setLogoPosition(logoPosition);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getLogoPosition() {
|
||||||
|
return null != amap ? amap.getUiSettings().getLogoPosition() : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setLogoBottomMargin(int pixels) {
|
||||||
|
if (null != amap) {
|
||||||
|
amap.getUiSettings().setLogoBottomMargin(pixels);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setLogoLeftMargin(int pixels) {
|
||||||
|
if (null != amap) {
|
||||||
|
amap.getUiSettings().setLogoLeftMargin(pixels);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,41 @@
|
|||||||
|
package com.amap.flutter.map.core;
|
||||||
|
|
||||||
|
import androidx.annotation.IntRange;
|
||||||
|
|
||||||
|
import com.amap.api.maps.AMapOptions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kuloud
|
||||||
|
*/
|
||||||
|
public interface UISettingsSink {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置“高德地图”Logo的位置。
|
||||||
|
*
|
||||||
|
* @param logoPosition
|
||||||
|
*/
|
||||||
|
void setLogoPosition(@IntRange(from = AMapOptions.LOGO_POSITION_BOTTOM_LEFT, to = AMapOptions.LOGO_POSITION_BOTTOM_RIGHT) int logoPosition);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取“高德地图”Logo的位置。
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int getLogoPosition();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置Logo下边界距离屏幕底部的边距
|
||||||
|
* Note: SDK 内有setLogoMarginRate接口按比例设置Logo位置,但是高德官方文档没有相关参数描述
|
||||||
|
*
|
||||||
|
* @param pixels
|
||||||
|
*/
|
||||||
|
void setLogoBottomMargin(int pixels);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置Logo左边界距离屏幕左侧的边距
|
||||||
|
* Note: SDK 内有setLogoMarginRate接口按比例设置Logo位置,但是高德官方文档没有相关参数描述
|
||||||
|
*
|
||||||
|
* @param pixels
|
||||||
|
*/
|
||||||
|
void setLogoLeftMargin(int pixels);
|
||||||
|
}
|
@ -278,6 +278,21 @@ public class ConvertUtil {
|
|||||||
if (null != zoomGesturesEnabled) {
|
if (null != zoomGesturesEnabled) {
|
||||||
sink.setZoomGesturesEnabled(toBoolean(zoomGesturesEnabled));
|
sink.setZoomGesturesEnabled(toBoolean(zoomGesturesEnabled));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final Object logoPosition = data.get("logoPosition");
|
||||||
|
if (null != logoPosition) {
|
||||||
|
sink.setLogoPosition(toInt(logoPosition));
|
||||||
|
}
|
||||||
|
|
||||||
|
final Object logoBottomMargin = data.get("logoBottomMargin");
|
||||||
|
if (null != logoBottomMargin) {
|
||||||
|
sink.setLogoBottomMargin(toInt(logoBottomMargin));
|
||||||
|
}
|
||||||
|
|
||||||
|
final Object logoLeftMargin = data.get("logoLeftMargin");
|
||||||
|
if (null != logoLeftMargin) {
|
||||||
|
sink.setLogoLeftMargin(toInt(logoLeftMargin));
|
||||||
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
LogUtil.e(CLASS_NAME, "interpretAMapOptions", e);
|
LogUtil.e(CLASS_NAME, "interpretAMapOptions", e);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
import 'package:amap_map/amap_map.dart';
|
import 'package:amap_map/amap_map.dart';
|
||||||
import 'package:amap_map_example/widgets/amap_gridview.dart';
|
import 'package:amap_map_example/widgets/amap_gridview.dart';
|
||||||
|
import 'package:amap_map_example/widgets/amap_radio_group.dart';
|
||||||
import 'package:amap_map_example/widgets/amap_switch_button.dart';
|
import 'package:amap_map_example/widgets/amap_switch_button.dart';
|
||||||
import 'package:flutter/material.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 {
|
class MapUIDemoPage extends StatefulWidget {
|
||||||
MapUIDemoPage({Key? key}) : super(key: key);
|
MapUIDemoPage({Key? key}) : super(key: key);
|
||||||
@ -26,6 +29,16 @@ class _BodyState extends State<MapUIDemoPage> {
|
|||||||
///是否显示比例尺
|
///是否显示比例尺
|
||||||
bool _scaleEnabled = true;
|
bool _scaleEnabled = true;
|
||||||
|
|
||||||
|
LogoPosition _logoPosition = LogoPosition.BOTTOM_LEFT;
|
||||||
|
int _logoBottomMargin = 0;
|
||||||
|
int _logoLeftMargin = 0;
|
||||||
|
|
||||||
|
final Map<String, LogoPosition?> _radioValueMap = {
|
||||||
|
'底部居左': LogoPosition.BOTTOM_LEFT,
|
||||||
|
'底部居中': LogoPosition.BOTTOM_CENTER,
|
||||||
|
'底部居右': LogoPosition.BOTTOM_RIGHT,
|
||||||
|
};
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final AMapWidget map = AMapWidget(
|
final AMapWidget map = AMapWidget(
|
||||||
@ -34,6 +47,9 @@ class _BodyState extends State<MapUIDemoPage> {
|
|||||||
compassEnabled: _compassEnabled,
|
compassEnabled: _compassEnabled,
|
||||||
labelsEnabled: _labelsEnabled,
|
labelsEnabled: _labelsEnabled,
|
||||||
scaleEnabled: _scaleEnabled,
|
scaleEnabled: _scaleEnabled,
|
||||||
|
logoPosition: _logoPosition,
|
||||||
|
logoBottomMargin: _logoBottomMargin,
|
||||||
|
logoLeftMargin: _logoLeftMargin,
|
||||||
);
|
);
|
||||||
|
|
||||||
//ui控制
|
//ui控制
|
||||||
@ -97,6 +113,43 @@ class _BodyState extends State<MapUIDemoPage> {
|
|||||||
padding: EdgeInsets.only(left: 10),
|
padding: EdgeInsets.only(left: 10),
|
||||||
child: AMapGradView(childrenWidgets: _uiOptions),
|
child: AMapGradView(childrenWidgets: _uiOptions),
|
||||||
),
|
),
|
||||||
|
AMapRadioGroup<LogoPosition?>(
|
||||||
|
groupLabel: 'Logo位置',
|
||||||
|
groupValue: _logoPosition,
|
||||||
|
radioValueMap: _radioValueMap,
|
||||||
|
onChanged: (value) => {
|
||||||
|
//改变当前地图样式为选中的样式
|
||||||
|
setState(() {
|
||||||
|
_logoPosition = value!;
|
||||||
|
})
|
||||||
|
},
|
||||||
|
),
|
||||||
|
Text('Logo底部边距: $_logoBottomMargin'),
|
||||||
|
Slider(
|
||||||
|
value: _logoBottomMargin.toDouble(),
|
||||||
|
min: 0,
|
||||||
|
max: 100,
|
||||||
|
divisions: 100,
|
||||||
|
label: _logoBottomMargin.round().toString(),
|
||||||
|
onChanged: (double value) {
|
||||||
|
setState(() {
|
||||||
|
_logoBottomMargin = value.round();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
Text('Logo左侧边距: $_logoLeftMargin'),
|
||||||
|
Slider(
|
||||||
|
value: _logoLeftMargin.toDouble(),
|
||||||
|
min: 0,
|
||||||
|
max: 100,
|
||||||
|
divisions: 100,
|
||||||
|
label: _logoLeftMargin.round().toString(),
|
||||||
|
onChanged: (double value) {
|
||||||
|
setState(() {
|
||||||
|
_logoLeftMargin = value.round();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -110,7 +163,7 @@ class _BodyState extends State<MapUIDemoPage> {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
height: MediaQuery.of(context).size.height * 0.7,
|
height: MediaQuery.of(context).size.height * 0.5,
|
||||||
width: MediaQuery.of(context).size.width,
|
width: MediaQuery.of(context).size.width,
|
||||||
child: map,
|
child: map,
|
||||||
),
|
),
|
||||||
|
@ -5,7 +5,7 @@ class AMapRadioGroup<T> extends StatefulWidget {
|
|||||||
final String? groupLabel;
|
final String? groupLabel;
|
||||||
final T? groupValue;
|
final T? groupValue;
|
||||||
final Map<String, T>? radioValueMap;
|
final Map<String, T>? radioValueMap;
|
||||||
final ValueChanged<T>? onChanged;
|
final ValueChanged<T?>? onChanged;
|
||||||
AMapRadioGroup(
|
AMapRadioGroup(
|
||||||
{Key? key,
|
{Key? key,
|
||||||
this.groupLabel,
|
this.groupLabel,
|
||||||
@ -15,37 +15,35 @@ class AMapRadioGroup<T> extends StatefulWidget {
|
|||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_AMapRadioGroupState createState() => _AMapRadioGroupState();
|
_AMapRadioGroupState<T> createState() => _AMapRadioGroupState<T>();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _AMapRadioGroupState extends State<AMapRadioGroup> {
|
class _AMapRadioGroupState<T> extends State<AMapRadioGroup<T>> {
|
||||||
dynamic _groupValue;
|
T? _groupValue;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_groupValue = widget.groupValue ?? null;
|
_groupValue = (widget.groupValue ?? null) as T?;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
List<Widget> radioList = <Widget>[];
|
List<Widget> radioList = <Widget>[];
|
||||||
_groupValue = widget.groupValue ?? null;
|
_groupValue = (widget.groupValue ?? null) as T?;
|
||||||
Widget _myRadio(String label, dynamic radioValue) {
|
Widget _myRadio(String label, dynamic radioValue) {
|
||||||
return Row(
|
return Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Text(label),
|
Text(label),
|
||||||
Radio<dynamic>(
|
Radio<T>(
|
||||||
value: radioValue,
|
value: radioValue,
|
||||||
groupValue: _groupValue,
|
groupValue: _groupValue,
|
||||||
onChanged: (_value) {
|
onChanged: (T? _value) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_groupValue = _value;
|
_groupValue = _value;
|
||||||
});
|
});
|
||||||
if (null != widget.onChanged) {
|
widget.onChanged!(_value);
|
||||||
widget.onChanged!(_value);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -22,6 +22,7 @@ dependencies:
|
|||||||
# The example app is bundled with the plugin so we use a path dependency on
|
# The example app is bundled with the plugin so we use a path dependency on
|
||||||
# the parent directory to use the current plugin's version.
|
# the parent directory to use the current plugin's version.
|
||||||
path: ../
|
path: ../
|
||||||
|
x_common: ^1.0.4
|
||||||
|
|
||||||
# amap_map_extensions: ^0.0.1
|
# amap_map_extensions: ^0.0.1
|
||||||
# amap_map_extensions:
|
# amap_map_extensions:
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
// amap_map
|
// amap_map
|
||||||
//
|
//
|
||||||
// Created by lly on 2020/10/30.
|
// Created by lly on 2020/10/30.
|
||||||
|
// Updated by kuloud on 2024/07/29.
|
||||||
//
|
//
|
||||||
|
|
||||||
#import "MAMapView+Flutter.h"
|
#import "MAMapView+Flutter.h"
|
||||||
@ -217,6 +218,50 @@
|
|||||||
if (rotateCameraEnable) {
|
if (rotateCameraEnable) {
|
||||||
self.rotateCameraEnabled = [rotateCameraEnable boolValue];
|
self.rotateCameraEnabled = [rotateCameraEnable boolValue];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NSNumber *logoPosition = dict[@"logoPosition"];
|
||||||
|
NSNumber *logoBottomMargin = dict[@"logoBottomMargin"];
|
||||||
|
NSNumber *logoLeftMargin = dict[@"logoLeftMargin"];
|
||||||
|
|
||||||
|
CGSize mapSize = self.bounds.size;
|
||||||
|
CGSize logoSize = CGSizeMake(110, 40); // 官方文档只一行代码 _mapView.logoCenter = CGPointMake(CGRectGetWidth(self.view.bounds)-55, 450);,猜测logo的大小是110x40
|
||||||
|
|
||||||
|
CGPoint logoCenter = CGPointZero;
|
||||||
|
|
||||||
|
if (logoBottomMargin || logoLeftMargin) {
|
||||||
|
CGFloat bottomMargin = logoBottomMargin ? [logoBottomMargin floatValue] : 0;
|
||||||
|
CGFloat leftMargin = logoLeftMargin ? [logoLeftMargin floatValue] : 0;
|
||||||
|
|
||||||
|
logoCenter.x = leftMargin + logoSize.width / 2;
|
||||||
|
logoCenter.y = mapSize.height - bottomMargin - logoSize.height / 2;
|
||||||
|
|
||||||
|
} else if (logoPosition) {
|
||||||
|
NSInteger position = [logoPosition integerValue];
|
||||||
|
switch (position) {
|
||||||
|
case 0: // LOGO_POSITION_BOTTOM_LEFT
|
||||||
|
logoCenter = CGPointMake(logoSize.width / 2, mapSize.height - logoSize.height / 2);
|
||||||
|
break;
|
||||||
|
case 1: // LOGO_POSITION_BOTTOM_CENTER
|
||||||
|
logoCenter = CGPointMake(mapSize.width / 2, mapSize.height - logoSize.height / 2);
|
||||||
|
break;
|
||||||
|
case 2: // LOGO_POSITION_BOTTOM_RIGHT
|
||||||
|
logoCenter = CGPointMake(mapSize.width - logoSize.width / 2, mapSize.height - logoSize.height / 2);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// 默认为左下角
|
||||||
|
logoCenter = CGPointMake(logoSize.width / 2, mapSize.height - logoSize.height / 2);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logoCenter = CGPointMake(logoSize.width / 2, mapSize.height - logoSize.height / 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 确保logoCenter在mapView.bounds之内
|
||||||
|
logoCenter.x = MAX(logoSize.width / 2, MIN(logoCenter.x, mapSize.width - logoSize.width / 2));
|
||||||
|
logoCenter.y = MAX(logoSize.height / 2, MIN(logoCenter.y, mapSize.height - logoSize.height / 2));
|
||||||
|
|
||||||
|
// 设置logo的位置
|
||||||
|
self.logoCenter = logoCenter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -24,6 +24,7 @@ import 'package:flutter/foundation.dart';
|
|||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:x_common/utils/logger.dart';
|
||||||
|
|
||||||
export 'package:amap_map/src/types/types.dart';
|
export 'package:amap_map/src/types/types.dart';
|
||||||
|
|
||||||
|
@ -64,6 +64,12 @@ class AMapWidget extends StatefulWidget {
|
|||||||
///是否支持倾斜手势
|
///是否支持倾斜手势
|
||||||
final bool tiltGesturesEnabled;
|
final bool tiltGesturesEnabled;
|
||||||
|
|
||||||
|
final LogoPosition? logoPosition;
|
||||||
|
|
||||||
|
final int? logoBottomMargin;
|
||||||
|
|
||||||
|
final int? logoLeftMargin;
|
||||||
|
|
||||||
/// 地图上显示的Marker
|
/// 地图上显示的Marker
|
||||||
final Set<Marker> markers;
|
final Set<Marker> markers;
|
||||||
|
|
||||||
@ -140,7 +146,10 @@ class AMapWidget extends StatefulWidget {
|
|||||||
this.markers = const <Marker>{},
|
this.markers = const <Marker>{},
|
||||||
this.polylines = const <Polyline>{},
|
this.polylines = const <Polyline>{},
|
||||||
this.polygons = const <Polygon>{},
|
this.polygons = const <Polygon>{},
|
||||||
this.extensions = const []})
|
this.extensions = const [],
|
||||||
|
this.logoPosition,
|
||||||
|
this.logoBottomMargin,
|
||||||
|
this.logoLeftMargin})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
///
|
///
|
||||||
@ -362,6 +371,12 @@ class _AMapOptions {
|
|||||||
///是否支持仰角手势
|
///是否支持仰角手势
|
||||||
final bool? tiltGesturesEnabled;
|
final bool? tiltGesturesEnabled;
|
||||||
|
|
||||||
|
/// logo的位置
|
||||||
|
final int? logoPosition;
|
||||||
|
|
||||||
|
final int? logoBottomMargin;
|
||||||
|
final int? logoLeftMargin;
|
||||||
|
|
||||||
_AMapOptions({
|
_AMapOptions({
|
||||||
this.mapType = MapType.normal,
|
this.mapType = MapType.normal,
|
||||||
this.buildingsEnabled,
|
this.buildingsEnabled,
|
||||||
@ -378,26 +393,31 @@ class _AMapOptions {
|
|||||||
this.scrollGesturesEnabled,
|
this.scrollGesturesEnabled,
|
||||||
this.tiltGesturesEnabled,
|
this.tiltGesturesEnabled,
|
||||||
this.zoomGesturesEnabled,
|
this.zoomGesturesEnabled,
|
||||||
|
this.logoPosition,
|
||||||
|
this.logoBottomMargin,
|
||||||
|
this.logoLeftMargin,
|
||||||
});
|
});
|
||||||
|
|
||||||
static _AMapOptions fromWidget(AMapWidget map) {
|
static _AMapOptions fromWidget(AMapWidget map) {
|
||||||
return _AMapOptions(
|
return _AMapOptions(
|
||||||
mapType: map.mapType,
|
mapType: map.mapType,
|
||||||
buildingsEnabled: map.buildingsEnabled,
|
buildingsEnabled: map.buildingsEnabled,
|
||||||
compassEnabled: map.compassEnabled,
|
compassEnabled: map.compassEnabled,
|
||||||
labelsEnabled: map.labelsEnabled,
|
labelsEnabled: map.labelsEnabled,
|
||||||
limitBounds: map.limitBounds,
|
limitBounds: map.limitBounds,
|
||||||
minMaxZoomPreference: map.minMaxZoomPreference,
|
minMaxZoomPreference: map.minMaxZoomPreference,
|
||||||
scaleEnabled: map.scaleEnabled,
|
scaleEnabled: map.scaleEnabled,
|
||||||
touchPoiEnabled: map.touchPoiEnabled,
|
touchPoiEnabled: map.touchPoiEnabled,
|
||||||
trafficEnabled: map.trafficEnabled,
|
trafficEnabled: map.trafficEnabled,
|
||||||
rotateGesturesEnabled: map.rotateGesturesEnabled,
|
rotateGesturesEnabled: map.rotateGesturesEnabled,
|
||||||
scrollGesturesEnabled: map.scrollGesturesEnabled,
|
scrollGesturesEnabled: map.scrollGesturesEnabled,
|
||||||
tiltGesturesEnabled: map.tiltGesturesEnabled,
|
tiltGesturesEnabled: map.tiltGesturesEnabled,
|
||||||
zoomGesturesEnabled: map.zoomGesturesEnabled,
|
zoomGesturesEnabled: map.zoomGesturesEnabled,
|
||||||
customStyleOptions: map.customStyleOptions?.clone(),
|
customStyleOptions: map.customStyleOptions?.clone(),
|
||||||
myLocationStyleOptions: map.myLocationStyleOptions?.clone(),
|
myLocationStyleOptions: map.myLocationStyleOptions?.clone(),
|
||||||
);
|
logoPosition: map.logoPosition?.index,
|
||||||
|
logoBottomMargin: map.logoBottomMargin,
|
||||||
|
logoLeftMargin: map.logoLeftMargin);
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, dynamic> toMap() {
|
Map<String, dynamic> toMap() {
|
||||||
@ -423,6 +443,9 @@ class _AMapOptions {
|
|||||||
addIfNonNull('tiltGesturesEnabled', tiltGesturesEnabled);
|
addIfNonNull('tiltGesturesEnabled', tiltGesturesEnabled);
|
||||||
addIfNonNull('zoomGesturesEnabled', zoomGesturesEnabled);
|
addIfNonNull('zoomGesturesEnabled', zoomGesturesEnabled);
|
||||||
addIfNonNull('myLocationStyle', myLocationStyleOptions?.clone().toMap());
|
addIfNonNull('myLocationStyle', myLocationStyleOptions?.clone().toMap());
|
||||||
|
addIfNonNull('logoPosition', logoPosition);
|
||||||
|
addIfNonNull('logoBottomMargin', logoBottomMargin);
|
||||||
|
addIfNonNull('logoLeftMargin', logoLeftMargin);
|
||||||
return optionsMap;
|
return optionsMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
name: amap_map
|
name: amap_map
|
||||||
description: Amap SDK Flutter plugin for integrating AMapSDK in iOS and Android applications.
|
description: Amap SDK Flutter plugin for integrating AMapSDK in iOS and Android applications.
|
||||||
version: 1.0.6
|
version: 1.0.7
|
||||||
homepage: https://github.com/kuloud/amap_map
|
homepage: https://github.com/kuloud/amap_map
|
||||||
issue_tracker: https://github.com/kuloud/amap_map/issues
|
issue_tracker: https://github.com/kuloud/amap_map/issues
|
||||||
platforms:
|
platforms:
|
||||||
@ -22,6 +22,7 @@ dependencies:
|
|||||||
stream_transform: ^2.0.0
|
stream_transform: ^2.0.0
|
||||||
|
|
||||||
x_amap_base: ^1.0.3
|
x_amap_base: ^1.0.3
|
||||||
|
x_common: ^1.0.4
|
||||||
# provider: ^6.1.1
|
# provider: ^6.1.1
|
||||||
# x_amap_base:
|
# x_amap_base:
|
||||||
# path: ../x_amap_base
|
# path: ../x_amap_base
|
||||||
|
Reference in New Issue
Block a user