release 1.0.3

This commit is contained in:
Kuloud 2024-01-03 17:12:29 +08:00
parent 6f49fc9228
commit 68178f96e3
24 changed files with 596 additions and 29 deletions

View File

@ -1,3 +1,7 @@
## 1.0.3
2024-01-03.
* AMapController 添加 toScreenCoordinate / fromScreenCoordinate实现屏幕坐标和经纬度的互相转换
## 1.0.2 ## 1.0.2
2023-12-30. 2023-12-30.
* 增加插件支持 * 增加插件支持

Binary file not shown.

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
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

234
android/gradlew vendored Executable file
View File

@ -0,0 +1,234 @@
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
#
# 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
#
# https://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,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
APP_NAME="Gradle"
APP_BASE_NAME=${0##*/}
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
warn () {
echo "$*"
} >&2
die () {
echo
echo "$*"
echo
exit 1
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"

89
android/gradlew.bat vendored Normal file
View File

@ -0,0 +1,89 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View File

@ -1,6 +1,7 @@
package com.amap.flutter.map.core; package com.amap.flutter.map.core;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Point;
import android.location.Location; import android.location.Location;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
@ -126,6 +127,16 @@ public class MapController
amap.removecache(); amap.removecache();
result.success(null); result.success(null);
break; break;
case Const.METHOD_MAP_TO_SCREEN_COORDINATE:
LatLng argLatLng = ConvertUtil.toLatLng(call.arguments);
Point resScreenLocation = amap.getProjection().toScreenLocation(argLatLng);
result.success(ConvertUtil.pointToJson(resScreenLocation));
break;
case Const.METHOD_MAP_FROM_SCREEN_COORDINATE:
Point argPoint = ConvertUtil.pointFromMap(call.arguments);
LatLng resLatLng = amap.getProjection().fromScreenLocation(argPoint);
result.success(ConvertUtil.latLngToList(resLatLng));
break;
default: default:
LogUtil.w(CLASS_NAME, "onMethodCall not find methodId:" + call.method); LogUtil.w(CLASS_NAME, "onMethodCall not find methodId:" + call.method);
break; break;

View File

@ -1,6 +1,7 @@
package com.amap.flutter.map.utils; package com.amap.flutter.map.utils;
/** /**
* @author kuloud
* @author whm * @author whm
* @date 2020/11/10 9:44 PM * @date 2020/11/10 9:44 PM
* @mail hongming.whm@alibaba-inc.com * @mail hongming.whm@alibaba-inc.com
@ -18,6 +19,8 @@ public class Const {
public static final String METHOD_MAP_SET_RENDER_FPS = "map#setRenderFps"; public static final String METHOD_MAP_SET_RENDER_FPS = "map#setRenderFps";
public static final String METHOD_MAP_TAKE_SNAPSHOT = "map#takeSnapshot"; public static final String METHOD_MAP_TAKE_SNAPSHOT = "map#takeSnapshot";
public static final String METHOD_MAP_CLEAR_DISK = "map#clearDisk"; public static final String METHOD_MAP_CLEAR_DISK = "map#clearDisk";
public static final String METHOD_MAP_TO_SCREEN_COORDINATE = "map#toScreenCoordinate";
public static final String METHOD_MAP_FROM_SCREEN_COORDINATE = "map#fromScreenCoordinate";
public static final String[] METHOD_ID_LIST_FOR_MAP = { public static final String[] METHOD_ID_LIST_FOR_MAP = {
METHOD_MAP_CONTENT_APPROVAL_NUMBER, METHOD_MAP_CONTENT_APPROVAL_NUMBER,
@ -27,7 +30,10 @@ public class Const {
METHOD_MAP_MOVE_CAMERA, METHOD_MAP_MOVE_CAMERA,
METHOD_MAP_SET_RENDER_FPS, METHOD_MAP_SET_RENDER_FPS,
METHOD_MAP_TAKE_SNAPSHOT, METHOD_MAP_TAKE_SNAPSHOT,
METHOD_MAP_CLEAR_DISK}; METHOD_MAP_CLEAR_DISK,
METHOD_MAP_TO_SCREEN_COORDINATE,
METHOD_MAP_FROM_SCREEN_COORDINATE
};
/** /**

View File

@ -143,6 +143,12 @@ public class ConvertUtil {
return new Point(toPixels(data.get(0)), toPixels(data.get(1))); return new Point(toPixels(data.get(0)), toPixels(data.get(1)));
} }
public static Point pointFromMap(Object o) {
Object x = toMap(o).get("x");
Object y = toMap(o).get("y");
return new Point((int) x, (int) y);
}
public static float toFloatPixels(Object o) { public static float toFloatPixels(Object o) {
return toFloat(o) * density; return toFloat(o) * density;
} }
@ -497,6 +503,13 @@ public class ConvertUtil {
return (Map<?, ?>) o; return (Map<?, ?>) o;
} }
public static Map<String, Integer> pointToJson(Point point) {
final Map<String, Integer> data = new HashMap<>(2);
data.put("x", point.x);
data.put("y", point.y);
return data;
}
public static String toString(Object o) { public static String toString(Object o) {
return (String) o; return (String) o;
} }

View File

@ -4,6 +4,9 @@ PODS:
- amap_map (0.0.1): - amap_map (0.0.1):
- AMap3DMap - AMap3DMap
- Flutter - Flutter
- amap_map_extensions (0.0.1):
- AMap3DMap
- Flutter
- AMapFoundation (1.8.2) - AMapFoundation (1.8.2)
- Flutter (1.0.0) - Flutter (1.0.0)
- permission_handler_apple (9.1.1): - permission_handler_apple (9.1.1):
@ -11,6 +14,7 @@ PODS:
DEPENDENCIES: DEPENDENCIES:
- amap_map (from `.symlinks/plugins/amap_map/ios`) - amap_map (from `.symlinks/plugins/amap_map/ios`)
- amap_map_extensions (from `.symlinks/plugins/amap_map_extensions/ios`)
- Flutter (from `Flutter`) - Flutter (from `Flutter`)
- permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`) - permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
@ -22,6 +26,8 @@ SPEC REPOS:
EXTERNAL SOURCES: EXTERNAL SOURCES:
amap_map: amap_map:
:path: ".symlinks/plugins/amap_map/ios" :path: ".symlinks/plugins/amap_map/ios"
amap_map_extensions:
:path: ".symlinks/plugins/amap_map_extensions/ios"
Flutter: Flutter:
:path: Flutter :path: Flutter
permission_handler_apple: permission_handler_apple:
@ -30,6 +36,7 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS: SPEC CHECKSUMS:
AMap3DMap: dce25dd3e51e6b92109caa7d0c97fc6055830fb3 AMap3DMap: dce25dd3e51e6b92109caa7d0c97fc6055830fb3
amap_map: fadcdab77d3fbb12a983c1e8aa434c3ef8dd4955 amap_map: fadcdab77d3fbb12a983c1e8aa434c3ef8dd4955
amap_map_extensions: 6d2affabf1ef14c7af8aa9eeb815b8b8453d92b0
AMapFoundation: 9885c48fc3a78fdfb84a0299a2293e56ea3c9fec AMapFoundation: 9885c48fc3a78fdfb84a0299a2293e56ea3c9fec
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
permission_handler_apple: e76247795d700c14ea09e3a2d8855d41ee80a2e6 permission_handler_apple: e76247795d700c14ea09e3a2d8855d41ee80a2e6

View File

@ -367,9 +367,10 @@
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Manual; CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = YMJ372W38W; DEVELOPMENT_TEAM = 459H548739;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
@ -379,6 +380,7 @@
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
/usr/lib/swift,
); );
LIBRARY_SEARCH_PATHS = ( LIBRARY_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
@ -386,7 +388,7 @@
); );
PRODUCT_BUNDLE_IDENTIFIER = com.autonavi.amapflutterdemo; PRODUCT_BUNDLE_IDENTIFIER = com.autonavi.amapflutterdemo;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = OpenPlatform_Dev; PROVISIONING_PROFILE_SPECIFIER = "";
VERSIONING_SYSTEM = "apple-generic"; VERSIONING_SYSTEM = "apple-generic";
}; };
name = Profile; name = Profile;
@ -501,9 +503,10 @@
baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Manual; CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = YMJ372W38W; DEVELOPMENT_TEAM = 459H548739;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
@ -513,6 +516,7 @@
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
/usr/lib/swift,
); );
LIBRARY_SEARCH_PATHS = ( LIBRARY_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
@ -520,7 +524,7 @@
); );
PRODUCT_BUNDLE_IDENTIFIER = com.autonavi.amapflutterdemo; PRODUCT_BUNDLE_IDENTIFIER = com.autonavi.amapflutterdemo;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = OpenPlatform_Dev; PROVISIONING_PROFILE_SPECIFIER = "";
VERSIONING_SYSTEM = "apple-generic"; VERSIONING_SYSTEM = "apple-generic";
}; };
name = Debug; name = Debug;
@ -530,9 +534,10 @@
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Manual; CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = YMJ372W38W; DEVELOPMENT_TEAM = 459H548739;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
@ -542,6 +547,7 @@
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
/usr/lib/swift,
); );
LIBRARY_SEARCH_PATHS = ( LIBRARY_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
@ -549,7 +555,7 @@
); );
PRODUCT_BUNDLE_IDENTIFIER = com.autonavi.amapflutterdemo; PRODUCT_BUNDLE_IDENTIFIER = com.autonavi.amapflutterdemo;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = OpenPlatform_Dev; PROVISIONING_PROFILE_SPECIFIER = "";
VERSIONING_SYSTEM = "apple-generic"; VERSIONING_SYSTEM = "apple-generic";
}; };
name = Release; name = Release;

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r"> <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="22505" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina6_12" orientation="portrait" appearance="light"/>
<dependencies> <dependencies>
<deployment identifier="iOS"/> <deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/> <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22504"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies> </dependencies>
<scenes> <scenes>
<!--Flutter View Controller--> <!--Flutter View Controller-->
@ -14,13 +16,14 @@
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/> <viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides> </layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC"> <view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/> <rect key="frame" x="0.0" y="0.0" width="393" height="852"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/> <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view> </view>
</viewController> </viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/> <placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects> </objects>
<point key="canvasLocation" x="48" y="-2"/>
</scene> </scene>
</scenes> </scenes>
</document> </document>

View File

@ -1,4 +1,16 @@
// import 'package:amap_map_extensions/amap_map_extensions.dart'; // Copyright 2023-2024 kuloud
// Copyright 2020 lbs.amap.com
// 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_extensions/amap_map_extensions.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'dart:typed_data'; import 'dart:typed_data';
@ -12,7 +24,7 @@ class MapWithExtensionPage extends StatefulWidget {
class _MapWithExtensionPageState extends State<MapWithExtensionPage> { class _MapWithExtensionPageState extends State<MapWithExtensionPage> {
List<Widget> _approvalNumberWidget = <Widget>[]; List<Widget> _approvalNumberWidget = <Widget>[];
// final _extension = AmapMapExtensions(); final _extension = AmapMapExtensions();
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {

View File

@ -23,7 +23,19 @@ class _State extends State<MarkerConfigDemoPage> {
BitmapDescriptor? _markerIcon; BitmapDescriptor? _markerIcon;
String? selectedMarkerId; String? selectedMarkerId;
void _onMapCreated(AMapController controller) {} Future<void> _onMapCreated(AMapController controller) async {
LatLng latLng = LatLng(mapCenter.latitude + sin(pi / 12.0) / 20.0,
mapCenter.longitude + cos(pi / 12.0) / 20.0);
try {
print('-latLng---------${latLng}');
ScreenCoordinate coordinate = await controller.toScreenCoordinate(latLng);
print('-coordinate---------${coordinate}');
LatLng reLatLng = await controller.fromScreenCoordinate(coordinate);
print('-reLatLng---------${reLatLng}');
} catch (e) {
print(e.toString());
}
}
///BitmapDescriptor.fromAssetImage的方式获取图片 ///BitmapDescriptor.fromAssetImage的方式获取图片
Future<void> _createMarkerImageFromAsset(BuildContext context) async { Future<void> _createMarkerImageFromAsset(BuildContext context) async {

View File

@ -23,7 +23,7 @@ dependencies:
# the parent directory to use the current plugin's version. # the parent directory to use the current plugin's version.
path: ../ path: ../
# amap_map_extensions: amap_map_extensions: ^0.0.1
# path: ../../amap_map_extensions # path: ../../amap_map_extensions

View File

@ -234,6 +234,16 @@
[weakSelf.mapView clearDisk]; [weakSelf.mapView clearDisk];
result(nil); result(nil);
}]; }];
[self.channel addMethodName:@"map#toScreenCoordinate" withHandler:^(FlutterMethodCall * _Nonnull call, FlutterResult _Nonnull result) {
CLLocationCoordinate2D location = [AMapConvertUtil coordinateFromArray:call.arguments];
CGPoint point = [weakSelf.mapView convertCoordinate:location toPointToView:weakSelf.mapView];
result([AMapConvertUtil dictionaryFromPoint:point]);
}];
[self.channel addMethodName:@"map#fromScreenCoordinate" withHandler:^(FlutterMethodCall * _Nonnull call, FlutterResult _Nonnull result) {
CGPoint point = [AMapConvertUtil pointFromDictionary:call.arguments];
CLLocationCoordinate2D coordinate = [weakSelf.mapView convertPoint:point toCoordinateFromView:weakSelf.mapView];
result([AMapConvertUtil arrayFromLocation:coordinate]);
}];
} }
//MARK: MAMapViewDelegate //MARK: MAMapViewDelegate

View File

@ -24,9 +24,7 @@ NS_ASSUME_NONNULL_BEGIN
/// @param numberColor 色值 /// @param numberColor 色值
+ (UIColor*)colorFromNumber:(NSNumber*)numberColor; + (UIColor*)colorFromNumber:(NSNumber*)numberColor;
/// 将数组内含数字转换为point坐标默认数组第一个元素为x值第二个为y值 + (CGPoint)pointFromDictionary:(NSDictionary *)dictionary;
/// @param data 数组
+ (CGPoint)pointFromArray:(NSArray*)data;
/// 从数据中解析经纬度 /// 从数据中解析经纬度
/// @param array 经纬度数组对(默认第一个当做维度,第二个当做经度) /// @param array 经纬度数组对(默认第一个当做维度,第二个当做经度)
@ -63,6 +61,14 @@ NS_ASSUME_NONNULL_BEGIN
/// @param array json数组[southwest,northeast],分别为西南、东北的坐标 /// @param array json数组[southwest,northeast],分别为西南、东北的坐标
+ (MAMapRect)mapRectFromArray:(NSArray *)array; + (MAMapRect)mapRectFromArray:(NSArray *)array;
+ (CGPoint)pointFromDictionary:(NSDictionary *)dictionary;
+ (CGPoint)pointFromArray:(NSArray *)array;
+ (NSDictionary<NSString *, NSNumber *> *)dictionaryFromPoint:(CGPoint)point;
+ (NSArray *)arrayFromLocation:(CLLocationCoordinate2D)location;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

View File

@ -27,11 +27,6 @@
alpha:((float)((value & 0xFF000000) >> 24)) / 255.0]; alpha:((float)((value & 0xFF000000) >> 24)) / 255.0];
} }
+ (CGPoint)pointFromArray:(NSArray*)data {
NSAssert((data != nil && [data isKindOfClass:[NSArray class]] && data.count == 2), @"数组类型转point格式错误");
return CGPointMake([data[0] doubleValue],
[data[1] doubleValue]);
}
/// ///
/// @param array /// @param array
@ -212,4 +207,28 @@
} }
+ (CGPoint)pointFromDictionary:(NSDictionary *)dictionary {
double x = [dictionary[@"x"] doubleValue];
double y = [dictionary[@"y"] doubleValue];
return CGPointMake(x, y);
}
+ (CGPoint)pointFromArray:(NSArray*)array {
NSAssert((array != nil && [array isKindOfClass:[NSArray class]] && array.count == 2), @"数组类型转point格式错误");
return CGPointMake([array[0] doubleValue],
[array[1] doubleValue]);
}
+ (NSDictionary<NSString *, NSNumber *> *)dictionaryFromPoint:(CGPoint)point {
return @{
@"x" : @(lroundf(point.x)),
@"y" : @(lroundf(point.y)),
};
}
+ (NSArray *)arrayFromLocation:(CLLocationCoordinate2D)location {
return @[ @(location.latitude), @(location.longitude) ];
}
@end @end

View File

@ -1,3 +1,15 @@
// Copyright 2023-2024 kuloud
// Copyright 2020 lbs.amap.com
// 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,
/// Flutter插件入口文件 /// Flutter插件入口文件
library amap_map; library amap_map;

View File

@ -1,3 +1,15 @@
// Copyright 2023-2024 kuloud
// Copyright 2020 lbs.amap.com
// 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,
part of amap_map; part of amap_map;
final MethodChannelAMapFlutterMap _methodChannel = final MethodChannelAMapFlutterMap _methodChannel =
@ -124,4 +136,14 @@ class AMapController {
Future<void> clearDisk() { Future<void> clearDisk() {
return _methodChannel.clearDisk(mapId: mapId); return _methodChannel.clearDisk(mapId: mapId);
} }
///
Future<ScreenCoordinate> toScreenCoordinate(LatLng latLng) {
return _methodChannel.toScreenLocation(latLng, mapId: mapId);
}
///
Future<LatLng> fromScreenCoordinate(ScreenCoordinate screenCoordinate) {
return _methodChannel.fromScreenLocation(screenCoordinate, mapId: mapId);
}
} }

View File

@ -1,3 +1,14 @@
// Copyright 2023-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,
part of amap_map; part of amap_map;
class AMapLoader extends StatefulWidget { class AMapLoader extends StatefulWidget {

View File

@ -1,4 +1,17 @@
// Copyright 2023-2024 kuloud
// Copyright 2020 lbs.amap.com
// 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 'dart:async'; import 'dart:async';
import 'dart:math';
import 'package:x_amap_base/x_amap_base.dart'; import 'package:x_amap_base/x_amap_base.dart';
import 'package:amap_map/src/core/amap_flutter_platform.dart'; import 'package:amap_map/src/core/amap_flutter_platform.dart';
@ -247,4 +260,24 @@ class MethodChannelAMapFlutterMap implements AMapFlutterPlatform {
}) { }) {
return channel(mapId).invokeMethod<void>('map#clearDisk'); return channel(mapId).invokeMethod<void>('map#clearDisk');
} }
Future<ScreenCoordinate> toScreenLocation(
LatLng latLng, {
required int mapId,
}) async {
final Map<String, int>? point = await channel(mapId)
.invokeMapMethod<String, int>(
'map#toScreenCoordinate', latLng.toJson());
return ScreenCoordinate(x: point!['x']!, y: point['y']!);
}
Future<LatLng> fromScreenLocation(
ScreenCoordinate screenCoordinate, {
required int mapId,
}) async {
final List<dynamic>? latLng = await channel(mapId)
.invokeMethod<List<dynamic>>(
'map#fromScreenCoordinate', screenCoordinate.toJson());
return LatLng(latLng![0] as double, latLng[1] as double);
}
} }

View File

@ -0,0 +1,44 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/foundation.dart' show immutable, objectRuntimeType;
/// Represents a point coordinate in the [GoogleMap]'s view.
///
/// The screen location is specified in screen pixels (not display pixels) relative
/// to the top left of the map, not top left of the whole screen. (x, y) = (0, 0)
/// corresponds to top-left of the [GoogleMap] not the whole screen.
@immutable
class ScreenCoordinate {
/// Creates an immutable representation of a point coordinate in the [GoogleMap]'s view.
const ScreenCoordinate({
required this.x,
required this.y,
});
/// Represents the number of pixels from the left of the [GoogleMap].
final int x;
/// Represents the number of pixels from the top of the [GoogleMap].
final int y;
/// Converts this object to something serializable in JSON.
Object toJson() {
return <String, int>{
'x': x,
'y': y,
};
}
@override
String toString() => '${objectRuntimeType(this, 'ScreenCoordinate')}($x, $y)';
@override
bool operator ==(Object other) {
return other is ScreenCoordinate && other.x == x && other.y == y;
}
@override
int get hashCode => Object.hash(x, y);
}

View File

@ -1,3 +1,15 @@
// Copyright 2023-2024 kuloud
// Copyright 2020 lbs.amap.com
// 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,
export 'camera.dart'; export 'camera.dart';
export 'ui.dart'; export 'ui.dart';
export 'base_overlay.dart'; export 'base_overlay.dart';
@ -10,3 +22,4 @@ export 'polygon_updates.dart';
export 'bitmap.dart'; export 'bitmap.dart';
export 'extension_context.dart'; export 'extension_context.dart';
export 'amap_extension.dart'; export 'amap_extension.dart';
export 'screen_coordinate.dart';

View File

@ -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.2 version: 1.0.3
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: