Commit c5a91ed7 authored by wind.wang's avatar wind.wang

init

parents
# Changelog
init project to ability platform
#1.2.8
修复安卓和ios多个map之间的跳转时,前一个页面的mark点击失效问题
#1.2.8
添加了 onMoveComplete函数,onMoveComplete 与 onChange只能二选一, onMoveComplete在移动地图的时候中心点变了都会调用
# 1.3.0
添加了 onMovingChange 回调函数
#2.0.0
集成github比较好的mapview组件,修复了一些bug
https://github.com/qiuxiang/react-native-amap3d
#2.0.1
重命名一些文件的名称,修复了ios的一些bug
#2.0.2-amap2d
s.dependency 'React'
#2.0.2-amap2d.3
web端的定位 AMap变量改为 window.AMap
#2.0.2-amap2d.4
中心点偶然会偏移
#2.0.2-amap2d.5
fetchLocation 错误信息安卓支持 if(error) 判断
\ No newline at end of file
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>android</name>
<comment>Project android created by Buildship.</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
</projectDescription>
arguments=
auto.sync=false
build.scans.enabled=false
connection.gradle.distribution=GRADLE_DISTRIBUTION(LOCAL_INSTALLATION(/Applications/Android Studio.app/Contents/gradle/gradle-3.2))
connection.project.dir=
eclipse.preferences.version=1
gradle.user.home=/Applications/Android Studio.app/Contents/gradle/gradle-3.2
java.home=
jvm.arguments=
offline.mode=false
override.workspace.settings=true
show.console.view=true
show.executions.view=true
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
}
}
}
buildscript {
ext.kotlin_version = '1.2.41'
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
}
}
allprojects {
repositories {
jcenter()
maven { url "$projectDir/../node_modules/react-native/android" }
}
}
dependencies {
compile 'com.android.support:appcompat-v7:23.1.0'
compile files('libs/AMap_Search_V4.0.0_20170111.jar')
compile files('libs/AMap_Location_V3.3.0_20170118.jar')
compile 'com.facebook.react:react-native:+'
}
\ No newline at end of file
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
#Mon Dec 28 10:00:20 PST 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
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" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
@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
@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=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@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 init
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 init
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
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
: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 %CMD_LINE_ARGS%
: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
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.terminus.rctamap">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
</manifest>
package io.terminus.rnamap;
import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import io.terminus.rnamap.service.GeocodeManager;
import io.terminus.rnamap.service.LocationManager;
import io.terminus.rnamap.service.MapNavigationManager;
/**
* io.terminus.rnamap
* Created by Allen.Chiang on 19/01/2017.
*/
public class AMapReactPackage implements ReactPackage {
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
List<NativeModule> modules = new ArrayList<>();
modules.add(new LocationManager(reactContext));
modules.add(new GeocodeManager(reactContext));
modules.add(new MapNavigationManager(reactContext));
return modules;
}
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
List<ViewManager> modules = new ArrayList<>();
return modules;
}
}
package io.terminus.rnamap;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.widget.Toast;
import com.amap.api.location.AMapLocation;
import com.amap.api.services.core.LatLonPoint;
import com.amap.api.services.geocoder.GeocodeAddress;
import com.amap.api.services.geocoder.RegeocodeAddress;
import com.amap.api.services.geocoder.StreetNumber;
import io.terminus.rnamap.model.LocationDO;
/**
* io.terminus.rnamap
* Created by Allen.Chiang on 22/01/2017.
*/
public class AMapUtils {
public static LocationDO createLocationDO(AMapLocation aMapLocation) {
LocationDO locationDO = new LocationDO();
locationDO.setLatitude(String.valueOf(aMapLocation.getLatitude()));
locationDO.setLongitude(String.valueOf(aMapLocation.getLongitude()));
locationDO.setAdCode(aMapLocation.getAdCode());
locationDO.setFormattedAddress(aMapLocation.getAddress());
locationDO.setCountry(aMapLocation.getCountry());
locationDO.setProvince(aMapLocation.getProvince());
locationDO.setCity(aMapLocation.getCity());
locationDO.setDistrict(aMapLocation.getDistrict());
locationDO.setCityCode(aMapLocation.getCityCode());
locationDO.setStreet(aMapLocation.getStreet());
locationDO.setNumber(aMapLocation.getStreetNum());
locationDO.setPOIName(aMapLocation.getPoiName());
locationDO.setAOIName(aMapLocation.getAoiName());
return locationDO;
}
/**
* 和iOS统一返回格式
*
* @param address address
* @return LocationDO
*/
public static LocationDO convert2Location(RegeocodeAddress address) {
LocationDO locationDO = new LocationDO();
locationDO.setFormattedAddress(address.getFormatAddress());
locationDO.setCountry(address.getTownship());
locationDO.setProvince(address.getProvince());
locationDO.setCityCode(address.getCityCode());
locationDO.setCity(address.getCity());
locationDO.setDistrict(address.getDistrict());
locationDO.setAdCode(address.getAdCode());
StreetNumber streetNumber = address.getStreetNumber();
if (streetNumber != null) {
LatLonPoint point = streetNumber.getLatLonPoint();
if (point != null) {
locationDO.setLatitude(String.valueOf(point.getLatitude()));
locationDO.setLongitude(String.valueOf(point.getLongitude()));
}
locationDO.setStreet(streetNumber.getStreet());
locationDO.setNumber(streetNumber.getNumber());
}
return locationDO;
}
/**
* 和iOS统一返回格式
*
* @param address address
* @return LocationDO
*/
public static LocationDO convert2Location(GeocodeAddress address) {
LocationDO locationDO = new LocationDO();
locationDO.setFormattedAddress(address.getFormatAddress());
locationDO.setCountry(address.getTownship());
locationDO.setProvince(address.getProvince());
locationDO.setCity(address.getCity());
// android这里没有返回citycode,但是ios有返回,这里可能导致不一样
locationDO.setAdCode(address.getAdcode());
LatLonPoint point = address.getLatLonPoint();
if (point != null) {
locationDO.setLatitude(String.valueOf(point.getLatitude()));
locationDO.setLongitude(String.valueOf(point.getLongitude()));
}
return locationDO;
}
public static Boolean isStringBlank(String str) {
if (str == null || str.length() == 0 || str.trim().length() == 0) {
return true;
}
return false;
}
public static void navigation(Context mContext,
String sname,
double slat,
double slon,
String dname,
double dlat,
double dlon){
if(!isMapInstall(mContext)){
Toast.makeText(mContext,"请下载安装高德地图",Toast.LENGTH_SHORT).show();
return;
}
String dat = "androidamap://route?sourceApplication="+mContext.getPackageName()+"&slat="+slat+"&slon="+slon+"&sname="+sname+"&dlat="+dlat+"&dlon="+dlon+"&dname="+dname+"&dev=0&t=2";
Intent intent = new Intent();
intent.setAction("android.intent.action.VIEW");
intent.addCategory("android.intent.category.DEFAULT");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setData(Uri.parse(dat));
mContext.startActivity(intent);
}
public static boolean isMapInstall(Context mContext){
try {
ApplicationInfo info = mContext.getPackageManager().getApplicationInfo("com.autonavi.minimap", PackageManager.GET_UNINSTALLED_PACKAGES);
if(info != null){
return true;
}
}catch (Exception e){
e.printStackTrace();
}
return false;
}
}
package io.terminus.rnamap.model;
/**
* Created by wenboli on 17/7/12.
*/
import com.amap.api.services.district.DistrictItem;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.WritableArray;
import com.facebook.react.bridge.WritableMap;
import java.util.ArrayList;
import java.util.List;
public class DistrictResultDO implements WritableObject {
private String latitude;
private String longitude;
private String adcode;
public void setLatitude(String latitude) {
this.latitude = latitude;
}
public String getLatitude() {
return latitude;
}
public void setLongitude(String longitude) {
this.longitude = longitude;
}
public String getLongitude() {
return longitude;
}
public void setAdcode(String adcode) {
this.adcode = adcode;
}
public String getAdcode() {
return adcode;
}
public DistrictResultDO(DistrictItem districtItem) {
latitude = String.valueOf(districtItem.getCenter().getLatitude());
longitude = String.valueOf(districtItem.getCenter().getLongitude()) ;
adcode = districtItem.getAdcode();
}
public WritableMap writableMap() {
WritableMap writableMap = Arguments.createMap();
writableMap.putString("adCode", adcode);
writableMap.putString("latitude", latitude);
writableMap.putString("longitude", longitude);
return writableMap;
}
<