release 1.0.7, Close Issue #10 , 添加Logo位置设置
This commit is contained in:
@ -34,5 +34,6 @@ android {
|
||||
|
||||
dependencies {
|
||||
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 androidx.annotation.IntRange;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
|
||||
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.MyLocationStyle;
|
||||
import com.amap.flutter.map.core.AMapOptionsSink;
|
||||
import com.amap.flutter.map.core.UISettingsSink;
|
||||
import com.amap.flutter.map.utils.LogUtil;
|
||||
|
||||
import java.util.List;
|
||||
@ -22,7 +24,7 @@ import io.flutter.plugin.common.BinaryMessenger;
|
||||
* @mail hongming.whm@alibaba-inc.com
|
||||
* @since
|
||||
*/
|
||||
class AMapOptionsBuilder implements AMapOptionsSink {
|
||||
class AMapOptionsBuilder implements AMapOptionsSink, UISettingsSink {
|
||||
private static final String CLASS_NAME = "AMapOptionsBuilder";
|
||||
private final AMapOptions options = new AMapOptions();
|
||||
private CustomMapStyleOptions customMapStyleOptions;
|
||||
@ -36,6 +38,10 @@ class AMapOptionsBuilder implements AMapOptionsSink {
|
||||
private boolean buildingsEnabled = 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 anchorY = 2.0F;
|
||||
|
||||
@ -82,6 +88,10 @@ class AMapOptionsBuilder implements AMapOptionsSink {
|
||||
aMapPlatformView.getMapController().setBuildingsEnabled(buildingsEnabled);
|
||||
aMapPlatformView.getMapController().setLabelsEnabled(labelsEnabled);
|
||||
|
||||
aMapPlatformView.getMapController().setLogoPosition(logoPosition);
|
||||
aMapPlatformView.getMapController().setLogoBottomMargin(logoBottomMargin);
|
||||
aMapPlatformView.getMapController().setLogoLeftMargin(logoLeftMargin);
|
||||
|
||||
|
||||
if (null != initialMarkers) {
|
||||
List<Object> markerList = (List<Object>) initialMarkers;
|
||||
@ -195,6 +205,27 @@ class AMapOptionsBuilder implements AMapOptionsSink {
|
||||
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
|
||||
public void setInitialMarkers(Object markersObject) {
|
||||
|
@ -1,5 +1,8 @@
|
||||
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.CustomMapStyleOptions;
|
||||
import com.amap.api.maps.model.LatLngBounds;
|
||||
@ -12,7 +15,7 @@ import com.amap.api.maps.model.MyLocationStyle;
|
||||
* @mail hongming.whm@alibaba-inc.com
|
||||
* @since
|
||||
*/
|
||||
public interface AMapOptionsSink {
|
||||
public interface AMapOptionsSink extends UISettingsSink {
|
||||
|
||||
void setCamera(CameraPosition camera);
|
||||
|
||||
@ -42,7 +45,6 @@ public interface AMapOptionsSink {
|
||||
|
||||
public void setScaleEnabled(boolean scaleEnabled);
|
||||
|
||||
|
||||
public void setZoomGesturesEnabled(boolean zoomGesturesEnabled);
|
||||
|
||||
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) {
|
||||
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) {
|
||||
LogUtil.e(CLASS_NAME, "interpretAMapOptions", e);
|
||||
}
|
||||
|
Reference in New Issue
Block a user