提交 f0784f7f authored 作者: shixiaochen's avatar shixiaochen

1、Android-设置已中心点地图缩放;

上级 06e01335
...@@ -39,6 +39,8 @@ class AMapOptionsBuilder implements AMapOptionsSink { ...@@ -39,6 +39,8 @@ class AMapOptionsBuilder implements AMapOptionsSink {
private float anchorX = 2.0F; private float anchorX = 2.0F;
private float anchorY = 2.0F; private float anchorY = 2.0F;
private boolean center = true;
private Object initialMarkers; private Object initialMarkers;
private Object initialPolylines; private Object initialPolylines;
...@@ -69,7 +71,8 @@ class AMapOptionsBuilder implements AMapOptionsSink { ...@@ -69,7 +71,8 @@ class AMapOptionsBuilder implements AMapOptionsSink {
aMapPlatformView.getMapController().setScreenAnchor( anchorX, anchorY); aMapPlatformView.getMapController().setScreenAnchor( anchorX, anchorY);
} }
// 设置以中心点缩放
aMapPlatformView.getMapController().setGestureScaleByMapCenter(true);
aMapPlatformView.getMapController().setMinZoomLevel(minZoomLevel); aMapPlatformView.getMapController().setMinZoomLevel(minZoomLevel);
aMapPlatformView.getMapController().setMaxZoomLevel(maxZoomLevel); aMapPlatformView.getMapController().setMaxZoomLevel(maxZoomLevel);
...@@ -130,6 +133,11 @@ class AMapOptionsBuilder implements AMapOptionsSink { ...@@ -130,6 +133,11 @@ class AMapOptionsBuilder implements AMapOptionsSink {
anchorY = y; anchorY = y;
} }
@Override
public void setGestureScaleByMapCenter(boolean center) {
this.center = center;
}
@Override @Override
public void setMinZoomLevel(float minZoomLevel) { public void setMinZoomLevel(float minZoomLevel) {
this.minZoomLevel = minZoomLevel; this.minZoomLevel = minZoomLevel;
......
...@@ -24,6 +24,8 @@ public interface AMapOptionsSink { ...@@ -24,6 +24,8 @@ public interface AMapOptionsSink {
public void setScreenAnchor(float x, float y); public void setScreenAnchor(float x, float y);
public void setGestureScaleByMapCenter(boolean center);
public void setMinZoomLevel(float minZoomLevel); public void setMinZoomLevel(float minZoomLevel);
public void setMaxZoomLevel(float maxZoomLevel); public void setMaxZoomLevel(float maxZoomLevel);
......
...@@ -285,6 +285,11 @@ public class MapController ...@@ -285,6 +285,11 @@ public class MapController
amap.setPointToCenter(Float.valueOf(mapView.getWidth() * x).intValue(), Float.valueOf(mapView.getHeight() * y).intValue()); amap.setPointToCenter(Float.valueOf(mapView.getWidth() * x).intValue(), Float.valueOf(mapView.getHeight() * y).intValue());
} }
@Override
public void setGestureScaleByMapCenter(boolean center) {
amap.getUiSettings().setGestureScaleByMapCenter(center);
}
@Override @Override
public void setMinZoomLevel(float minZoomLevel) { public void setMinZoomLevel(float minZoomLevel) {
amap.setMinZoomLevel(minZoomLevel); amap.setMinZoomLevel(minZoomLevel);
......
...@@ -24,12 +24,12 @@ if (flutterVersionName == null) { ...@@ -24,12 +24,12 @@ if (flutterVersionName == null) {
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
def keystorePropertiesFile = rootProject.file("app/key.properties") //def keystorePropertiesFile = rootProject.file("app/key.properties")
def keystoreProperties = new Properties() //def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) //keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
android { android {
compileSdkVersion 31 compileSdkVersion 33
lintOptions { lintOptions {
disable 'InvalidPackage' disable 'InvalidPackage'
...@@ -44,24 +44,24 @@ android { ...@@ -44,24 +44,24 @@ android {
versionName flutterVersionName versionName flutterVersionName
} }
signingConfigs { signingConfigs {
release { // release {
//keystore中key的别名 // //keystore中key的别名
keyAlias keystoreProperties['keyAlias'] // keyAlias keystoreProperties['keyAlias']
//keystore中key的密码 // //keystore中key的密码
keyPassword keystoreProperties['keyPassword'] // keyPassword keystoreProperties['keyPassword']
//keystore的文件路径,可以是绝对路径也可以是相对路径 // //keystore的文件路径,可以是绝对路径也可以是相对路径
storeFile file(keystoreProperties['storeFile']) // storeFile file(keystoreProperties['storeFile'])
//keystore的密码l // //keystore的密码l
storePassword keystoreProperties['storePassword'] // storePassword keystoreProperties['storePassword']
} // }
} }
buildTypes { buildTypes {
debug { debug {
signingConfig signingConfigs.release // signingConfig signingConfigs.release
} }
release { release {
// flutter build apk // flutter build apk
signingConfig signingConfigs.release // signingConfig signingConfigs.release
} }
} }
sourceSets { sourceSets {
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
android:value="6a158bd9bdede0d4276a7ab4fc45ca1b" /> android:value="6a158bd9bdede0d4276a7ab4fc45ca1b" />
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop" android:launchMode="singleTop"
android:theme="@style/LaunchTheme" android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
......
...@@ -5,7 +5,7 @@ buildscript { ...@@ -5,7 +5,7 @@ buildscript {
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.5.0' classpath 'com.android.tools.build:gradle:7.3.0'
} }
} }
...@@ -24,6 +24,6 @@ subprojects { ...@@ -24,6 +24,6 @@ subprojects {
project.evaluationDependsOn(':app') project.evaluationDependsOn(':app')
} }
task clean(type: Delete) { tasks.register("clean", Delete) {
delete rootProject.buildDir delete rootProject.buildDir
} }
...@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME ...@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip
import 'dart:typed_data'; import 'package:amap_flutter_map/amap_flutter_map.dart';
import 'package:amap_flutter_base/amap_flutter_base.dart';
import 'package:amap_flutter_map_example/base_page.dart'; import 'package:amap_flutter_map_example/base_page.dart';
import 'package:amap_flutter_map_example/const_config.dart'; import 'package:amap_flutter_map_example/const_config.dart';
import 'package:amap_flutter_map_example/widgets/amap_switch_button.dart'; import 'package:amap_flutter_map_example/widgets/amap_switch_button.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:amap_flutter_map/amap_flutter_map.dart';
class AllMapConfigDemoPage extends BasePage { class AllMapConfigDemoPage extends BasePage {
AllMapConfigDemoPage(String title, String subTitle) : super(title, subTitle); AllMapConfigDemoPage(String title, String subTitle) : super(title, subTitle);
...@@ -342,10 +338,21 @@ class _MapUiBodyState extends State<_MapUiBody> { ...@@ -342,10 +338,21 @@ class _MapUiBodyState extends State<_MapUiBody> {
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
Container( Stack(
height: MediaQuery.of(context).size.height * 0.6, children: [
width: MediaQuery.of(context).size.width, Container(
child: map, height: MediaQuery.of(context).size.height * 0.6,
width: MediaQuery.of(context).size.width,
child: map,
),
Positioned(
top: 0,
bottom: 0,
left: 0,
right: 0,
child: Icon(Icons.wrong_location_sharp,color: Colors.blue),
)
],
), ),
Expanded( Expanded(
child: SingleChildScrollView( child: SingleChildScrollView(
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论