├── .eslintrc.json ├── .gitignore ├── .gitmodules ├── .npmignore ├── LICENSE ├── README.md ├── RELEASENOTES.md ├── android ├── .gitignore ├── README.md ├── android_dev.sh ├── patch │ ├── config.xml.patch │ └── project.patch └── plugin │ ├── .gitignore │ ├── bintray-build.gradle │ ├── build.gradle │ ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ ├── proguard-rules.pro │ ├── src │ └── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ └── com │ │ │ └── taobao │ │ │ └── weex │ │ │ └── amap │ │ │ ├── component │ │ │ ├── AbstractMapWidgetComponent.java │ │ │ ├── AbstractMapWidgetContainer.java │ │ │ ├── WXMapCircleComponent.java │ │ │ ├── WXMapInfoWindowComponent.java │ │ │ ├── WXMapMarkerComponent.java │ │ │ ├── WXMapPolyLineComponent.java │ │ │ ├── WXMapPolygonComponent.java │ │ │ └── WXMapViewComponent.java │ │ │ ├── module │ │ │ └── WXMapModule.java │ │ │ └── util │ │ │ ├── Constant.java │ │ │ └── GifDecoder.java │ │ └── res │ │ ├── drawable │ │ └── infowindow_marker_icon.png │ │ └── values │ │ └── strings.xml │ └── tb-build.gradle ├── demos ├── include │ ├── example-list-item.we │ ├── example-list.we │ ├── info-window.we │ ├── navbar.we │ └── page.style.css ├── index.we └── pages │ ├── circle.we │ ├── get-distance.we │ ├── info-window.we │ ├── polygon-contains-marker.we │ ├── polygon.we │ ├── polyline.we │ └── pressure-test.we ├── doc ├── 3rd-needs.md ├── article.md ├── es │ ├── README.md │ └── index.md └── zh │ ├── README.md │ └── index.md ├── ios ├── .gitignore ├── LICENSE ├── Podfile ├── README.md ├── WeexDemo.xcodeproj │ ├── project.pbxproj │ └── xcshareddata │ │ └── xcschemes │ │ ├── WeexDemo.xcscheme │ │ └── WeexUITestDemo.xcscheme ├── WeexDemo │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ ├── Contents.json │ │ │ ├── Icon-29.png │ │ │ ├── Icon-29@2x-1.png │ │ │ ├── Icon-29@2x.png │ │ │ ├── Icon-29@3x.png │ │ │ ├── Icon-40.png │ │ │ ├── Icon-40@2x-1.png │ │ │ ├── Icon-40@2x.png │ │ │ ├── Icon-40@3x.png │ │ │ ├── Icon-60@2x.png │ │ │ ├── Icon-60@3x.png │ │ │ ├── Icon-76.png │ │ │ ├── Icon-76@2x.png │ │ │ └── Icon-83.5@2x.png │ │ ├── Contents.json │ │ ├── LaunchImage.launchimage │ │ │ ├── Contents.json │ │ │ ├── Default-4.7@2x.png │ │ │ ├── Default-568h@2x-1.png │ │ │ ├── Default-568h@2x.png │ │ │ ├── Default.png │ │ │ ├── Default@2x-1.png │ │ │ ├── Default@2x.png │ │ │ ├── Default@3x-1.png │ │ │ └── Default@3x.png │ │ ├── back.imageset │ │ │ ├── Contents.json │ │ │ ├── back.png │ │ │ ├── back@2x.png │ │ │ └── back@3x.png │ │ ├── reload.imageset │ │ │ ├── Contents.json │ │ │ ├── reload.png │ │ │ ├── reload@2x.png │ │ │ └── reload@3x.png │ │ └── scan.imageset │ │ │ ├── Contents.json │ │ │ ├── scan.png │ │ │ ├── scan@2x.png │ │ │ └── scan@3x.png │ ├── DemoDefine.h │ ├── Images.xcassets │ │ └── Brand Assets.launchimage │ │ │ └── Contents.json │ ├── WeexConfig │ │ ├── WeexBundleUrlLoder.h │ │ ├── WeexBundleUrlLoder.m │ │ ├── WeexConfigParser.h │ │ ├── WeexConfigParser.m │ │ ├── WeexSDKManager.h │ │ └── WeexSDKManager.m │ ├── WeexDemo-Info.plist │ ├── WeexScanner │ │ ├── UIViewController+WXDemoNaviBar.h │ │ ├── UIViewController+WXDemoNaviBar.m │ │ ├── WXDemoViewController.h │ │ ├── WXDemoViewController.m │ │ ├── WXScannerVC.h │ │ └── WXScannerVC.m │ ├── config.xml │ ├── main.m │ └── weex-icon.png ├── WeexDemoTests │ ├── Info.plist │ └── WeexDemoTests.m ├── WeexUITestDemo-Info.plist ├── WeexUITestDemoUITests │ ├── Info.plist │ └── WeexUITestDemoUITests.m ├── Weexplugin │ ├── Podfile │ ├── Weexplugin.podspec │ ├── Weexplugin.xcodeproj │ │ ├── project.pbxproj │ │ └── project.xcworkspace │ │ │ └── contents.xcworkspacedata │ ├── Weexplugin │ │ ├── Plugins │ │ │ ├── weex-adapter-image │ │ │ │ ├── WXImgLoaderImpl.h │ │ │ │ └── WXImgLoaderImpl.m │ │ │ └── weex-plugin-amap │ │ │ │ ├── NSArray+WXMap.h │ │ │ │ ├── NSArray+WXMap.m │ │ │ │ ├── NSDictionary+WXMap.h │ │ │ │ ├── NSDictionary+WXMap.m │ │ │ │ ├── NSString+WXMap.h │ │ │ │ ├── NSString+WXMap.m │ │ │ │ ├── WXConvert+AMapKit.h │ │ │ │ ├── WXConvert+AMapKit.m │ │ │ │ ├── WXMapCircleComponent.h │ │ │ │ ├── WXMapCircleComponent.m │ │ │ │ ├── WXMapInfoWindow.h │ │ │ │ ├── WXMapInfoWindow.m │ │ │ │ ├── WXMapInfoWindowComponent.h │ │ │ │ ├── WXMapInfoWindowComponent.m │ │ │ │ ├── WXMapPolygonComponent.h │ │ │ │ ├── WXMapPolygonComponent.m │ │ │ │ ├── WXMapPolylineComponent.h │ │ │ │ ├── WXMapPolylineComponent.m │ │ │ │ ├── WXMapRenderer.h │ │ │ │ ├── WXMapRenderer.m │ │ │ │ ├── WXMapViewComponent.h │ │ │ │ ├── WXMapViewComponent.m │ │ │ │ ├── WXMapViewMarkerComponent.h │ │ │ │ ├── WXMapViewMarkerComponent.m │ │ │ │ ├── WXMapViewModule.h │ │ │ │ └── WXMapViewModule.m │ │ ├── Resources │ │ │ ├── WeexpluginConfig.xml │ │ │ ├── greenPin.png │ │ │ ├── greenPin@2x.png │ │ │ └── greenPin@3x.png │ │ ├── Source │ │ │ └── WeexPlugin │ │ │ │ ├── WeexPluginConfigParser.h │ │ │ │ ├── WeexPluginConfigParser.m │ │ │ │ ├── WeexPluginLoader.h │ │ │ │ ├── WeexPluginLoader.m │ │ │ │ ├── WeexPluginManager.h │ │ │ │ └── WeexPluginManager.m │ │ ├── Weexplugin-Info.plist │ │ └── Weexplugin.h │ ├── WeexpluginTests │ │ ├── Info.plist │ │ └── WeexpluginTests.m │ ├── frameworks.json │ ├── ios.json │ └── pods.json ├── bundlejs │ ├── include │ │ ├── example-list-item.js │ │ ├── example-list.js │ │ ├── info-window.js │ │ └── navbar.js │ ├── index.js │ ├── pages │ │ ├── center.js │ │ ├── circle.js │ │ ├── geolocation.js │ │ ├── get-distance.js │ │ ├── info-window.js │ │ ├── init.js │ │ ├── marker.js │ │ ├── polygon-contains-marker.js │ │ ├── polygon.js │ │ ├── polyline.js │ │ ├── pressure-test.js │ │ ├── search.js │ │ └── zoom.js │ └── vue │ │ ├── include │ │ └── panel.vue.js │ │ └── input.vue.js ├── weex.png └── weex@2x.png ├── js ├── demo.vue ├── package.json └── weex-amap.vue ├── karma.conf.js ├── package.json ├── plugin.xml └── web ├── components ├── amap-circle.js ├── amap-info-window.js ├── amap-marker.js ├── amap-polygon.js ├── amap-polyline.js └── amap.js ├── index.js ├── module └── amap.js ├── package.json ├── service ├── components.js ├── map-loader.js ├── map-manager.js ├── marker.js └── vendor.js └── vue-amap ├── index.js └── index.js.map /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "airbnb-base", 3 | "plugins": [ 4 | "import" 5 | ], 6 | "globals":{ 7 | "AMap": true 8 | }, 9 | "env": { 10 | "browser": true 11 | }, 12 | "rules": { 13 | "func-names": 0, 14 | "comma-dangle": 0, 15 | "object-shorthand": 0, 16 | "no-underscore-dangle": 0, 17 | "no-plusplus": 0, 18 | "consistent-return": 0, 19 | "prefer-template": 0 20 | } 21 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the ART/Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | out/ 15 | 16 | # Gradle files 17 | .gradle/ 18 | build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | 29 | # Android Studio Navigation editor temp files 30 | .navigation/ 31 | 32 | # Android Studio captures folder 33 | captures/ 34 | 35 | # Intellij 36 | *.iml 37 | .idea/workspace.xml 38 | 39 | # Keystore files 40 | *.jks 41 | .DS_Store 42 | 43 | node_modules 44 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "android/dev"] 2 | path = android/dev 3 | url = https://github.com/littleseven/weex-app-template 4 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | noude_moudles 2 | android/patch 3 | android/dev 4 | android_dev.sh 5 | android/plugin/build 6 | android/gradle 7 | android/gradlew 8 | android/gradlew.bat 9 | android/local.properties 10 | *.iml -------------------------------------------------------------------------------- /RELEASENOTES.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weex-plugins/Amap-for-Apache-Weex/b6c3f5d615e9979527dc22f68e3ed7898dc27b94/RELEASENOTES.md -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .DS_Store 3 | build/ 4 | -------------------------------------------------------------------------------- /android/README.md: -------------------------------------------------------------------------------- 1 | # 如何开发 2 | 如果想要开发amap,首先要准备好开发环境。 如果一开始clone仓库时缺少 --recursive 选项 3 | 4 | $ git clone --recursive https://github.com/weex-plugins/weex-amap.git 5 | 6 | 则submodule并未同步下来,请在android目录下运行 7 | 8 | $ git submodule init 9 | 10 | $ git submodule update 11 | 12 | 接下来,执行如下脚本,以patch的方式设置好工程依赖 13 | 14 | $ sh android_dev.sh 15 | 16 | 该命令行执行完毕后进入dev目录,使用Android Studio打开settings.gradle导入android工程。导入完毕后可以看到主要有以下几个工程。 17 | 18 |  19 | 20 | 其中plugin即为开发的插件所在的工程,你可以在这里进行插件开发。如果创建新的module或者component类,则需要在weexplugin的src/main/res/xml/config.xml中进行配置。 21 | 22 | ## 插件开发的两个基本部分 23 | 24 | ### 组件或者模块开发 25 | 这里是纯功能的开发,与普通的weex组件或者模块扩展无异,测试时需要在weexplugin的src/main/res/xml/config.xml中正确的配置才能成功加载。 26 | 27 | ### 配置文件 28 | 这里主要是修改插件根目录下的plugin.xml和.npmignore。其中 29 | * plugin.xml 该文件主要用来设置插件安装过程中要copy的代码、依赖的库文件及权限等。 30 | * .npmignore 该文件主要是用来配置哪些文件需要忽略不需要打包到插件中,如dev目录下的所有内容,和plugin下的build目录等。 31 | 32 | # 如何发布 33 | 如果已经完成了插件开发,则在插件根目录下执行 `weexpack plugin publish` 命令即可完成发布。 34 | -------------------------------------------------------------------------------- /android/android_dev.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | cd dev 3 | git apply ../patch/project.patch 4 | git apply ../patch/config.xml.patch 5 | -------------------------------------------------------------------------------- /android/patch/config.xml.patch: -------------------------------------------------------------------------------- 1 | diff --git a/weexplugin/src/main/res/xml/config.xml b/weexplugin/src/main/res/xml/config.xml 2 | index 9f91ca2..a2d3157 100644 3 | --- a/weexplugin/src/main/res/xml/config.xml 4 | +++ b/weexplugin/src/main/res/xml/config.xml 5 | @@ -18,4 +18,19 @@ 6 | 7 | 8 | 9 | + 10 | + 11 | + 12 | + 13 | + 14 | + 15 | + 16 | + 17 | + 18 | + 19 | + 20 | + 21 | + 22 | + 23 | + 24 | 25 | -------------------------------------------------------------------------------- /android/patch/project.patch: -------------------------------------------------------------------------------- 1 | diff --git a/app/build.gradle b/app/build.gradle 2 | index b902bfe..555d003 100755 3 | --- a/app/build.gradle 4 | +++ b/app/build.gradle 5 | @@ -85,7 +85,7 @@ dependencies { 6 | compile 'com.taobao.android:weex_sdk:0.10.1.1' 7 | compile project(':appframework') 8 | compile project(':weexplugin') 9 | -// compile project(':plugin') 10 | + compile project(':plugin') 11 | compile 'com.google.code.findbugs:jsr305:2.0.1' 12 | compile 'com.squareup.okhttp:okhttp:2.3.0' 13 | compile 'com.squareup.okhttp:okhttp-ws:2.3.0' 14 | diff --git a/settings.gradle b/settings.gradle 15 | index 827f265..d91d926 100755 16 | --- a/settings.gradle 17 | +++ b/settings.gradle 18 | @@ -1,8 +1,8 @@ 19 | include ':app' 20 | include ':weexplugin' 21 | include ":appframework" 22 | -//include ":plugin" 23 | -//project(":plugin").projectDir=new File("../plugin") 24 | +include ":plugin" 25 | +project(":plugin").projectDir=new File("../plugin") 26 | 27 | //include ":inspector" 28 | //project(":inspector").projectDir=new File("../inspector") 29 | -------------------------------------------------------------------------------- /android/plugin/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | build 3 | .idea/ -------------------------------------------------------------------------------- /android/plugin/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | // maven { url "http://mvnrepo.alibaba-inc.com/mvn/repository" } 4 | // maven { url "http://mvnrepo.alibaba-inc.com/mvn/snapshots" } 5 | mavenCentral() 6 | jcenter() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:2.1.2' 10 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0' 11 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1' 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | maven { url 'http://mvnrepo.alibaba-inc.com/mvn/repository' } 18 | mavenCentral() 19 | jcenter() 20 | } 21 | } 22 | 23 | apply plugin: 'com.android.library' 24 | apply plugin: 'com.jfrog.bintray' 25 | apply plugin: 'com.github.dcendents.android-maven' 26 | 27 | android { 28 | compileSdkVersion 23 29 | buildToolsVersion "23.0.2" 30 | 31 | defaultConfig { 32 | minSdkVersion 14 33 | targetSdkVersion 23 34 | versionCode 1 35 | versionName "1.0" 36 | 37 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 38 | 39 | } 40 | buildTypes { 41 | release { 42 | minifyEnabled false 43 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 44 | } 45 | } 46 | compileOptions { 47 | sourceCompatibility JavaVersion.VERSION_1_7 48 | targetCompatibility JavaVersion.VERSION_1_7 49 | } 50 | } 51 | 52 | dependencies { 53 | compile fileTree(include: ['*.jar'], dir: 'libs') 54 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 55 | exclude group: 'com.android.support', module: 'support-annotations' 56 | }) 57 | compile 'com.android.support:appcompat-v7:23.1.1' 58 | provided 'com.taobao.android:weex_sdk:0.10.0' 59 | provided 'com.amap.api:3dmap:latest.integration' 60 | provided 'com.amap.api:location:latest.integration' 61 | //provided 'com.taobao.android:dynamicimport:1.0.4.18' 62 | // provided 'com.amap.api:location:3.3.0' 63 | provided 'org.weex.plugin:processor:1.0.2' 64 | } 65 | -------------------------------------------------------------------------------- /android/plugin/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weex-plugins/Amap-for-Apache-Weex/b6c3f5d615e9979527dc22f68e3ed7898dc27b94/android/plugin/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /android/plugin/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 28 10:00:20 PST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip 7 | -------------------------------------------------------------------------------- /android/plugin/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /android/plugin/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/aoxiao/Develop/android-sdk-macosx/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /android/plugin/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /android/plugin/src/main/java/com/taobao/weex/amap/component/AbstractMapWidgetComponent.java: -------------------------------------------------------------------------------- 1 | package com.taobao.weex.amap.component; 2 | 3 | import android.view.View; 4 | 5 | import com.amap.api.maps.TextureMapView; 6 | import com.taobao.weex.WXSDKInstance; 7 | import com.taobao.weex.dom.WXDomObject; 8 | import com.taobao.weex.ui.component.WXComponent; 9 | import com.taobao.weex.ui.component.WXVContainer; 10 | import com.taobao.weex.utils.WXLogUtils; 11 | 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | import java.util.concurrent.atomic.AtomicBoolean; 15 | 16 | /** 17 | * Created by moxun on 17/5/17. 18 | */ 19 | 20 | public abstract class AbstractMapWidgetComponent extends WXComponent { 21 | 22 | protected static final String TAG = "WXMapViewComponent"; 23 | private List mPaddingWidgetTasks = new ArrayList<>(); 24 | private AtomicBoolean mIsMapLoaded = new AtomicBoolean(false); 25 | private Widget mWidget; 26 | 27 | public AbstractMapWidgetComponent(WXSDKInstance instance, WXDomObject dom, WXVContainer parent) { 28 | super(instance, dom, parent); 29 | } 30 | 31 | protected void postMapOperationTask(WXMapViewComponent parent, final WXMapViewComponent.MapOperationTask task) { 32 | if (parent != null) { 33 | WXMapViewComponent.MapOperationTask wrapper = new WXMapViewComponent.MapOperationTask() { 34 | @Override 35 | public void execute(TextureMapView mapView) { 36 | try { 37 | setMapLoaded(true); 38 | task.execute(mapView); 39 | } catch (Throwable t) { 40 | WXLogUtils.w(TAG, t); 41 | } 42 | } 43 | }; 44 | parent.postTask(wrapper); 45 | } 46 | } 47 | 48 | protected void setMapLoaded(boolean loaded) { 49 | mIsMapLoaded.set(loaded); 50 | } 51 | 52 | protected void execPaddingWidgetTasks() { 53 | for (Runnable task : mPaddingWidgetTasks) { 54 | task.run(); 55 | WXLogUtils.d(TAG, "Exec padding widget task " + task.toString()); 56 | } 57 | mPaddingWidgetTasks.clear(); 58 | } 59 | 60 | protected void setWidget(Widget widget) { 61 | mWidget = widget; 62 | if (mWidget != null) { 63 | execPaddingWidgetTasks(); 64 | } 65 | } 66 | 67 | protected void execAfterWidgetReady(final String friendlyName, final Runnable task) { 68 | Runnable wrapper = new Runnable() { 69 | @Override 70 | public void run() { 71 | try { 72 | task.run(); 73 | } catch (Throwable t) { 74 | WXLogUtils.w(TAG, t); 75 | } 76 | } 77 | 78 | @Override 79 | public String toString() { 80 | return friendlyName; 81 | } 82 | }; 83 | 84 | if (mWidget != null) { 85 | WXLogUtils.d(TAG, "Widget is ready, execute task " + friendlyName + " immediately"); 86 | wrapper.run(); 87 | } else { 88 | WXLogUtils.d(TAG, "Widget is not ready, cache task " + friendlyName); 89 | mPaddingWidgetTasks.add(wrapper); 90 | } 91 | } 92 | 93 | protected Widget getWidget() { 94 | if (mWidget == null) { 95 | WXLogUtils.w(TAG, new Throwable("Widget is null")); 96 | } 97 | return mWidget; 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /android/plugin/src/main/java/com/taobao/weex/amap/component/AbstractMapWidgetContainer.java: -------------------------------------------------------------------------------- 1 | package com.taobao.weex.amap.component; 2 | 3 | import com.amap.api.maps.TextureMapView; 4 | import com.taobao.weex.WXSDKInstance; 5 | import com.taobao.weex.dom.WXDomObject; 6 | import com.taobao.weex.ui.component.WXVContainer; 7 | import com.taobao.weex.ui.view.WXFrameLayout; 8 | import com.taobao.weex.utils.WXLogUtils; 9 | 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | import java.util.concurrent.atomic.AtomicBoolean; 13 | 14 | /** 15 | * Created by moxun on 2017/5/31. 16 | */ 17 | 18 | public class AbstractMapWidgetContainer extends WXVContainer { 19 | protected static final String TAG = "WXMapViewComponent"; 20 | private List mPaddingWidgetTasks = new ArrayList<>(); 21 | private AtomicBoolean mIsMapLoaded = new AtomicBoolean(false); 22 | private Widget mWidget; 23 | 24 | public AbstractMapWidgetContainer(WXSDKInstance instance, WXDomObject dom, WXVContainer parent, String instanceId, boolean isLazy) { 25 | super(instance, dom, parent, instanceId, isLazy); 26 | } 27 | 28 | public AbstractMapWidgetContainer(WXSDKInstance instance, WXDomObject node, WXVContainer parent) { 29 | super(instance, node, parent); 30 | } 31 | 32 | public AbstractMapWidgetContainer(WXSDKInstance instance, WXDomObject node, WXVContainer parent, boolean lazy) { 33 | super(instance, node, parent, lazy); 34 | } 35 | 36 | protected void postMapOperationTask(WXMapViewComponent parent, final WXMapViewComponent.MapOperationTask task) { 37 | if (parent != null) { 38 | WXMapViewComponent.MapOperationTask wrapper = new WXMapViewComponent.MapOperationTask() { 39 | @Override 40 | public void execute(TextureMapView mapView) { 41 | try { 42 | setMapLoaded(true); 43 | task.execute(mapView); 44 | } catch (Throwable t) { 45 | WXLogUtils.w(TAG, t); 46 | } 47 | } 48 | }; 49 | parent.postTask(wrapper); 50 | } 51 | } 52 | 53 | protected void setMapLoaded(boolean loaded) { 54 | mIsMapLoaded.set(loaded); 55 | } 56 | 57 | protected void execPaddingWidgetTasks() { 58 | for (Runnable task : mPaddingWidgetTasks) { 59 | task.run(); 60 | WXLogUtils.d(TAG, "Exec padding widget task " + task.toString()); 61 | } 62 | mPaddingWidgetTasks.clear(); 63 | } 64 | 65 | protected void setWidget(Widget widget) { 66 | mWidget = widget; 67 | if (mWidget != null) { 68 | execPaddingWidgetTasks(); 69 | } else { 70 | WXLogUtils.w(TAG, "Widget is null when call setWidget"); 71 | } 72 | } 73 | 74 | protected void execAfterWidgetReady(final String friendlyName, final Runnable task) { 75 | Runnable wrapper = new Runnable() { 76 | @Override 77 | public void run() { 78 | try { 79 | task.run(); 80 | } catch (Throwable t) { 81 | WXLogUtils.w(TAG, t); 82 | } 83 | } 84 | 85 | @Override 86 | public String toString() { 87 | return friendlyName; 88 | } 89 | }; 90 | 91 | if (mWidget != null) { 92 | WXLogUtils.d(TAG, "Widget is ready, execute task " + friendlyName + " immediately"); 93 | wrapper.run(); 94 | } else { 95 | WXLogUtils.d(TAG, "Widget is not ready, cache task " + friendlyName); 96 | mPaddingWidgetTasks.add(wrapper); 97 | } 98 | } 99 | 100 | protected Widget getWidget() { 101 | if (mWidget == null) { 102 | WXLogUtils.w(TAG, new Throwable("Widget is null")); 103 | } 104 | return mWidget; 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /android/plugin/src/main/java/com/taobao/weex/amap/component/WXMapCircleComponent.java: -------------------------------------------------------------------------------- 1 | package com.taobao.weex.amap.component; 2 | 3 | import android.content.Context; 4 | import android.graphics.Color; 5 | import android.support.annotation.NonNull; 6 | import android.view.View; 7 | import android.view.ViewStub; 8 | 9 | import com.alibaba.weex.plugin.annotation.WeexComponent; 10 | import com.amap.api.maps.TextureMapView; 11 | import com.amap.api.maps.model.Circle; 12 | import com.amap.api.maps.model.CircleOptions; 13 | import com.amap.api.maps.model.LatLng; 14 | import com.taobao.weex.WXSDKInstance; 15 | import com.taobao.weex.amap.util.Constant; 16 | import com.taobao.weex.dom.WXDomObject; 17 | import com.taobao.weex.ui.component.WXComponentProp; 18 | import com.taobao.weex.ui.component.WXVContainer; 19 | 20 | import org.json.JSONArray; 21 | import org.json.JSONException; 22 | 23 | /** 24 | * Created by budao on 2017/3/3. 25 | */ 26 | 27 | @WeexComponent(names = {"weex-amap-circle"}) 28 | public class WXMapCircleComponent extends AbstractMapWidgetComponent { 29 | private int mColor = 0; 30 | private int mFillColor = 0; 31 | private float mWeight = 1.0f; 32 | private float mRadius = 1.0f; 33 | 34 | public WXMapCircleComponent(WXSDKInstance instance, WXDomObject dom, WXVContainer parent) { 35 | super(instance, dom, parent); 36 | } 37 | 38 | @Override 39 | protected View initComponentHostView(@NonNull Context context) { 40 | if (getParent() != null && getParent() instanceof WXMapViewComponent) { 41 | initCircle(); 42 | } 43 | // FixMe: 只是为了绕过updateProperties中的逻辑检查 44 | return new ViewStub(context); 45 | } 46 | 47 | @WXComponentProp(name = Constant.Name.CENTER) 48 | public void setPath(final String param) { 49 | execAfterWidgetReady("setPath", new Runnable() { 50 | @Override 51 | public void run() { 52 | try { 53 | JSONArray center = new JSONArray(param); 54 | if (center.length() == 2) { 55 | Circle circle = getWidget(); 56 | if (circle != null) { 57 | circle.setCenter(new LatLng(center.getDouble(1), center.getDouble(0))); 58 | } 59 | } 60 | } catch (JSONException e) { 61 | e.printStackTrace(); 62 | } 63 | } 64 | }); 65 | } 66 | 67 | @WXComponentProp(name = Constant.Name.STROKE_COLOR) 68 | public void setStrokeColor(String param) { 69 | mColor = Color.parseColor(param); 70 | execAfterWidgetReady("setStrokeColor", new Runnable() { 71 | @Override 72 | public void run() { 73 | Circle circle = getWidget(); 74 | if (circle != null) { 75 | circle.setStrokeColor(mColor); 76 | } 77 | } 78 | }); 79 | } 80 | 81 | @WXComponentProp(name = Constant.Name.FILL_COLOR) 82 | public void setFillColor(String param) { 83 | mFillColor = Color.parseColor(param); 84 | execAfterWidgetReady("setFillColor", new Runnable() { 85 | @Override 86 | public void run() { 87 | Circle circle = getWidget(); 88 | if (circle != null) { 89 | circle.setFillColor(mFillColor); 90 | } 91 | } 92 | }); 93 | } 94 | 95 | @WXComponentProp(name = Constant.Name.STROKE_WIDTH) 96 | public void setStrokeWeight(float param) { 97 | mWeight = param; 98 | execAfterWidgetReady("setStrokeWeight", new Runnable() { 99 | @Override 100 | public void run() { 101 | Circle circle = getWidget(); 102 | if (circle != null) { 103 | circle.setStrokeWidth(mWeight); 104 | } 105 | } 106 | }); 107 | } 108 | 109 | @WXComponentProp(name = Constant.Name.RADIUS) 110 | public void setRadius(float param) { 111 | mRadius = param; 112 | execAfterWidgetReady("setRadius", new Runnable() { 113 | @Override 114 | public void run() { 115 | Circle circle = getWidget(); 116 | if (circle != null) { 117 | circle.setRadius(mRadius); 118 | } 119 | } 120 | }); 121 | } 122 | 123 | private void initCircle() { 124 | postMapOperationTask((WXMapViewComponent) getParent(), new WXMapViewComponent.MapOperationTask() { 125 | @Override 126 | public void execute(TextureMapView mapView) { 127 | CircleOptions circleOptions = new CircleOptions(); 128 | circleOptions.strokeColor(mColor); 129 | circleOptions.strokeWidth(mWeight); 130 | circleOptions.radius(mRadius); 131 | circleOptions.fillColor(mFillColor); 132 | setWidget(mapView.getMap().addCircle(circleOptions)); 133 | } 134 | }); 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /android/plugin/src/main/java/com/taobao/weex/amap/component/WXMapPolyLineComponent.java: -------------------------------------------------------------------------------- 1 | package com.taobao.weex.amap.component; 2 | 3 | import android.content.Context; 4 | import android.graphics.Color; 5 | import android.support.annotation.NonNull; 6 | import android.view.View; 7 | import android.view.ViewStub; 8 | 9 | import com.alibaba.weex.plugin.annotation.WeexComponent; 10 | import com.amap.api.maps.TextureMapView; 11 | import com.amap.api.maps.model.LatLng; 12 | import com.amap.api.maps.model.Polyline; 13 | import com.amap.api.maps.model.PolylineOptions; 14 | import com.taobao.weex.WXSDKInstance; 15 | import com.taobao.weex.amap.util.Constant; 16 | import com.taobao.weex.dom.WXDomObject; 17 | import com.taobao.weex.ui.component.WXComponentProp; 18 | import com.taobao.weex.ui.component.WXVContainer; 19 | 20 | import org.json.JSONArray; 21 | import org.json.JSONException; 22 | 23 | import java.util.ArrayList; 24 | 25 | /** 26 | * Created by budao on 2017/3/3. 27 | */ 28 | @WeexComponent(names = {"weex-amap-polyline"}) 29 | public class WXMapPolyLineComponent extends AbstractMapWidgetComponent { 30 | ArrayList mPosition = new ArrayList<>(); 31 | private int mColor = 0; 32 | private String mStyle; 33 | private float mWeight = 1.0f; 34 | 35 | public WXMapPolyLineComponent(WXSDKInstance instance, WXDomObject dom, WXVContainer parent) { 36 | super(instance, dom, parent); 37 | } 38 | 39 | @Override 40 | protected View initComponentHostView(@NonNull Context context) { 41 | if (getParent() != null && getParent() instanceof WXMapViewComponent) { 42 | initPolyLine(); 43 | } 44 | // FixMe: 只是为了绕过updateProperties中的逻辑检查 45 | return new ViewStub(context); 46 | } 47 | 48 | @WXComponentProp(name = Constant.Name.PATH) 49 | public void setPath(String param) { 50 | try { 51 | JSONArray path = new JSONArray(param); 52 | if (path != null) { 53 | for (int i = 0; i < path.length(); i++) { 54 | JSONArray position = path.getJSONArray(i); 55 | mPosition.add(new LatLng(position.getDouble(1), position.getDouble(0))); 56 | } 57 | } 58 | 59 | } catch (JSONException e) { 60 | e.printStackTrace(); 61 | } 62 | execAfterWidgetReady("setPath", new Runnable() { 63 | @Override 64 | public void run() { 65 | Polyline polyline = getWidget(); 66 | if (polyline != null) { 67 | polyline.setPoints(mPosition); 68 | } 69 | } 70 | }); 71 | } 72 | 73 | @WXComponentProp(name = Constant.Name.STROKE_COLOR) 74 | public void setStrokeColor(String param) { 75 | mColor = Color.parseColor(param); 76 | execAfterWidgetReady("setStrokeColor", new Runnable() { 77 | @Override 78 | public void run() { 79 | Polyline polyline = getWidget(); 80 | if (polyline != null) { 81 | polyline.setColor(mColor); 82 | } 83 | } 84 | }); 85 | } 86 | 87 | @WXComponentProp(name = Constant.Name.STROKE_WIDTH) 88 | public void setStrokeWeight(float param) { 89 | mWeight = param; 90 | execAfterWidgetReady("setStrokeWeight", new Runnable() { 91 | @Override 92 | public void run() { 93 | Polyline polyline = getWidget(); 94 | if (polyline != null) { 95 | polyline.setWidth(mWeight); 96 | } 97 | } 98 | }); 99 | } 100 | 101 | @WXComponentProp(name = Constant.Name.STROKE_STYLE) 102 | public void setStrokeStyle(String param) { 103 | mStyle = param; 104 | execAfterWidgetReady("setStrokeStyle", new Runnable() { 105 | @Override 106 | public void run() { 107 | Polyline polyline = getWidget(); 108 | if (polyline != null) { 109 | polyline.setDottedLine("dashed".equalsIgnoreCase(mStyle)); 110 | } 111 | } 112 | }); 113 | } 114 | 115 | private void initPolyLine() { 116 | if (getParent() != null && getParent() instanceof WXMapViewComponent) { 117 | postMapOperationTask((WXMapViewComponent) getParent(), new WXMapViewComponent.MapOperationTask() { 118 | @Override 119 | public void execute(TextureMapView mapView) { 120 | PolylineOptions polylineOptions = new PolylineOptions(); 121 | polylineOptions.setPoints(mPosition); 122 | polylineOptions.color(mColor); 123 | polylineOptions.width(mWeight); 124 | polylineOptions.setDottedLine("dashed".equalsIgnoreCase(mStyle)); 125 | setWidget(mapView.getMap().addPolyline(polylineOptions)); 126 | } 127 | }); 128 | } 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /android/plugin/src/main/java/com/taobao/weex/amap/component/WXMapPolygonComponent.java: -------------------------------------------------------------------------------- 1 | package com.taobao.weex.amap.component; 2 | 3 | import android.content.Context; 4 | import android.graphics.Color; 5 | import android.support.annotation.NonNull; 6 | import android.view.View; 7 | import android.view.ViewStub; 8 | 9 | import com.alibaba.weex.plugin.annotation.WeexComponent; 10 | import com.amap.api.maps.TextureMapView; 11 | import com.amap.api.maps.model.LatLng; 12 | import com.amap.api.maps.model.Polygon; 13 | import com.amap.api.maps.model.PolygonOptions; 14 | import com.taobao.weex.WXSDKInstance; 15 | import com.taobao.weex.amap.util.Constant; 16 | import com.taobao.weex.dom.WXDomObject; 17 | import com.taobao.weex.ui.component.WXComponentProp; 18 | import com.taobao.weex.ui.component.WXVContainer; 19 | 20 | import org.json.JSONArray; 21 | import org.json.JSONException; 22 | 23 | import java.util.ArrayList; 24 | 25 | /** 26 | * Created by budao on 2017/3/3. 27 | */ 28 | @WeexComponent(names = {"weex-amap-polygon"}) 29 | public class WXMapPolygonComponent extends AbstractMapWidgetComponent { 30 | ArrayList mPosition = new ArrayList<>(); 31 | private int mColor = 0; 32 | private int mFillColor = 0; 33 | private float mWidth = 1.0f; 34 | 35 | public WXMapPolygonComponent(WXSDKInstance instance, WXDomObject dom, WXVContainer parent) { 36 | super(instance, dom, parent); 37 | } 38 | 39 | @Override 40 | protected View initComponentHostView(@NonNull Context context) { 41 | if (getParent() != null && getParent() instanceof WXMapViewComponent) { 42 | initPolygon(); 43 | } 44 | // FixMe: 只是为了绕过updateProperties中的逻辑检查 45 | return new ViewStub(context); 46 | } 47 | 48 | @WXComponentProp(name = Constant.Name.PATH) 49 | public void setPath(String param) { 50 | try { 51 | JSONArray path = new JSONArray(param); 52 | if (path != null) { 53 | for (int i = 0; i < path.length(); i++) { 54 | JSONArray position = path.getJSONArray(i); 55 | mPosition.add(new LatLng(position.getDouble(1), position.getDouble(0))); 56 | } 57 | } 58 | 59 | } catch (JSONException e) { 60 | e.printStackTrace(); 61 | } 62 | execAfterWidgetReady("setPath", new Runnable() { 63 | @Override 64 | public void run() { 65 | Polygon polygon = getWidget(); 66 | if (polygon != null) { 67 | polygon.setPoints(mPosition); 68 | } 69 | } 70 | }); 71 | } 72 | 73 | @WXComponentProp(name = Constant.Name.STROKE_COLOR) 74 | public void setStrokeColor(String param) { 75 | mColor = Color.parseColor(param); 76 | execAfterWidgetReady("setStrokeColor", new Runnable() { 77 | @Override 78 | public void run() { 79 | Polygon polygon = getWidget(); 80 | if (polygon != null) { 81 | polygon.setStrokeColor(mColor); 82 | } 83 | } 84 | }); 85 | } 86 | 87 | @WXComponentProp(name = Constant.Name.FILL_COLOR) 88 | public void setFillColor(String param) { 89 | mFillColor = Color.parseColor(param); 90 | execAfterWidgetReady("setFillColor", new Runnable() { 91 | @Override 92 | public void run() { 93 | Polygon polygon = getWidget(); 94 | if (polygon != null) { 95 | polygon.setFillColor(mFillColor); 96 | } 97 | } 98 | }); 99 | } 100 | 101 | @WXComponentProp(name = Constant.Name.STROKE_WIDTH) 102 | public void setStrokeWidth(float param) { 103 | mWidth = param; 104 | execAfterWidgetReady("setStrokeWidth", new Runnable() { 105 | @Override 106 | public void run() { 107 | Polygon polygon = getWidget(); 108 | if (polygon != null) { 109 | polygon.setStrokeWidth(mWidth); 110 | } 111 | } 112 | }); 113 | } 114 | 115 | private void initPolygon() { 116 | postMapOperationTask((WXMapViewComponent) getParent(), new WXMapViewComponent.MapOperationTask() { 117 | @Override 118 | public void execute(TextureMapView mapView) { 119 | PolygonOptions polygonOptions = new PolygonOptions(); 120 | polygonOptions.addAll(mPosition); 121 | polygonOptions.strokeColor(mColor); 122 | polygonOptions.strokeWidth(mWidth); 123 | setWidget(mapView.getMap().addPolygon(polygonOptions)); 124 | } 125 | }); 126 | } 127 | 128 | public boolean contains(LatLng latLng) { 129 | Polygon polygon = getWidget(); 130 | return polygon != null && polygon.contains(latLng); 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /android/plugin/src/main/java/com/taobao/weex/amap/util/Constant.java: -------------------------------------------------------------------------------- 1 | package com.taobao.weex.amap.util; 2 | 3 | /** 4 | * Created by aoxiao on 2017/1/4. 5 | */ 6 | 7 | public class Constant { 8 | 9 | public interface Value { 10 | int SCROLLGESTURE = 0x1; 11 | int ZOOMGESTURE = 0x1 << 1; 12 | int TILTGESTURE = 0x1 << 2; 13 | int ROTATEGESTURE = 0x1 << 3; 14 | String RIGHT_CENTER = "center"; 15 | String RIGHT_BOTTOM = "bottom"; 16 | } 17 | 18 | public interface Name { 19 | 20 | // mapview 21 | String SCALECONTROL = "scale"; 22 | String ZOOM_ENABLE = "zoomEnable"; 23 | String ZOOM = "zoom"; 24 | String COMPASS = "compass"; 25 | String GEOLOCATION = "geolocation"; 26 | String GESTURE = "gesture"; 27 | String GESTURES = "gestures"; 28 | String INDOORSWITCH = "indoorswitch"; 29 | String CENTER = "center"; 30 | String KEYS = "sdkKey"; 31 | String ZOOM_POSITION = "zoomPosition"; 32 | String MY_LOCATION_ENABLED = "myLocationEnabled"; 33 | String SHOW_MY_LOCATION = "showMyLocation"; 34 | String CUSTOM_STYLE_PATH = "customStylePath"; 35 | String CUSTOM_ENABLED = "customEnabled"; 36 | 37 | // marker 38 | String MARKER = "marker"; 39 | String POSITION = "position"; 40 | String ICON = "icon"; 41 | String TITLE = "title"; 42 | String HIDE_CALL_OUT = "hideCallout"; 43 | 44 | // polyline 45 | String PATH = "path"; 46 | String STROKE_COLOR = "strokeColor"; 47 | String STROKE_WIDTH = "strokeWidth"; 48 | String STROKE_OPACITY = "strokeOpacity"; 49 | String STROKE_STYLE = "strokeStyle"; 50 | 51 | // circle 52 | String RADIUS = "radius"; 53 | String FILL_COLOR = "fillColor"; 54 | 55 | // offset 56 | String OFFSET = "offset"; 57 | String OPEN = "open"; 58 | } 59 | 60 | 61 | public static interface EVENT { 62 | String ZOOM_CHANGE = "zoomchange"; 63 | String DRAG_CHANGE = "dragend"; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /android/plugin/src/main/res/drawable/infowindow_marker_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weex-plugins/Amap-for-Apache-Weex/b6c3f5d615e9979527dc22f68e3ed7898dc27b94/android/plugin/src/main/res/drawable/infowindow_marker_icon.png -------------------------------------------------------------------------------- /android/plugin/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | amap_weex_plugin 3 | 4 | -------------------------------------------------------------------------------- /android/plugin/tb-build.gradle: -------------------------------------------------------------------------------- 1 | apply from: 'http://mirrors.taobao.net/mirror/gradle/android-parent.gradle' 2 | apply plugin: 'com.taobao.android.weex.plugin.gradle' 3 | group = 'com.taobao.android' 4 | version = '0.0.0.6-SNAPSHOT' 5 | 6 | description = """weex_amap""" 7 | 8 | try { 9 | if ('' != deployVersion) { 10 | version = deployVersion 11 | println "version: " + version 12 | } 13 | 14 | } catch (java.lang.Exception e) { 15 | 16 | } 17 | 18 | buildscript { 19 | repositories { 20 | maven { 21 | url "http://mvnrepo.alibaba-inc.com/mvn/repository" 22 | } 23 | } 24 | dependencies { 25 | classpath('com.taobao.android.tools.build:gradle:1.3.3.2') { 26 | exclude module: 'guava' 27 | } 28 | classpath("com.taobao.android:weexplugin-gradle-plugin:1+") 29 | classpath 'com.google.guava:guava:17.0' 30 | } 31 | } 32 | 33 | repositories { 34 | maven { url 'http://mvnrepo.alibaba-inc.com/mvn/repository' } 35 | mavenLocal() 36 | mavenCentral() 37 | } 38 | 39 | android { 40 | compileSdkVersion 23 41 | buildToolsVersion '23.0.2' 42 | 43 | defaultConfig { 44 | minSdkVersion 11 45 | targetSdkVersion 23 46 | versionCode 1 47 | versionName "1.0" 48 | consumerProguardFiles 'proguard-rules.pro' 49 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 50 | } 51 | 52 | sourceSets { 53 | main { 54 | java { 55 | srcDirs = ['src/main/java'] 56 | } 57 | resources.srcDirs = ['src/main/java'] 58 | manifest.srcFile projectDir.path+'/src/main/AndroidManifest.xml' 59 | res.srcDirs = ['src/main/res'] 60 | } 61 | } 62 | tBuildConfig { 63 | libraryType 'aar' 64 | } 65 | } 66 | 67 | dependencies { 68 | compile fileTree(include: ['*.jar'], dir: 'libs') 69 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 70 | exclude group: 'com.android.support', module: 'support-annotations' 71 | }) 72 | provided 'com.android.support:appcompat-v7:23.1.1' 73 | provided 'com.taobao.android:weex_sdk:0.10.0' 74 | // provided 'com.amap.api:map3d-native:4.1.3' 75 | // provided 'com.amap.api:map3d:4.1.3' 76 | provided 'com.taobao.android:amp3d_sdk:5.0.8.test@aar' 77 | provided 'com.amap.api.location:android_location:2.5.1' 78 | //provided 'com.taobao.android:dynamicimport:1.0.4.18' 79 | // provided 'com.amap.api:location:3.3.0' 80 | provided 'org.weex.plugin:processor:1.0.2' 81 | } 82 | 83 | publishing { 84 | publications { 85 | maven(MavenPublication) { 86 | // 需要自己定义产出artifact的路径,根据你的项目的产出进行配置 87 | artifact "${project.buildDir}/outputs/aar/${project.name}-release.aar" 88 | 89 | // 如果你要部署到maven仓库的artifatcId和project名称不同,需要在这里重载 90 | artifactId 'weex_amap' 91 | } 92 | 93 | } 94 | } 95 | 96 | //apply from: rootProject.file('release.gradle') 97 | 98 | android.libraryVariants.all { variant -> 99 | def name = variant.name.capitalize() 100 | 101 | // Ugly kludge to rename license files in the bundled commons-cli 102 | // dependency so that they do not appear to describe Stetho's license. 103 | // configurations.compile.each { 104 | // if (it.getName() == 'commons-cli-1.2.jar') { 105 | // def depJarPath = it.getPath() 106 | // task "tidyCommonsCli${name}"(type: Copy) { 107 | // from zipTree(depJarPath) 108 | // into "build/commons-cli-tidy-${name}" 109 | // rename 'LICENSE', 'commons-cli-LICENSE' 110 | // rename 'NOTICE', 'commons-cli-NOTICE' 111 | // } 112 | // } 113 | // } 114 | 115 | task "metainf${name}"(type: Copy) { 116 | from rootProject.file('LICENSE') 117 | into "build/metainf-${name}/META-INF" 118 | } 119 | 120 | task "fatjar${name}"(type: Jar, dependsOn: [ "jar${name}", "tidyCommonsCli${name}", "metainf${name}" ]) { 121 | classifier = 'fatjar' 122 | from variant.javaCompile.destinationDir 123 | from "build/commons-cli-tidy-${name}" 124 | from "build/metainf-${name}" 125 | } 126 | } -------------------------------------------------------------------------------- /demos/include/example-list-item.we: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | {{keyword}} 7 | {{desc}} 8 | 9 | 10 | 查看详情 11 | 12 | 13 | 14 | 15 | 16 | 17 | 73 | 74 | -------------------------------------------------------------------------------- /demos/include/example-list.we: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 79 | 80 | -------------------------------------------------------------------------------- /demos/include/info-window.we: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {{title}} 5 | {{location}} 6 | 7 | 8 | 9 | 36 | 37 | -------------------------------------------------------------------------------- /demos/include/navbar.we: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 返回 7 | 8 | {{title}} 9 | 10 | 11 | 12 | 54 | -------------------------------------------------------------------------------- /demos/include/page.style.css: -------------------------------------------------------------------------------- 1 | .container{ 2 | position: relative; 3 | flex:1; 4 | background-color: #fff; 5 | } 6 | .map{ 7 | flex: 1; 8 | position: relative; 9 | background-color: #fff; 10 | min-height: 800; 11 | border-bottom-width: 10; 12 | border-bottom-color: #fff; 13 | } 14 | .map-control{ 15 | padding-top: 20; 16 | min-height: 600; 17 | } 18 | .title{ 19 | margin-left: 20; 20 | padding-left: 20; 21 | padding-top: 10; 22 | padding-bottom: 10; 23 | font-size: 36px; 24 | border-left-width: 6; 25 | border-left-color: #0f89f5; 26 | color: #222; 27 | text-align: left; 28 | } 29 | .tips{ 30 | margin: 20; 31 | padding: 10; 32 | color:#666; 33 | font-size: 20px; 34 | } 35 | .btn{ 36 | margin: 20; 37 | padding: 20; 38 | background-color: #1ba1e2; 39 | border-radius: 5; 40 | color: #fff; 41 | text-align:center; 42 | cursor: pointer; 43 | font-size: 28px; 44 | } -------------------------------------------------------------------------------- /demos/index.we: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | WEEX-AMAP DEMOS 9 | 10 | 11 | 12 | 13 | 14 | 51 | 52 | 112 | -------------------------------------------------------------------------------- /demos/pages/circle.we: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Componenet: weex-amap-circle 9 | 可以在地图上绘制圆形 10 | 11 | 12 | 13 | 14 | 50 | 51 | -------------------------------------------------------------------------------- /demos/pages/get-distance.we: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Methods: getDistanceBetweenMarkers 10 | getDistanceBetweenMarkers,可以获取地图上两个坐标点的巨鹿 11 | Get Distance 12 | {{distance}} 13 | 14 | 15 | 16 | 17 | 70 | 71 | -------------------------------------------------------------------------------- /demos/pages/info-window.we: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | Component: weex-amap-info-window 16 | 在地图上显示自定义窗体 17 | 18 | 19 | 打开南站信息 20 | 关闭南站信息 21 | 22 | 23 | 打开故宫信息 24 | 关闭故宫信息 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 92 | 93 | -------------------------------------------------------------------------------- /demos/pages/polygon-contains-marker.we: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Method: polygonContainsMarker 11 | 判断多边形是不是包含某个点 12 | Test Marker1 13 | Test Marker2 14 | 15 | 16 | 17 | 18 | 71 | 72 | -------------------------------------------------------------------------------- /demos/pages/polygon.we: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Componenet: weex-amap-polygon 9 | weex-amap-polygon 可以在地图上绘制多边形 10 | 11 | 12 | 13 | 14 | 50 | 51 | -------------------------------------------------------------------------------- /demos/pages/polyline.we: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Component weex-amap-polyline 9 | 在地图上绘制折线 10 | 11 | 12 | 13 | 14 | 50 | 51 | -------------------------------------------------------------------------------- /doc/3rd-needs.md: -------------------------------------------------------------------------------- 1 | ## 三期需求api设计参考 2 | 3 | ### 折线组件 weex-amap-polyline 4 | 5 | 在地图上绘制折线 6 | 7 | | 属性 | 类型 | Demo | 描述 | 8 | | ------------- |:-------------:| -----:|----------:| 9 | | path | array | [[116.487, 40.00003],[113.487, 40.0002]...]| 折线的节点坐标数组 | 10 | | stroke-color | string | #000 | 线条颜色 | 11 | | stroke-width | number | 2 | 线条宽度 | 12 | | stroke-opacity | number | 0.5 | 线条透明度[0-1] 13 | | stroke-style | string | solid | 线条的样式 实线:solid,虚线:dashed 14 | 15 | #### code example 16 | 17 | ``` bash 18 | 19 | 20 | 33 | ``` 34 | 35 | 36 | ### 多边形组件 weex-amap-polygon 37 | 38 | 在地图上绘制多边形 39 | 40 | 41 | | 属性 | 类型 | Demo | 描述 | 42 | | ------------- |:-------------:| -----:|----------:| 43 | | path | array | [[116.487, 40.00003],[113.487, 40.0002]...]| 多边形轮廓线的节点坐标数组 | 44 | | fill-color | string | #000 | 多边形填充颜色 | 45 | | fill-opacity | string | #000 | 多边形填充透明度 | 46 | | stroke-color | string | #000 | 线条颜色 | 47 | | stroke-width | number | 2 | 线条宽度 | 48 | | stroke-opacity | number | 0.5 | 线条透明度[0-1] 49 | | stroke-style | string | solid | 线条的样式 实线:solid,虚线:dashed 50 | 51 | 52 | ### 圆形组件 weex-amap-circle 53 | 54 | 在地图上绘制圆形 55 | 56 | 57 | | 属性 | 类型 | Demo | 描述 | 58 | | ------------- |:-------------:| -----:|----------:| 59 | | center | array | [116.346, 40.234234]| 圆形位置 | 60 | | radius | number | 50 | 圆的半径 | 61 | | fill-color | string | #000 | 圆的填充颜色 | 62 | | fill-opacity | string | #000 | 圆的填充透明度 | 63 | | stroke-color | string | #000 | 圆的轮廓线条颜色 | 64 | | stroke-width | number | 2 | 圆的轮廓线条宽度 | 65 | | stroke-opacity | number | 0.5 | 圆的轮廓线条透明度[0-1] 66 | | stroke-style | string | solid | 圆的轮廓线条的样式 实线:solid,虚线:dashed 67 | 68 | 69 | #### 自定义信息窗体 weex-amap-info-window 70 | 71 | 在地图上显示自定义窗体 72 | 73 | | 属性 | 类型 | Demo | 描述 | 74 | | ------------- |:-------------:| -----:|----------:| 75 | | position | array | [[116.487, 40.00003]| 在地图上的位置 | 76 | | open | boolean | true | 是否在地图上打开 | 77 | | offset | array | 偏移 | 相对定位点坐标偏移 | 78 | | children | weex comonnet | This is a info window | 窗体的内容 | 79 | || 80 | 81 | *SDK限制,一个地图只允许显示一个infoWindow* 82 | 83 | 84 | ### Amap方法 getLineDistance 85 | 86 | 计算两个标记点的距离 87 | 88 | 该方法接收三个参数 进行计算比如: 89 | 90 | @param coor1 坐标1 91 | 92 | @param coor2 坐标2 93 | 94 | @param callback 计算完成后的回调 会返回一个计算出的具体距离,单位 米 95 | 96 | ``` js 97 | //... 98 | amap.getLineDistance(this.marker1.position, this.marker2.position, (res) => { 99 | if (res.result == 'success') { 100 | this.distance = '两点相距' + res.data + '米'; 101 | console.log(res.data.distance + '米'); 102 | } else { 103 | console.log('计算失败'); 104 | } 105 | }) 106 | ``` 107 | 108 | ### Amap 方法 polygonContainsMarker 109 | 110 | 判断几何形是否包含某个点 111 | 112 | 该方法接收两个参数,返回一个boolean值 113 | 114 | @param coor 点的坐标 115 | 116 | @param polygonRef 多边形的ref 117 | 118 | @param callbcak 计算完成后的回调 会返回一个运算的结果,其中data字段是个boolean,表示是否包含 119 | 120 | 121 | ``` 122 | amap.polygonContainsMarker([114.23423, 43.2222], this.$ref('polygon2017'), (res) => { 123 | if (res.result == 'success') { 124 | console.log(res.data ? '存在' : '不存在' ); 125 | } 126 | }) 127 | 128 | ``` 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | -------------------------------------------------------------------------------- /doc/es/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weex-plugins/Amap-for-Apache-Weex/b6c3f5d615e9979527dc22f68e3ed7898dc27b94/doc/es/README.md -------------------------------------------------------------------------------- /doc/es/index.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weex-plugins/Amap-for-Apache-Weex/b6c3f5d615e9979527dc22f68e3ed7898dc27b94/doc/es/index.md -------------------------------------------------------------------------------- /doc/zh/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weex-plugins/Amap-for-Apache-Weex/b6c3f5d615e9979527dc22f68e3ed7898dc27b94/doc/zh/README.md -------------------------------------------------------------------------------- /doc/zh/index.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weex-plugins/Amap-for-Apache-Weex/b6c3f5d615e9979527dc22f68e3ed7898dc27b94/doc/zh/index.md -------------------------------------------------------------------------------- /ios/.gitignore: -------------------------------------------------------------------------------- 1 | # Created by https://www.gitignore.io/api/objective-c 2 | 3 | ### Objective-C ### 4 | # Xcode 5 | # 6 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 7 | 8 | ## Build generated 9 | build/ 10 | _demo/ 11 | DerivedData 12 | 13 | ## Various settings 14 | *.pbxuser 15 | !default.pbxuser 16 | *.mode1v3 17 | !default.mode1v3 18 | *.mode2v3 19 | !default.mode2v3 20 | *.perspectivev3 21 | !default.perspectivev3 22 | xcuserdata 23 | 24 | ## Other 25 | *.xccheckout 26 | *.moved-aside 27 | *.xcuserstate 28 | *.xcscmblueprint 29 | 30 | ## Obj-C/Swift specific 31 | *.hmap 32 | *.ipa 33 | 34 | # CocoaPods 35 | # 36 | # We recommend against adding the Pods directory to your .gitignore. However 37 | # you should judge for yourself, the pros and cons are mentioned at: 38 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 39 | # 40 | Pods/ 41 | Podfile.lock 42 | 43 | # Carthage 44 | # 45 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 46 | # Carthage/Checkouts 47 | 48 | Carthage/Build 49 | 50 | # fastlane 51 | # 52 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 53 | # screenshots whenever they are needed. 54 | # For more information about the recommended setup visit: 55 | # https://github.com/fastlane/fastlane/blob/master/docs/Gitignore.md 56 | 57 | fastlane/report.xml 58 | fastlane/screenshots 59 | 60 | ### Objective-C Patch ### 61 | *.xcscmblueprint 62 | 63 | 64 | # Created by https://www.gitignore.io/api/node 65 | 66 | *.gcno 67 | 68 | -------------------------------------------------------------------------------- /ios/Podfile: -------------------------------------------------------------------------------- 1 | source 'git@github.com/CocoaPods/Specs.git' 2 | platform :ios, '7.0' 3 | inhibit_all_warnings! 4 | 5 | def common 6 | pod 'WeexSDK' 7 | pod 'Weexplugin', :path=>'./Weexplugin/' 8 | pod 'WXDevtool' 9 | pod 'SDWebImage', '3.7.5' 10 | pod 'SocketRocket', '0.4.2' 11 | pod 'ATSDK-Weex', '0.0.1' 12 | end 13 | 14 | target 'WeexDemo' do 15 | common 16 | end 17 | 18 | target 'WeexUITestDemo' do 19 | common 20 | end 21 | -------------------------------------------------------------------------------- /ios/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weex-plugins/Amap-for-Apache-Weex/b6c3f5d615e9979527dc22f68e3ed7898dc27b94/ios/README.md -------------------------------------------------------------------------------- /ios/WeexDemo.xcodeproj/xcshareddata/xcschemes/WeexDemo.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 31 | 32 | 34 | 40 | 41 | 42 | 44 | 50 | 51 | 52 | 53 | 54 | 60 | 61 | 62 | 63 | 64 | 65 | 75 | 77 | 83 | 84 | 85 | 86 | 87 | 88 | 94 | 96 | 102 | 103 | 104 | 105 | 107 | 108 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /ios/WeexDemo.xcodeproj/xcshareddata/xcschemes/WeexUITestDemo.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /ios/WeexDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | 11 | 12 | @interface AppDelegate : UIResponder 13 | 14 | @property (strong, nonatomic) UIWindow *window; 15 | @property (strong, nonatomic) NSString *latestVer; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /ios/WeexDemo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "size" : "29x29", 15 | "idiom" : "iphone", 16 | "filename" : "Icon-29@2x.png", 17 | "scale" : "2x" 18 | }, 19 | { 20 | "size" : "29x29", 21 | "idiom" : "iphone", 22 | "filename" : "Icon-29@3x.png", 23 | "scale" : "3x" 24 | }, 25 | { 26 | "size" : "40x40", 27 | "idiom" : "iphone", 28 | "filename" : "Icon-40@2x-1.png", 29 | "scale" : "2x" 30 | }, 31 | { 32 | "size" : "40x40", 33 | "idiom" : "iphone", 34 | "filename" : "Icon-40@3x.png", 35 | "scale" : "3x" 36 | }, 37 | { 38 | "size" : "60x60", 39 | "idiom" : "iphone", 40 | "filename" : "Icon-60@2x.png", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "size" : "60x60", 45 | "idiom" : "iphone", 46 | "filename" : "Icon-60@3x.png", 47 | "scale" : "3x" 48 | }, 49 | { 50 | "idiom" : "ipad", 51 | "size" : "20x20", 52 | "scale" : "1x" 53 | }, 54 | { 55 | "idiom" : "ipad", 56 | "size" : "20x20", 57 | "scale" : "2x" 58 | }, 59 | { 60 | "size" : "29x29", 61 | "idiom" : "ipad", 62 | "filename" : "Icon-29.png", 63 | "scale" : "1x" 64 | }, 65 | { 66 | "size" : "29x29", 67 | "idiom" : "ipad", 68 | "filename" : "Icon-29@2x-1.png", 69 | "scale" : "2x" 70 | }, 71 | { 72 | "size" : "40x40", 73 | "idiom" : "ipad", 74 | "filename" : "Icon-40.png", 75 | "scale" : "1x" 76 | }, 77 | { 78 | "size" : "40x40", 79 | "idiom" : "ipad", 80 | "filename" : "Icon-40@2x.png", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "size" : "76x76", 85 | "idiom" : "ipad", 86 | "filename" : "Icon-76.png", 87 | "scale" : "1x" 88 | }, 89 | { 90 | "size" : "76x76", 91 | "idiom" : "ipad", 92 | "filename" : "Icon-76@2x.png", 93 | "scale" : "2x" 94 | }, 95 | { 96 | "size" : "83.5x83.5", 97 | "idiom" : "ipad", 98 | "filename" : "Icon-83.5@2x.png", 99 | "scale" : "2x" 100 | } 101 | ], 102 | "info" : { 103 | "version" : 1, 104 | "author" : "xcode" 105 | } 106 | } -------------------------------------------------------------------------------- /ios/WeexDemo/Assets.xcassets/AppIcon.appiconset/Icon-29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weex-plugins/Amap-for-Apache-Weex/b6c3f5d615e9979527dc22f68e3ed7898dc27b94/ios/WeexDemo/Assets.xcassets/AppIcon.appiconset/Icon-29.png -------------------------------------------------------------------------------- /ios/WeexDemo/Assets.xcassets/AppIcon.appiconset/Icon-29@2x-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weex-plugins/Amap-for-Apache-Weex/b6c3f5d615e9979527dc22f68e3ed7898dc27b94/ios/WeexDemo/Assets.xcassets/AppIcon.appiconset/Icon-29@2x-1.png -------------------------------------------------------------------------------- /ios/WeexDemo/Assets.xcassets/AppIcon.appiconset/Icon-29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weex-plugins/Amap-for-Apache-Weex/b6c3f5d615e9979527dc22f68e3ed7898dc27b94/ios/WeexDemo/Assets.xcassets/AppIcon.appiconset/Icon-29@2x.png -------------------------------------------------------------------------------- /ios/WeexDemo/Assets.xcassets/AppIcon.appiconset/Icon-29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weex-plugins/Amap-for-Apache-Weex/b6c3f5d615e9979527dc22f68e3ed7898dc27b94/ios/WeexDemo/Assets.xcassets/AppIcon.appiconset/Icon-29@3x.png -------------------------------------------------------------------------------- /ios/WeexDemo/Assets.xcassets/AppIcon.appiconset/Icon-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weex-plugins/Amap-for-Apache-Weex/b6c3f5d615e9979527dc22f68e3ed7898dc27b94/ios/WeexDemo/Assets.xcassets/AppIcon.appiconset/Icon-40.png -------------------------------------------------------------------------------- /ios/WeexDemo/Assets.xcassets/AppIcon.appiconset/Icon-40@2x-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weex-plugins/Amap-for-Apache-Weex/b6c3f5d615e9979527dc22f68e3ed7898dc27b94/ios/WeexDemo/Assets.xcassets/AppIcon.appiconset/Icon-40@2x-1.png -------------------------------------------------------------------------------- /ios/WeexDemo/Assets.xcassets/AppIcon.appiconset/Icon-40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weex-plugins/Amap-for-Apache-Weex/b6c3f5d615e9979527dc22f68e3ed7898dc27b94/ios/WeexDemo/Assets.xcassets/AppIcon.appiconset/Icon-40@2x.png -------------------------------------------------------------------------------- /ios/WeexDemo/Assets.xcassets/AppIcon.appiconset/Icon-40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weex-plugins/Amap-for-Apache-Weex/b6c3f5d615e9979527dc22f68e3ed7898dc27b94/ios/WeexDemo/Assets.xcassets/AppIcon.appiconset/Icon-40@3x.png -------------------------------------------------------------------------------- /ios/WeexDemo/Assets.xcassets/AppIcon.appiconset/Icon-60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weex-plugins/Amap-for-Apache-Weex/b6c3f5d615e9979527dc22f68e3ed7898dc27b94/ios/WeexDemo/Assets.xcassets/AppIcon.appiconset/Icon-60@2x.png -------------------------------------------------------------------------------- /ios/WeexDemo/Assets.xcassets/AppIcon.appiconset/Icon-60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weex-plugins/Amap-for-Apache-Weex/b6c3f5d615e9979527dc22f68e3ed7898dc27b94/ios/WeexDemo/Assets.xcassets/AppIcon.appiconset/Icon-60@3x.png -------------------------------------------------------------------------------- /ios/WeexDemo/Assets.xcassets/AppIcon.appiconset/Icon-76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weex-plugins/Amap-for-Apache-Weex/b6c3f5d615e9979527dc22f68e3ed7898dc27b94/ios/WeexDemo/Assets.xcassets/AppIcon.appiconset/Icon-76.png -------------------------------------------------------------------------------- /ios/WeexDemo/Assets.xcassets/AppIcon.appiconset/Icon-76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weex-plugins/Amap-for-Apache-Weex/b6c3f5d615e9979527dc22f68e3ed7898dc27b94/ios/WeexDemo/Assets.xcassets/AppIcon.appiconset/Icon-76@2x.png -------------------------------------------------------------------------------- /ios/WeexDemo/Assets.xcassets/AppIcon.appiconset/Icon-83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weex-plugins/Amap-for-Apache-Weex/b6c3f5d615e9979527dc22f68e3ed7898dc27b94/ios/WeexDemo/Assets.xcassets/AppIcon.appiconset/Icon-83.5@2x.png -------------------------------------------------------------------------------- /ios/WeexDemo/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /ios/WeexDemo/Assets.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "extent" : "full-screen", 5 | "idiom" : "iphone", 6 | "subtype" : "736h", 7 | "filename" : "Default@3x.png", 8 | "minimum-system-version" : "8.0", 9 | "orientation" : "portrait", 10 | "scale" : "3x" 11 | }, 12 | { 13 | "extent" : "full-screen", 14 | "idiom" : "iphone", 15 | "subtype" : "736h", 16 | "filename" : "Default@3x-1.png", 17 | "minimum-system-version" : "8.0", 18 | "orientation" : "landscape", 19 | "scale" : "3x" 20 | }, 21 | { 22 | "extent" : "full-screen", 23 | "idiom" : "iphone", 24 | "subtype" : "667h", 25 | "filename" : "Default-4.7@2x.png", 26 | "minimum-system-version" : "8.0", 27 | "orientation" : "portrait", 28 | "scale" : "2x" 29 | }, 30 | { 31 | "orientation" : "portrait", 32 | "idiom" : "iphone", 33 | "filename" : "Default@2x.png", 34 | "extent" : "full-screen", 35 | "minimum-system-version" : "7.0", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "extent" : "full-screen", 40 | "idiom" : "iphone", 41 | "subtype" : "retina4", 42 | "filename" : "Default-568h@2x.png", 43 | "minimum-system-version" : "7.0", 44 | "orientation" : "portrait", 45 | "scale" : "2x" 46 | }, 47 | { 48 | "orientation" : "portrait", 49 | "idiom" : "ipad", 50 | "extent" : "full-screen", 51 | "minimum-system-version" : "7.0", 52 | "scale" : "1x" 53 | }, 54 | { 55 | "orientation" : "landscape", 56 | "idiom" : "ipad", 57 | "extent" : "full-screen", 58 | "minimum-system-version" : "7.0", 59 | "scale" : "1x" 60 | }, 61 | { 62 | "orientation" : "portrait", 63 | "idiom" : "ipad", 64 | "extent" : "full-screen", 65 | "minimum-system-version" : "7.0", 66 | "scale" : "2x" 67 | }, 68 | { 69 | "orientation" : "landscape", 70 | "idiom" : "ipad", 71 | "extent" : "full-screen", 72 | "minimum-system-version" : "7.0", 73 | "scale" : "2x" 74 | }, 75 | { 76 | "orientation" : "portrait", 77 | "idiom" : "iphone", 78 | "filename" : "Default.png", 79 | "extent" : "full-screen", 80 | "scale" : "1x" 81 | }, 82 | { 83 | "orientation" : "portrait", 84 | "idiom" : "iphone", 85 | "filename" : "Default@2x-1.png", 86 | "extent" : "full-screen", 87 | "scale" : "2x" 88 | }, 89 | { 90 | "orientation" : "portrait", 91 | "idiom" : "iphone", 92 | "filename" : "Default-568h@2x-1.png", 93 | "extent" : "full-screen", 94 | "subtype" : "retina4", 95 | "scale" : "2x" 96 | }, 97 | { 98 | "orientation" : "portrait", 99 | "idiom" : "ipad", 100 | "extent" : "to-status-bar", 101 | "scale" : "1x" 102 | }, 103 | { 104 | "orientation" : "portrait", 105 | "idiom" : "ipad", 106 | "extent" : "full-screen", 107 | "scale" : "1x" 108 | }, 109 | { 110 | "orientation" : "landscape", 111 | "idiom" : "ipad", 112 | "extent" : "to-status-bar", 113 | "scale" : "1x" 114 | }, 115 | { 116 | "orientation" : "landscape", 117 | "idiom" : "ipad", 118 | "extent" : "full-screen", 119 | "scale" : "1x" 120 | }, 121 | { 122 | "orientation" : "portrait", 123 | "idiom" : "ipad", 124 | "extent" : "to-status-bar", 125 | "scale" : "2x" 126 | }, 127 | { 128 | "orientation" : "portrait", 129 | "idiom" : "ipad", 130 | "extent" : "full-screen", 131 | "scale" : "2x" 132 | }, 133 | { 134 | "orientation" : "landscape", 135 | "idiom" : "ipad", 136 | "extent" : "to-status-bar", 137 | "scale" : "2x" 138 | }, 139 | { 140 | "orientation" : "landscape", 141 | "idiom" : "ipad", 142 | "extent" : "full-screen", 143 | "scale" : "2x" 144 | } 145 | ], 146 | "info" : { 147 | "version" : 1, 148 | "author" : "xcode" 149 | } 150 | } -------------------------------------------------------------------------------- /ios/WeexDemo/Assets.xcassets/LaunchImage.launchimage/Default-4.7@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weex-plugins/Amap-for-Apache-Weex/b6c3f5d615e9979527dc22f68e3ed7898dc27b94/ios/WeexDemo/Assets.xcassets/LaunchImage.launchimage/Default-4.7@2x.png -------------------------------------------------------------------------------- /ios/WeexDemo/Assets.xcassets/LaunchImage.launchimage/Default-568h@2x-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weex-plugins/Amap-for-Apache-Weex/b6c3f5d615e9979527dc22f68e3ed7898dc27b94/ios/WeexDemo/Assets.xcassets/LaunchImage.launchimage/Default-568h@2x-1.png -------------------------------------------------------------------------------- /ios/WeexDemo/Assets.xcassets/LaunchImage.launchimage/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weex-plugins/Amap-for-Apache-Weex/b6c3f5d615e9979527dc22f68e3ed7898dc27b94/ios/WeexDemo/Assets.xcassets/LaunchImage.launchimage/Default-568h@2x.png -------------------------------------------------------------------------------- /ios/WeexDemo/Assets.xcassets/LaunchImage.launchimage/Default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weex-plugins/Amap-for-Apache-Weex/b6c3f5d615e9979527dc22f68e3ed7898dc27b94/ios/WeexDemo/Assets.xcassets/LaunchImage.launchimage/Default.png -------------------------------------------------------------------------------- /ios/WeexDemo/Assets.xcassets/LaunchImage.launchimage/Default@2x-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weex-plugins/Amap-for-Apache-Weex/b6c3f5d615e9979527dc22f68e3ed7898dc27b94/ios/WeexDemo/Assets.xcassets/LaunchImage.launchimage/Default@2x-1.png -------------------------------------------------------------------------------- /ios/WeexDemo/Assets.xcassets/LaunchImage.launchimage/Default@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weex-plugins/Amap-for-Apache-Weex/b6c3f5d615e9979527dc22f68e3ed7898dc27b94/ios/WeexDemo/Assets.xcassets/LaunchImage.launchimage/Default@2x.png -------------------------------------------------------------------------------- /ios/WeexDemo/Assets.xcassets/LaunchImage.launchimage/Default@3x-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weex-plugins/Amap-for-Apache-Weex/b6c3f5d615e9979527dc22f68e3ed7898dc27b94/ios/WeexDemo/Assets.xcassets/LaunchImage.launchimage/Default@3x-1.png -------------------------------------------------------------------------------- /ios/WeexDemo/Assets.xcassets/LaunchImage.launchimage/Default@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weex-plugins/Amap-for-Apache-Weex/b6c3f5d615e9979527dc22f68e3ed7898dc27b94/ios/WeexDemo/Assets.xcassets/LaunchImage.launchimage/Default@3x.png -------------------------------------------------------------------------------- /ios/WeexDemo/Assets.xcassets/back.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "back.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "back@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "back@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /ios/WeexDemo/Assets.xcassets/back.imageset/back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weex-plugins/Amap-for-Apache-Weex/b6c3f5d615e9979527dc22f68e3ed7898dc27b94/ios/WeexDemo/Assets.xcassets/back.imageset/back.png -------------------------------------------------------------------------------- /ios/WeexDemo/Assets.xcassets/back.imageset/back@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weex-plugins/Amap-for-Apache-Weex/b6c3f5d615e9979527dc22f68e3ed7898dc27b94/ios/WeexDemo/Assets.xcassets/back.imageset/back@2x.png -------------------------------------------------------------------------------- /ios/WeexDemo/Assets.xcassets/back.imageset/back@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weex-plugins/Amap-for-Apache-Weex/b6c3f5d615e9979527dc22f68e3ed7898dc27b94/ios/WeexDemo/Assets.xcassets/back.imageset/back@3x.png -------------------------------------------------------------------------------- /ios/WeexDemo/Assets.xcassets/reload.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "reload.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "reload@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "reload@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /ios/WeexDemo/Assets.xcassets/reload.imageset/reload.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weex-plugins/Amap-for-Apache-Weex/b6c3f5d615e9979527dc22f68e3ed7898dc27b94/ios/WeexDemo/Assets.xcassets/reload.imageset/reload.png -------------------------------------------------------------------------------- /ios/WeexDemo/Assets.xcassets/reload.imageset/reload@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weex-plugins/Amap-for-Apache-Weex/b6c3f5d615e9979527dc22f68e3ed7898dc27b94/ios/WeexDemo/Assets.xcassets/reload.imageset/reload@2x.png -------------------------------------------------------------------------------- /ios/WeexDemo/Assets.xcassets/reload.imageset/reload@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weex-plugins/Amap-for-Apache-Weex/b6c3f5d615e9979527dc22f68e3ed7898dc27b94/ios/WeexDemo/Assets.xcassets/reload.imageset/reload@3x.png -------------------------------------------------------------------------------- /ios/WeexDemo/Assets.xcassets/scan.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "scan.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "scan@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "scan@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /ios/WeexDemo/Assets.xcassets/scan.imageset/scan.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weex-plugins/Amap-for-Apache-Weex/b6c3f5d615e9979527dc22f68e3ed7898dc27b94/ios/WeexDemo/Assets.xcassets/scan.imageset/scan.png -------------------------------------------------------------------------------- /ios/WeexDemo/Assets.xcassets/scan.imageset/scan@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weex-plugins/Amap-for-Apache-Weex/b6c3f5d615e9979527dc22f68e3ed7898dc27b94/ios/WeexDemo/Assets.xcassets/scan.imageset/scan@2x.png -------------------------------------------------------------------------------- /ios/WeexDemo/Assets.xcassets/scan.imageset/scan@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weex-plugins/Amap-for-Apache-Weex/b6c3f5d615e9979527dc22f68e3ed7898dc27b94/ios/WeexDemo/Assets.xcassets/scan.imageset/scan@3x.png -------------------------------------------------------------------------------- /ios/WeexDemo/DemoDefine.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | 11 | #define CURRENT_IP @"your computer device ip" 12 | 13 | #if TARGET_IPHONE_SIMULATOR 14 | #define DEMO_HOST @"127.0.0.1" 15 | #else 16 | #define DEMO_HOST CURRENT_IP 17 | #endif 18 | 19 | #define DEMO_URL(path) [NSString stringWithFormat:@"http://%@:12580/%s", DEMO_HOST, #path] 20 | 21 | #define HOME_URL [NSString stringWithFormat:@"http://%@:8080/dist/index.js", DEMO_HOST] 22 | 23 | #define BUNDLE_URL [NSString stringWithFormat:@"file://%@/bundlejs/index.js",[NSBundle mainBundle].bundlePath] 24 | 25 | #define UITEST_HOME_URL @"http://test?_wx_tpl=http://localhost:12580/test/build/TC__Home.js" 26 | 27 | #define QRSCAN @"com.taobao.WeexDemo.scan" 28 | #define WEEX_COLOR [UIColor colorWithRed:0.27 green:0.71 blue:0.94 alpha:1] 29 | -------------------------------------------------------------------------------- /ios/WeexDemo/Images.xcassets/Brand Assets.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "iphone", 6 | "minimum-system-version" : "7.0", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "orientation" : "portrait", 11 | "idiom" : "iphone", 12 | "minimum-system-version" : "7.0", 13 | "subtype" : "retina4", 14 | "scale" : "2x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /ios/WeexDemo/WeexConfig/WeexBundleUrlLoder.h: -------------------------------------------------------------------------------- 1 | // 2 | // WeexPlugin.h 3 | // WeexDemo 4 | // 5 | // Created by yangshengtao on 16/11/15. 6 | // Copyright © 2016年 taobao. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface WeexBundleUrlLoder : NSObject 12 | 13 | @property (nonatomic, readonly, copy) NSString* configFile; 14 | 15 | 16 | - (NSURL *)jsBundleURL; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /ios/WeexDemo/WeexConfig/WeexBundleUrlLoder.m: -------------------------------------------------------------------------------- 1 | // 2 | // WeexPlugin.m 3 | // WeexDemo 4 | // 5 | // Created by yangshengtao on 16/11/15. 6 | // Copyright © 2016年 taobao. All rights reserved. 7 | // 8 | 9 | #import "WeexBundleUrlLoder.h" 10 | #import "DemoDefine.h" 11 | #import "WeexConfigParser.h" 12 | #import 13 | @interface WeexBundleUrlLoder () 14 | 15 | @property (nonatomic, readwrite, strong) NSXMLParser* configParser; 16 | @property (nonatomic, readwrite, copy) NSString* configFile; 17 | @property (nonatomic, readwrite, strong) NSArray *pluginNames; 18 | @property (nonatomic, readwrite, strong) NSDictionary* settings; 19 | 20 | @end 21 | 22 | @implementation WeexBundleUrlLoder 23 | 24 | @synthesize configParser, configFile; 25 | - (id)init 26 | { 27 | self = [super init]; 28 | if (self != nil) { 29 | [self loadSettings]; 30 | } 31 | return self; 32 | } 33 | 34 | - (void)parseSettingsWithParser:(NSObject *)delegate 35 | { 36 | // read from config.xml in the app bundle 37 | NSString* path = [self configFilePath]; 38 | 39 | NSURL* url = [NSURL fileURLWithPath:path]; 40 | 41 | self.configParser = [[NSXMLParser alloc] initWithContentsOfURL:url]; 42 | if (self.configParser == nil) { 43 | NSLog(@"Failed to initialize XML parser."); 44 | return; 45 | } 46 | [self.configParser setDelegate:((id < NSXMLParserDelegate >)delegate)]; 47 | [self.configParser parse]; 48 | } 49 | 50 | -(NSString*)configFilePath 51 | { 52 | NSString* path = self.configFile ?: @"config.xml"; 53 | 54 | // if path is relative, resolve it against the main bundle 55 | if(![path isAbsolutePath]){ 56 | NSString* absolutePath = [[NSBundle mainBundle] pathForResource:path ofType:nil]; 57 | if(!absolutePath){ 58 | NSAssert(NO, @"ERROR: %@ not found in the main bundle!", path); 59 | } 60 | path = absolutePath; 61 | } 62 | 63 | // Assert file exists 64 | if (![[NSFileManager defaultManager] fileExistsAtPath:path]) { 65 | NSAssert(NO, @"ERROR: %@ does not exist. Please run cordova-ios/bin/cordova_plist_to_config_xml path/to/project.", path); 66 | return nil; 67 | } 68 | 69 | return path; 70 | } 71 | 72 | - (void)loadSettings 73 | { 74 | WeexConfigParser *delegate = [[WeexConfigParser alloc] init]; 75 | [self parseSettingsWithParser:delegate]; 76 | self.settings = [NSDictionary dictionaryWithDictionary:delegate.settings]; 77 | } 78 | 79 | 80 | - (NSURL *)jsBundleURL 81 | { 82 | if (!self.settings) { 83 | return nil; 84 | } 85 | NSURL *jsBundleUrl = nil; 86 | if (self.settings[@"launch_locally"] && [self.settings[@"launch_locally"] boolValue]) { 87 | NSString *jsFile = self.settings[@"local_url"]; 88 | if (jsFile && ![jsFile isEqualToString:@""]) { 89 | jsBundleUrl = [NSURL URLWithString:[NSString stringWithFormat:@"file://%@/bundlejs/%@",[NSBundle mainBundle].bundlePath,jsFile]]; 90 | }else { 91 | jsBundleUrl = [NSURL URLWithString:[NSString stringWithFormat:@"file://%@/bundlejs/index.js",[NSBundle mainBundle].bundlePath]]; 92 | } 93 | }else { 94 | NSString *hostAddress = self.settings[@"launch_url"]; 95 | if (hostAddress && ![hostAddress isEqualToString:@""]) { 96 | jsBundleUrl = [NSURL URLWithString:[NSString stringWithFormat:@"http://%@:8080/dist/index.js",hostAddress]]; 97 | }else { 98 | jsBundleUrl = [NSURL URLWithString:[NSString stringWithFormat:@"http://%@:8080/dist/index.js", [self getPackageHost]]]; 99 | } 100 | } 101 | return jsBundleUrl; 102 | } 103 | 104 | - (NSString *)getPackageHost 105 | { 106 | static NSString *ipGuess; 107 | static dispatch_once_t onceToken; 108 | dispatch_once(&onceToken, ^{ 109 | NSString *ipPath = [[NSBundle mainBundle] pathForResource:@"ip" ofType:@"txt"]; 110 | ipGuess = [[NSString stringWithContentsOfFile:ipPath encoding:NSUTF8StringEncoding error:nil] 111 | stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]]; 112 | }); 113 | 114 | NSString *host = ipGuess ?: @"localhost"; 115 | return host; 116 | } 117 | 118 | @end 119 | -------------------------------------------------------------------------------- /ios/WeexDemo/WeexConfig/WeexConfigParser.h: -------------------------------------------------------------------------------- 1 | // 2 | // WeexConfigParser.h 3 | // WeexDemo 4 | // 5 | // Created by yangshengtao on 16/11/15. 6 | // Copyright © 2016年 taobao. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface WeexConfigParser : NSObject 12 | { 13 | NSString* featureName; 14 | } 15 | 16 | @property (nonatomic, readonly, strong) NSMutableDictionary* pluginsDict; 17 | @property (nonatomic, readonly, strong) NSMutableDictionary* settings; 18 | @property (nonatomic, readonly, strong) NSMutableArray* pluginNames; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /ios/WeexDemo/WeexConfig/WeexConfigParser.m: -------------------------------------------------------------------------------- 1 | // 2 | // WeexConfigParser.m 3 | // WeexDemo 4 | // 5 | // Created by yangshengtao on 16/11/15. 6 | // Copyright © 2016年 taobao. All rights reserved. 7 | // 8 | 9 | #import "WeexConfigParser.h" 10 | @interface WeexConfigParser () 11 | 12 | @property (nonatomic, readwrite, strong) NSMutableDictionary* pluginsDict; 13 | @property (nonatomic, readwrite, strong) NSMutableDictionary* settings; 14 | @property (nonatomic, readwrite, strong) NSMutableArray* pluginNames; 15 | 16 | @end 17 | 18 | @implementation WeexConfigParser 19 | 20 | @synthesize pluginsDict, settings, pluginNames; 21 | - (id)init 22 | { 23 | self = [super init]; 24 | if (self != nil) { 25 | self.pluginsDict = [[NSMutableDictionary alloc] initWithCapacity:30]; 26 | self.settings = [[NSMutableDictionary alloc] initWithCapacity:30]; 27 | self.pluginNames = [[NSMutableArray alloc] initWithCapacity:8]; 28 | featureName = nil; 29 | } 30 | return self; 31 | } 32 | 33 | - (void)parser:(NSXMLParser*)parser didStartElement:(NSString*)elementName namespaceURI:(NSString*)namespaceURI qualifiedName:(NSString*)qualifiedName attributes:(NSDictionary*)attributeDict 34 | { 35 | if ([elementName isEqualToString:@"preference"]) { 36 | settings[[attributeDict[@"name"] lowercaseString]] = attributeDict[@"value"]; 37 | } else if ([elementName isEqualToString:@"feature"]) { // store feature name to use with correct parameter set 38 | featureName = [attributeDict[@"name"] lowercaseString]; 39 | pluginsDict[@"name"] = featureName; 40 | } else if ((featureName != nil) && [elementName isEqualToString:@"param"]) { 41 | NSString* paramName = [attributeDict[@"name"] lowercaseString]; 42 | id value = attributeDict[@"value"]; 43 | pluginsDict[paramName] = value; 44 | } 45 | } 46 | 47 | - (void)parser:(NSXMLParser*)parser didEndElement:(NSString*)elementName namespaceURI:(NSString*)namespaceURI qualifiedName:(NSString*)qualifiedName 48 | { 49 | if ([elementName isEqualToString:@"feature"]) { // no longer handling a feature so release 50 | NSDictionary *dic = [NSDictionary dictionaryWithDictionary:pluginsDict]; 51 | [self.pluginNames addObject:dic]; 52 | featureName = nil; 53 | [pluginsDict removeAllObjects]; 54 | } 55 | } 56 | 57 | - (void)parser:(NSXMLParser*)parser parseErrorOccurred:(NSError*)parseError 58 | { 59 | NSAssert(NO, @"config.xml parse error line %ld col %ld", (long)[parser lineNumber], (long)[parser columnNumber]); 60 | } 61 | 62 | 63 | @end 64 | -------------------------------------------------------------------------------- /ios/WeexDemo/WeexConfig/WeexSDKManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // WeexSDKManager.h 3 | // WeexDemo 4 | // 5 | // Created by yangshengtao on 16/11/14. 6 | // Copyright © 2016年 taobao. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface WeexSDKManager : NSObject 12 | 13 | + (void)setup; 14 | 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /ios/WeexDemo/WeexConfig/WeexSDKManager.m: -------------------------------------------------------------------------------- 1 | // 2 | // WeexSDKManager.m 3 | // WeexDemo 4 | // 5 | // Created by yangshengtao on 16/11/14. 6 | // Copyright © 2016年 taobao. All rights reserved. 7 | // 8 | 9 | #import "WeexSDKManager.h" 10 | #import "DemoDefine.h" 11 | #import "WeexBundleUrlLoder.h" 12 | #import 13 | #import "WXDemoViewController.h" 14 | #import "WeexPluginManager.h" 15 | 16 | @implementation WeexSDKManager 17 | 18 | + (void)setup; 19 | { 20 | NSURL *url = nil; 21 | WeexBundleUrlLoder *loader = [WeexBundleUrlLoder new]; 22 | #if DEBUG 23 | //If you are debugging in device , please change the host to current IP of your computer. 24 | url = [loader jsBundleURL]; 25 | if (!url) { 26 | url = [NSURL URLWithString:BUNDLE_URL]; 27 | } 28 | #else 29 | url = [NSURL URLWithString:BUNDLE_URL]; 30 | #endif 31 | 32 | #ifdef UITEST 33 | url = [NSURL URLWithString:UITEST_HOME_URL]; 34 | #endif 35 | 36 | [self initWeexSDK]; 37 | [WeexPluginManager registerWeexPlugin]; 38 | [self loadCustomContainWithScannerWithUrl:url]; 39 | } 40 | 41 | + (void)initWeexSDK 42 | { 43 | [WXAppConfiguration setAppGroup:@"AliApp"]; 44 | [WXAppConfiguration setAppName:@"WeexDemo"]; 45 | [WXAppConfiguration setAppVersion:@"1.8.3"]; 46 | [WXAppConfiguration setExternalUserAgent:@"ExternalUA"]; 47 | 48 | [WXSDKEngine initSDKEnvironment]; 49 | 50 | #ifdef DEBUG 51 | [WXLog setLogLevel:WXLogLevelLog]; 52 | #endif 53 | } 54 | 55 | + (void)loadCustomContainWithScannerWithUrl:(NSURL *)url 56 | { 57 | UIViewController *demo = [[WXDemoViewController alloc] init]; 58 | ((WXDemoViewController *)demo).url = url; 59 | [[UIApplication sharedApplication] delegate].window.rootViewController = [[WXRootViewController alloc] initWithRootViewController:demo]; 60 | } 61 | 62 | @end 63 | -------------------------------------------------------------------------------- /ios/WeexDemo/WeexDemo-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | WeexApp 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | com.taobao.yangtao 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 0.1 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 0.1.0 25 | LSRequiresIPhoneOS 26 | 27 | NSAppTransportSecurity 28 | 29 | NSAllowsArbitraryLoads 30 | 31 | 32 | UIApplicationShortcutItems 33 | 34 | 35 | UIApplicationShortcutItemIconFile 36 | scan 37 | UIApplicationShortcutItemSubtitle 38 | scan your QR code 39 | UIApplicationShortcutItemTitle 40 | Scan QR 41 | UIApplicationShortcutItemType 42 | com.taobao.WeexDemo.scan 43 | 44 | 45 | UIRequiredDeviceCapabilities 46 | 47 | armv7 48 | 49 | UIStatusBarStyle 50 | UIStatusBarStyleLightContent 51 | UISupportedInterfaceOrientations 52 | 53 | UIInterfaceOrientationPortrait 54 | 55 | UISupportedInterfaceOrientations~ipad 56 | 57 | UIInterfaceOrientationPortrait 58 | UIInterfaceOrientationPortraitUpsideDown 59 | UIInterfaceOrientationLandscapeLeft 60 | UIInterfaceOrientationLandscapeRight 61 | 62 | UIViewControllerBasedStatusBarAppearance 63 | 64 | NSCameraUsageDescription 65 | 66 | NSPhotoLibraryUsageDescription 67 | 68 | NSLocationWhenInUseUsageDescription 69 | 70 | 71 | -------------------------------------------------------------------------------- /ios/WeexDemo/WeexScanner/UIViewController+WXDemoNaviBar.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | #import "DemoDefine.h" 11 | 12 | @interface UIViewController (WXDemoNaviBar) 13 | 14 | /** 15 | * back button click action 16 | * @param sender responder 17 | */ 18 | - (void)backButtonClicked:(id)sender; 19 | 20 | - (void)setupNaviBar; 21 | 22 | @end 23 | 24 | -------------------------------------------------------------------------------- /ios/WeexDemo/WeexScanner/UIViewController+WXDemoNaviBar.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "UIViewController+WXDemoNaviBar.h" 10 | #import "WXScannerVC.h" 11 | #import 12 | #import 13 | 14 | @implementation UIViewController (WXDemoNaviBar) 15 | 16 | - (void)setupNaviBar 17 | { 18 | UIScreenEdgePanGestureRecognizer *edgePanGestureRecognizer = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(edgePanGesture:)]; 19 | edgePanGestureRecognizer.delegate = self; 20 | edgePanGestureRecognizer.edges = UIRectEdgeLeft; 21 | [self.view addGestureRecognizer:edgePanGestureRecognizer]; 22 | 23 | NSArray *ver = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:@"."]; 24 | if ([[ver objectAtIndex:0] intValue] >= 7) { 25 | // iOS 7.0 or later 26 | self.navigationController.navigationBar.barTintColor = WEEX_COLOR; 27 | self.navigationController.navigationBar.tintColor = [UIColor whiteColor]; 28 | self.navigationController.navigationBar.translucent = NO; 29 | }else { 30 | // iOS 6.1 or earlier 31 | self.navigationController.navigationBar.tintColor = WEEX_COLOR; 32 | } 33 | 34 | [self.navigationController.navigationBar setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys: 35 | [UIColor whiteColor], NSForegroundColorAttributeName, nil]]; 36 | self.navigationItem.title = @"Weex Playground"; 37 | 38 | if (self.navigationItem.leftBarButtonItem) return; 39 | 40 | UIBarButtonItem *leftItem; 41 | if(![[self.navigationController.viewControllers objectAtIndex:0] isEqual:self]) { 42 | leftItem = [self backButtonItem]; 43 | } else { 44 | leftItem = [self leftBarButtonItem]; 45 | } 46 | 47 | self.navigationItem.leftBarButtonItems = @[leftItem]; 48 | } 49 | 50 | - (void)edgePanGesture:(UIScreenEdgePanGestureRecognizer*)edgePanGestureRecognizer 51 | { 52 | [self.navigationController popViewControllerAnimated:YES]; 53 | } 54 | 55 | #pragma mark- UIGestureRecognizerDelegate 56 | - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer 57 | { 58 | if (self.navigationController && [self.navigationController.viewControllers count] == 1) { 59 | return NO; 60 | } 61 | return YES; 62 | } 63 | 64 | #pragma mark - 65 | #pragma mark - UIBarButtonItems 66 | 67 | - (UIBarButtonItem *)leftBarButtonItem 68 | { 69 | UIBarButtonItem *leftItem = objc_getAssociatedObject(self, _cmd); 70 | 71 | if (!leftItem) { 72 | leftItem = [[UIBarButtonItem alloc] 73 | initWithImage:[UIImage imageNamed:@"scan"] 74 | style:UIBarButtonItemStyleBordered 75 | target:self 76 | action:@selector(scanQR:)]; 77 | leftItem.accessibilityHint = @"click to scan qr code"; 78 | leftItem.accessibilityValue = @"scan qr code"; 79 | objc_setAssociatedObject(self, _cmd, leftItem, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 80 | } 81 | return leftItem; 82 | } 83 | 84 | - (UIBarButtonItem *)backButtonItem 85 | { 86 | UIBarButtonItem *backButtonItem = objc_getAssociatedObject(self, _cmd); 87 | if (!backButtonItem) { 88 | backButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"back"] 89 | style:UIBarButtonItemStyleBordered 90 | target:self 91 | action:@selector(backButtonClicked:)]; 92 | objc_setAssociatedObject(self, _cmd, backButtonItem, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 93 | } 94 | return backButtonItem; 95 | } 96 | 97 | #pragma mark - 98 | #pragma mark - UIBarButtonItem actions 99 | 100 | - (void)scanQR:(id)sender 101 | { 102 | WXScannerVC * scanViewController = [[WXScannerVC alloc] init]; 103 | [self.navigationController pushViewController:scanViewController animated:YES]; 104 | } 105 | 106 | - (void)backButtonClicked:(id)sender 107 | { 108 | [self.navigationController popViewControllerAnimated:YES]; 109 | } 110 | 111 | @end 112 | -------------------------------------------------------------------------------- /ios/WeexDemo/WeexScanner/WXDemoViewController.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | #import 11 | 12 | @interface WXDemoViewController : UIViewController 13 | 14 | @property (nonatomic, strong) NSString *script; 15 | @property (nonatomic, strong) NSURL *url; 16 | 17 | @property (nonatomic, strong) SRWebSocket *hotReloadSocket; 18 | @property (nonatomic, strong) NSString *source; 19 | 20 | @end 21 | 22 | -------------------------------------------------------------------------------- /ios/WeexDemo/WeexScanner/WXScannerVC.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | #import 11 | 12 | @interface WXScannerVC : UIViewController 13 | 14 | @end -------------------------------------------------------------------------------- /ios/WeexDemo/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | WeexDemo 4 | 5 | A sample Weex application that responds to the deviceready event. 6 | 7 | 8 | Weex Team 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /ios/WeexDemo/main.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /ios/WeexDemo/weex-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weex-plugins/Amap-for-Apache-Weex/b6c3f5d615e9979527dc22f68e3ed7898dc27b94/ios/WeexDemo/weex-icon.png -------------------------------------------------------------------------------- /ios/WeexDemoTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /ios/WeexDemoTests/WeexDemoTests.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | 11 | @interface WeexDemoTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation WeexDemoTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /ios/WeexUITestDemo-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | NSAppTransportSecurity 26 | 27 | NSAllowsArbitraryLoads 28 | 29 | 30 | UILaunchStoryboardName 31 | LaunchScreen 32 | UIRequiredDeviceCapabilities 33 | 34 | armv7 35 | 36 | UIStatusBarStyle 37 | UIStatusBarStyleLightContent 38 | UISupportedInterfaceOrientations 39 | 40 | UIInterfaceOrientationPortrait 41 | 42 | UISupportedInterfaceOrientations~ipad 43 | 44 | UIInterfaceOrientationPortrait 45 | UIInterfaceOrientationPortraitUpsideDown 46 | UIInterfaceOrientationLandscapeLeft 47 | UIInterfaceOrientationLandscapeRight 48 | 49 | UIViewControllerBasedStatusBarAppearance 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /ios/WeexUITestDemoUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /ios/WeexUITestDemoUITests/WeexUITestDemoUITests.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | 11 | @interface WeexUITestDemoUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation WeexUITestDemoUITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /ios/Weexplugin/Podfile: -------------------------------------------------------------------------------- 1 | source 'git@github.com/CocoaPods/Specs.git' 2 | platform :ios, '7.0' 3 | # inhibit_all_warnings! 4 | def common 5 | pod 'WeexSDK' 6 | pod 'AMap3DMap' 7 | end 8 | target 'Weexplugin' do 9 | common 10 | end 11 | -------------------------------------------------------------------------------- /ios/Weexplugin/Weexplugin.podspec: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | Pod::Spec.new do |s| 4 | s.name = "Weexplugin" 5 | s.version = "0.0.1" 6 | s.summary = "Weex plugin container" 7 | 8 | s.description = <<-DESC 9 | Weexplugin Source Description 10 | DESC 11 | 12 | s.homepage = "https://github.com/weexteam/weex-pack.git" 13 | s.license = { 14 | :type => 'Copyright', 15 | :text => <<-LICENSE 16 | Alibaba-INC copyright 17 | LICENSE 18 | } 19 | s.authors = { 20 | "yangshengtao" =>"yangshengtao1314@163.com" 21 | } 22 | s.platform = :ios 23 | s.ios.deployment_target = "7.0" 24 | 25 | s.source = { :path => '.' } 26 | s.source_files = "Weexplugin/**/*.{h,m,mm}" 27 | # s.exclude_files = "Classes/Exclude" 28 | s.resources = "Weexplugin/Resources/*" 29 | 30 | 31 | s.requires_arc = true 32 | 33 | #s.xcconfig = { "FRAMEWORK_SEARCH_PATHS" => "$(SDKROOT)/TRemoteDebugger" } 34 | s.dependency "WeexSDK" 35 | s.dependency 'AMap3DMap','4.6.1' 36 | #${weexpackPlaceHolder} 37 | 38 | # s.vendored_frameworks = 'Weexplugin.framework' 39 | 40 | # s.user_target_xcconfig = { 'FRAMEWORK_SEARCH_PATHS' => "'$(PODS_ROOT)/Weexplugin'" } 41 | 42 | end 43 | -------------------------------------------------------------------------------- /ios/Weexplugin/Weexplugin.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios/Weexplugin/Weexplugin/Plugins/weex-adapter-image/WXImgLoaderImpl.h: -------------------------------------------------------------------------------- 1 | // Created by yangshengtao on 2017/1/23. 2 | // Copyright © 2016年 taobao. All rights reserved. 3 | 4 | #import 5 | #import 6 | 7 | @interface WXImgLoaderImpl : NSObject 8 | @end 9 | -------------------------------------------------------------------------------- /ios/Weexplugin/Weexplugin/Plugins/weex-adapter-image/WXImgLoaderImpl.m: -------------------------------------------------------------------------------- 1 | // Created by yangshengtao on 2017/1/23. 2 | // Copyright © 2016年 taobao. All rights reserved. 3 | 4 | #import "WXImgLoaderImpl.h" 5 | #import 6 | 7 | @implementation WXImgLoaderImpl 8 | 9 | #pragma mark - 10 | #pragma mark WXImgLoaderProtocol 11 | 12 | - (id)downloadImageWithURL:(NSString *)url imageFrame:(CGRect)imageFrame userInfo:(NSDictionary *)userInfo completed:(void(^)(UIImage *image, NSError *error, BOOL finished))completedBlock 13 | { 14 | if ([url hasPrefix:@"//"]) { 15 | url = [@"http:" stringByAppendingString:url]; 16 | } 17 | return (id)[[SDWebImageManager sharedManager] downloadImageWithURL:[NSURL URLWithString:url] options:0 progress:^(NSInteger receivedSize, NSInteger expectedSize) { 18 | 19 | } completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { 20 | if (completedBlock) { 21 | completedBlock(image, error, finished); 22 | } 23 | }]; 24 | } 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /ios/Weexplugin/Weexplugin/Plugins/weex-plugin-amap/NSArray+WXMap.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+WXMap.h 3 | // Pods 4 | // 5 | // Created by yangshengtao on 17/3/2. 6 | // 7 | // 8 | 9 | #import 10 | 11 | @interface NSArray (WXMap) 12 | 13 | - (id)wxmap_safeObjectForKey:(NSInteger)index; 14 | 15 | @end 16 | 17 | @interface NSMutableArray (WXMap) 18 | 19 | - (void)wxmap_safeAddObject:(id)object; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /ios/Weexplugin/Weexplugin/Plugins/weex-plugin-amap/NSArray+WXMap.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+WXMap.m 3 | // Pods 4 | // 5 | // Created by yangshengtao on 17/3/2. 6 | // 7 | // 8 | 9 | #import "NSArray+WXMap.h" 10 | 11 | @implementation NSArray (WXMap) 12 | 13 | - (id)wxmap_safeObjectForKey:(NSInteger)index 14 | { 15 | if (index < self.count) { 16 | id object = self[index]; 17 | if (object == [NSNull null]) { 18 | return nil; 19 | } 20 | return object; 21 | } 22 | return nil; 23 | } 24 | 25 | @end 26 | 27 | @implementation NSMutableArray (Weex) 28 | 29 | - (void)wxmap_safeAddObject:(id)object 30 | { 31 | if (object) { 32 | [self addObject:object]; 33 | } 34 | } 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /ios/Weexplugin/Weexplugin/Plugins/weex-plugin-amap/NSDictionary+WXMap.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSDictionary+WXMap.h 3 | // Pods 4 | // 5 | // Created by yangshengtao on 17/3/2. 6 | // 7 | // 8 | 9 | #import 10 | 11 | @interface NSDictionary (WXMap) 12 | 13 | - (id)wxmap_safeObjectForKey:(id)aKey; 14 | 15 | @end 16 | 17 | @interface NSMutableDictionary (WXMap) 18 | 19 | - (void)wxmap_safeSetObject:(id)anObject forKey:(id)aKey; 20 | 21 | - (void)wxmap_safeRemoveObjectForKey:(id)aKey; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /ios/Weexplugin/Weexplugin/Plugins/weex-plugin-amap/NSDictionary+WXMap.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSDictionary+WXMap.m 3 | // Pods 4 | // 5 | // Created by yangshengtao on 17/3/2. 6 | // 7 | // 8 | 9 | #import "NSDictionary+WXMap.h" 10 | 11 | @implementation NSDictionary (WXMap) 12 | 13 | - (id)wxmap_safeObjectForKey:(id)aKey 14 | { 15 | id object = [self objectForKey:aKey]; 16 | if (object == [NSNull null]) { 17 | return nil; 18 | } 19 | return object; 20 | 21 | } 22 | 23 | @end 24 | 25 | @implementation NSMutableDictionary (WXMap) 26 | 27 | - (void)wxmap_safeSetObject:(id)anObject forKey:(id)aKey 28 | { 29 | if(!aKey) { 30 | return; 31 | } 32 | if(anObject) { 33 | [self setObject:anObject forKey:aKey]; 34 | } 35 | } 36 | 37 | - (void)wxmap_safeRemoveObjectForKey:(id)aKey 38 | { 39 | if(aKey) { 40 | [self removeObjectForKey:aKey]; 41 | } 42 | } 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /ios/Weexplugin/Weexplugin/Plugins/weex-plugin-amap/NSString+WXMap.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+WXMap.h 3 | // Pods 4 | // 5 | // Created by yangshengtao on 17/3/2. 6 | // 7 | // 8 | 9 | #import 10 | 11 | @interface NSString (WXMap) 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /ios/Weexplugin/Weexplugin/Plugins/weex-plugin-amap/NSString+WXMap.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+WXMap.m 3 | // Pods 4 | // 5 | // Created by yangshengtao on 17/3/2. 6 | // 7 | // 8 | 9 | #import "NSString+WXMap.h" 10 | 11 | @implementation NSString (WXMap) 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /ios/Weexplugin/Weexplugin/Plugins/weex-plugin-amap/WXConvert+AMapKit.h: -------------------------------------------------------------------------------- 1 | // 2 | // WXConvert+AMapKit.h 3 | // Pods 4 | // 5 | // Created by yangshengtao on 17/3/3. 6 | // 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface WXConvert (AMapKit) 13 | 14 | + (BOOL)isLineDash:(id)json; 15 | + (CLLocationCoordinate2D)CLLocationCoordinate2D:(id)json; 16 | + (CGPoint)sizeToWXPixelType:(id)json withInstance:(WXSDKInstance *)instance; 17 | + (CGSize)offsetToContainRect:(CGRect)innerRect inRect:(CGRect)outerRect; 18 | + (BOOL)isValidatedArray:(id)json; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /ios/Weexplugin/Weexplugin/Plugins/weex-plugin-amap/WXConvert+AMapKit.m: -------------------------------------------------------------------------------- 1 | // 2 | // WXConvert+AMapKit.m 3 | // Pods 4 | // 5 | // Created by yangshengtao on 17/3/3. 6 | // 7 | // 8 | 9 | #import "WXConvert+AMapKit.h" 10 | #import "NSArray+WXMap.h" 11 | 12 | @implementation WXConvert (AMapKit) 13 | 14 | 15 | #define WX_JSON_CONVERTER(type) \ 16 | + (type *)type:(id)json { return json; } 17 | 18 | #pragma clang diagnostic push 19 | #pragma clang diagnostic ignored "-Wobjc-protocol-method-implementation" 20 | WX_JSON_CONVERTER(NSArray) 21 | WX_JSON_CONVERTER(NSDictionary) 22 | #pragma clang diagnostic pop 23 | 24 | 25 | + (CLLocationCoordinate2D)CLLocationCoordinate2D:(id)json 26 | { 27 | json = [self NSArray:json]; 28 | return (CLLocationCoordinate2D){ 29 | [[json wxmap_safeObjectForKey:1] doubleValue], 30 | [[json wxmap_safeObjectForKey:0] doubleValue] 31 | }; 32 | } 33 | 34 | + (BOOL)isLineDash:(id)json 35 | { 36 | json = [self NSString:json]; 37 | if ([json isEqualToString:@"dashed"]) { 38 | return YES; 39 | } 40 | return NO; 41 | } 42 | 43 | + (CGSize)offsetToContainRect:(CGRect)innerRect inRect:(CGRect)outerRect 44 | { 45 | CGFloat nudgeRight = fmaxf(0, CGRectGetMinX(outerRect) - (CGRectGetMinX(innerRect))); 46 | CGFloat nudgeLeft = fminf(0, CGRectGetMaxX(outerRect) - (CGRectGetMaxX(innerRect))); 47 | CGFloat nudgeTop = fmaxf(0, CGRectGetMinY(outerRect) - (CGRectGetMinY(innerRect))); 48 | CGFloat nudgeBottom = fminf(0, CGRectGetMaxY(outerRect) - (CGRectGetMaxY(innerRect))); 49 | return CGSizeMake(nudgeLeft ?: nudgeRight, nudgeTop ?: nudgeBottom); 50 | } 51 | 52 | + (CGPoint)sizeToWXPixelType:(id)json withInstance:(WXSDKInstance *)instance 53 | { 54 | json = [self NSArray:json]; 55 | return CGPointMake([WXConvert WXPixelType:[json wxmap_safeObjectForKey:0] scaleFactor:instance.pixelScaleFactor], 56 | [WXConvert WXPixelType:[json wxmap_safeObjectForKey:1] scaleFactor:instance.pixelScaleFactor]); 57 | } 58 | 59 | + (BOOL)isValidatedArray:(id)json 60 | { 61 | NSArray *convertedjson = [self NSArray:json]; 62 | if (convertedjson && convertedjson.count > 1) { 63 | return YES; 64 | } 65 | return NO; 66 | } 67 | 68 | @end 69 | -------------------------------------------------------------------------------- /ios/Weexplugin/Weexplugin/Plugins/weex-plugin-amap/WXMapCircleComponent.h: -------------------------------------------------------------------------------- 1 | // 2 | // WXMapCircleComponent.h 3 | // Pods 4 | // 5 | // Created by yangshengtao on 17/3/6. 6 | // 7 | // 8 | 9 | #import "WXMapPolygonComponent.h" 10 | 11 | @interface WXMapCircleComponent : WXMapPolygonComponent 12 | 13 | @property (nonatomic, strong) NSArray *center; 14 | @property (nonatomic, assign) double radius; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /ios/Weexplugin/Weexplugin/Plugins/weex-plugin-amap/WXMapCircleComponent.m: -------------------------------------------------------------------------------- 1 | // 2 | // WXMapCircleComponent.m 3 | // Pods 4 | // 5 | // Created by yangshengtao on 17/3/6. 6 | // 7 | // 8 | 9 | #import "WXMapCircleComponent.h" 10 | #import "WXMapViewComponent.h" 11 | #import "NSDictionary+WXMap.h" 12 | #import "WXConvert+AMapKit.h" 13 | 14 | @implementation WXMapCircleComponent 15 | 16 | @synthesize center = _center; 17 | @synthesize radius = _radius; 18 | 19 | - (instancetype)initWithRef:(NSString *)ref 20 | type:(NSString*)type 21 | styles:(nullable NSDictionary *)styles 22 | attributes:(nullable NSDictionary *)attributes 23 | events:(nullable NSArray *)events 24 | weexInstance:(WXSDKInstance *)weexInstance 25 | { 26 | self = [super initWithRef:ref type:type styles:styles attributes:attributes events:events weexInstance:weexInstance]; 27 | if (self) { 28 | NSArray *centerArray = [attributes wxmap_safeObjectForKey:@"center"]; 29 | if ([WXConvert isValidatedArray:centerArray]) { 30 | _center = centerArray; 31 | } 32 | _radius = [[attributes wxmap_safeObjectForKey:@"radius"] doubleValue]; 33 | } 34 | return self; 35 | } 36 | 37 | - (void)updateAttributes:(NSDictionary *)attributes 38 | { 39 | NSArray *centerArray = [attributes wxmap_safeObjectForKey:@"center"]; 40 | WXMapViewComponent *parentComponent = (WXMapViewComponent *)self.supercomponent; 41 | if ([WXConvert isValidatedArray:centerArray]) { 42 | _center = centerArray; 43 | [parentComponent removeOverlay:self]; 44 | [parentComponent addOverlay:self]; 45 | }else if ([[attributes wxmap_safeObjectForKey:@"radius"] doubleValue] >= 0) { 46 | _radius = [[attributes wxmap_safeObjectForKey:@"radius"] doubleValue]; 47 | [parentComponent removeOverlay:self]; 48 | [parentComponent addOverlay:self]; 49 | }else { 50 | [super updateAttributes:attributes]; 51 | } 52 | } 53 | 54 | @end 55 | -------------------------------------------------------------------------------- /ios/Weexplugin/Weexplugin/Plugins/weex-plugin-amap/WXMapInfoWindow.h: -------------------------------------------------------------------------------- 1 | // 2 | // WXMapCustomInfoWindow.h 3 | // Pods 4 | // 5 | // Created by yangshengtao on 17/3/7. 6 | // 7 | // 8 | 9 | #import 10 | 11 | @interface WXMapInfoWindow : MAAnnotationView 12 | 13 | - (void)addCustomInfoWindow:(UIView *)view; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /ios/Weexplugin/Weexplugin/Plugins/weex-plugin-amap/WXMapInfoWindow.m: -------------------------------------------------------------------------------- 1 | // 2 | // WXMapCustomInfoWindow.m 3 | // Pods 4 | // 5 | // Created by yangshengtao on 17/3/7. 6 | // 7 | // 8 | 9 | #import "WXMapInfoWindow.h" 10 | 11 | @implementation WXMapInfoWindow 12 | 13 | - (id)initWithAnnotation:(id)annotation reuseIdentifier:(NSString *)reuseIdentifier 14 | { 15 | self = [super initWithAnnotation:annotation reuseIdentifier:reuseIdentifier]; 16 | 17 | if (self){} 18 | 19 | return self; 20 | } 21 | 22 | - (void)addCustomInfoWindow:(UIView *)view; 23 | { 24 | [self addSubview:view]; 25 | } 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /ios/Weexplugin/Weexplugin/Plugins/weex-plugin-amap/WXMapInfoWindowComponent.h: -------------------------------------------------------------------------------- 1 | // 2 | // WXMapInfoWindowComponent.h 3 | // Pods 4 | // 5 | // Created by yangshengtao on 17/3/7. 6 | // 7 | // 8 | 9 | #import "WXMapViewMarkerComponent.h" 10 | #import 11 | 12 | @interface WXMapInfoWindowComponent : WXMapViewMarkerComponent 13 | 14 | @property (nonatomic, strong) MAPointAnnotation *annotation; 15 | @property (nonatomic, copy) NSString *identifier; 16 | 17 | @property (nonatomic, assign) BOOL isOpen; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /ios/Weexplugin/Weexplugin/Plugins/weex-plugin-amap/WXMapInfoWindowComponent.m: -------------------------------------------------------------------------------- 1 | // 2 | // WXMapInfoWindowComponent.m 3 | // Pods 4 | // 5 | // Created by yangshengtao on 17/3/7. 6 | // 7 | // 8 | 9 | #import "WXMapInfoWindowComponent.h" 10 | #import "WXMapViewComponent.h" 11 | #import "WXMapInfoWindow.h" 12 | 13 | @implementation WXMapInfoWindowComponent 14 | @synthesize annotation = _annotation; 15 | @synthesize identifier = _identifier; 16 | 17 | @synthesize isOpen = _isOpen; 18 | 19 | - (instancetype)initWithRef:(NSString *)ref 20 | type:(NSString*)type 21 | styles:(nullable NSDictionary *)styles 22 | attributes:(nullable NSDictionary *)attributes 23 | events:(nullable NSArray *)events 24 | weexInstance:(WXSDKInstance *)weexInstance 25 | { 26 | self = [super initWithRef:ref type:type styles:styles attributes:attributes events:events weexInstance:weexInstance]; 27 | if (self) { 28 | if (attributes[@"open"]) { 29 | _isOpen = [attributes[@"open"] boolValue]; 30 | } 31 | 32 | } 33 | return self; 34 | } 35 | 36 | - (UIView *) loadView 37 | { 38 | return [[WXMapInfoWindow alloc] initWithAnnotation:_annotation reuseIdentifier:_identifier]; 39 | } 40 | 41 | - (void)insertSubview:(WXComponent *)subcomponent atIndex:(NSInteger)index{} 42 | - (void)updateAttributes:(NSDictionary *)attributes 43 | { 44 | if (attributes[@"open"]) 45 | { 46 | _isOpen = [attributes[@"open"] boolValue]; 47 | if (_isOpen) { 48 | [self _addSubView]; 49 | }else { 50 | [self _removeViewFromSuperView]; 51 | } 52 | } 53 | } 54 | 55 | #pragma mark - private method 56 | - (void)_addSubView 57 | { 58 | [self _removeViewFromSuperView]; 59 | [(WXMapViewComponent *)self.supercomponent addMarker:self]; 60 | } 61 | 62 | - (void)_removeViewFromSuperView 63 | { 64 | [(WXMapViewComponent *)self.supercomponent removeMarker:self]; 65 | } 66 | 67 | @end 68 | -------------------------------------------------------------------------------- /ios/Weexplugin/Weexplugin/Plugins/weex-plugin-amap/WXMapPolygonComponent.h: -------------------------------------------------------------------------------- 1 | // 2 | // WXMapPolygon.h 3 | // Pods 4 | // 5 | // Created by yangshengtao on 17/3/3. 6 | // 7 | // 8 | 9 | #import "WXMapRenderer.h" 10 | 11 | @interface WXMapPolygonComponent : WXMapRenderer 12 | 13 | @property (nonatomic, copy) NSString *fillColor; 14 | @property (nonatomic, copy) NSString *fillOpacity; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /ios/Weexplugin/Weexplugin/Plugins/weex-plugin-amap/WXMapPolygonComponent.m: -------------------------------------------------------------------------------- 1 | // 2 | // WXMapPolygon.m 3 | // Pods 4 | // 5 | // Created by yangshengtao on 17/3/3. 6 | // 7 | // 8 | 9 | #import "WXMapPolygonComponent.h" 10 | #import "NSDictionary+WXMap.h" 11 | 12 | @implementation WXMapPolygonComponent 13 | 14 | @synthesize fillColor = _fillColor; 15 | @synthesize fillOpacity = _fillOpacity; 16 | 17 | - (instancetype)initWithRef:(NSString *)ref 18 | type:(NSString*)type 19 | styles:(nullable NSDictionary *)styles 20 | attributes:(nullable NSDictionary *)attributes 21 | events:(nullable NSArray *)events 22 | weexInstance:(WXSDKInstance *)weexInstance 23 | { 24 | self = [super initWithRef:ref type:type styles:styles attributes:attributes events:events weexInstance:weexInstance]; 25 | if (self) { 26 | _fillColor = [attributes wxmap_safeObjectForKey:@"fillColor"]; 27 | _fillOpacity = [attributes wxmap_safeObjectForKey:@"fillOpacity"]; 28 | } 29 | return self; 30 | } 31 | 32 | - (void)updateAttributes:(NSDictionary *)attributes 33 | { 34 | if ([attributes wxmap_safeObjectForKey:@"fillColor"]) { 35 | _fillColor = [attributes wxmap_safeObjectForKey:@"fillColor"]; 36 | }else if ([attributes wxmap_safeObjectForKey:@"fillOpacity"]) { 37 | _fillOpacity = [attributes wxmap_safeObjectForKey:@"fillOpacity"]; 38 | }else { 39 | [super updateAttributes:attributes]; 40 | } 41 | } 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /ios/Weexplugin/Weexplugin/Plugins/weex-plugin-amap/WXMapPolylineComponent.h: -------------------------------------------------------------------------------- 1 | // 2 | // WXMapPolyline.h 3 | // Pods 4 | // 5 | // Created by yangshengtao on 17/3/3. 6 | // 7 | // 8 | 9 | #import "WXMapRenderer.h" 10 | 11 | @interface WXMapPolylineComponent : WXMapRenderer 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /ios/Weexplugin/Weexplugin/Plugins/weex-plugin-amap/WXMapPolylineComponent.m: -------------------------------------------------------------------------------- 1 | // 2 | // WXMapPolyline.m 3 | // Pods 4 | // 5 | // Created by yangshengtao on 17/3/3. 6 | // 7 | // 8 | 9 | #import "WXMapPolylineComponent.h" 10 | 11 | @implementation WXMapPolylineComponent 12 | 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /ios/Weexplugin/Weexplugin/Plugins/weex-plugin-amap/WXMapRenderer.h: -------------------------------------------------------------------------------- 1 | // 2 | // WXMapRenderer.h 3 | // Pods 4 | // 5 | // Created by yangshengtao on 17/3/3. 6 | // 7 | // 8 | 9 | #import 10 | #import 11 | @interface WXComponent(WXMapShape) 12 | 13 | @property(nonatomic, strong) MAShape *shape; 14 | 15 | @end 16 | 17 | @interface WXMapRenderer : WXComponent 18 | 19 | @property (nonatomic, strong) NSArray *path; 20 | @property (nonatomic, copy) NSString *strokeColor; 21 | @property (nonatomic, assign) double strokeWidth; 22 | @property (nonatomic, assign) double strokeOpacity; 23 | @property (nonatomic, copy) NSString *strokeStyle; 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /ios/Weexplugin/Weexplugin/Plugins/weex-plugin-amap/WXMapRenderer.m: -------------------------------------------------------------------------------- 1 | // 2 | // WXMapRenderer.m 3 | // Pods 4 | // 5 | // Created by yangshengtao on 17/3/3. 6 | // 7 | // 8 | 9 | #import "WXMapRenderer.h" 10 | #import "WXMapViewComponent.h" 11 | #import "NSDictionary+WXMap.h" 12 | #import "NSArray+WXMap.h" 13 | #import "WXConvert+AMapKit.h" 14 | 15 | static const void *shapeKey = &shapeKey; 16 | 17 | @implementation WXComponent(WXMapShape) 18 | 19 | @dynamic shape; 20 | 21 | - (void)setShape:(MAShape *)shape { 22 | objc_setAssociatedObject(self, shapeKey, shape, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 23 | } 24 | 25 | - (MAShape *)shape { 26 | return objc_getAssociatedObject(self, shapeKey); 27 | } 28 | 29 | @end 30 | 31 | @implementation WXMapRenderer 32 | { 33 | @private BOOL _viewLoaded; 34 | } 35 | 36 | @synthesize path = _path; 37 | @synthesize strokeColor = _strokeColor; 38 | @synthesize strokeWidth = _strokeWidth; 39 | @synthesize strokeOpacity = _strokeOpacity; 40 | @synthesize strokeStyle = _strokeStyle; 41 | 42 | - (instancetype)initWithRef:(NSString *)ref 43 | type:(NSString*)type 44 | styles:(nullable NSDictionary *)styles 45 | attributes:(nullable NSDictionary *)attributes 46 | events:(nullable NSArray *)events 47 | weexInstance:(WXSDKInstance *)weexInstance 48 | { 49 | self = [super initWithRef:ref type:type styles:styles attributes:attributes events:events weexInstance:weexInstance]; 50 | if (self) { 51 | NSArray * pathArray = [attributes wxmap_safeObjectForKey:@"path"]; 52 | if ([WXConvert isValidatedArray:pathArray]) { 53 | _path = pathArray; 54 | } 55 | _strokeColor = [attributes wxmap_safeObjectForKey:@"strokeColor"]; 56 | _strokeWidth = [[attributes wxmap_safeObjectForKey:@"strokeWidth"] doubleValue]; 57 | _strokeOpacity = [[attributes wxmap_safeObjectForKey:@"strokeOpacity"] doubleValue]; 58 | _strokeStyle = [attributes wxmap_safeObjectForKey:@"strokeStyle"]; 59 | } 60 | _viewLoaded = NO; 61 | return self; 62 | } 63 | 64 | - (void)updateAttributes:(NSDictionary *)attributes 65 | { 66 | NSArray * pathArray = [attributes wxmap_safeObjectForKey:@"path"]; 67 | WXMapViewComponent *parentComponent = (WXMapViewComponent *)self.supercomponent; 68 | if (pathArray) { 69 | if ([WXConvert isValidatedArray:pathArray]) { 70 | _path = pathArray; 71 | } 72 | [parentComponent removeOverlay:self]; 73 | [parentComponent addOverlay:self]; 74 | return; 75 | }else if ([attributes wxmap_safeObjectForKey:@"strokeColor"]) { 76 | _strokeColor = [attributes wxmap_safeObjectForKey:@"strokeColor"]; 77 | }else if ([[attributes wxmap_safeObjectForKey:@"strokeWidth"] doubleValue] >= 0) { 78 | _strokeWidth = [[attributes wxmap_safeObjectForKey:@"strokeWidth"] doubleValue]; 79 | }else if ([[attributes wxmap_safeObjectForKey:@"strokeOpacity"] doubleValue] >= 0) { 80 | _strokeOpacity = [[attributes wxmap_safeObjectForKey:@"strokeOpacity"] doubleValue]; 81 | }else if ([attributes wxmap_safeObjectForKey:@"strokeStyle"]) { 82 | _strokeStyle = [attributes wxmap_safeObjectForKey:@"strokeStyle"]; 83 | } 84 | [parentComponent updateOverlayAttributes:self]; 85 | } 86 | 87 | 88 | - (void)removeFromSuperview; 89 | { 90 | [super removeFromSuperview]; 91 | WXMapViewComponent *parentComponent = (WXMapViewComponent *)self.supercomponent; 92 | [parentComponent removeMarker:self]; 93 | } 94 | 95 | - (void)dealloc 96 | { 97 | 98 | } 99 | 100 | 101 | @end 102 | -------------------------------------------------------------------------------- /ios/Weexplugin/Weexplugin/Plugins/weex-plugin-amap/WXMapViewComponent.h: -------------------------------------------------------------------------------- 1 | // 2 | // WXMapViewComponent.h 3 | // WeexDemo 4 | // 5 | // Created by yangshengtao on 2017/1/20. 6 | // Copyright © 2016年 taobao. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "WXMapViewMarkerComponent.h" 11 | #import "WXMapRenderer.h" 12 | #import 13 | #import 14 | 15 | @interface WXMapViewComponent : WXComponent 16 | 17 | - (NSDictionary *)getUserLocation; 18 | 19 | 20 | #pragma - Marker 21 | - (void)addMarker:(WXMapViewMarkerComponent *)marker; 22 | 23 | - (void)updateTitleMarker:(WXMapViewMarkerComponent *)marker; 24 | 25 | - (void)updateIconMarker:(WXMapViewMarkerComponent *)marker; 26 | 27 | - (void)updateLocationMarker:(WXMapViewMarkerComponent *)marker; 28 | 29 | - (void)removeMarker:(WXComponent *)marker; 30 | 31 | #pragma - Overlay 32 | - (void)addOverlay:(id)overlay; 33 | 34 | - (void)removeOverlay:(id)overlay; 35 | 36 | - (void)updateOverlayAttributes:(id)overlay; 37 | @end 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /ios/Weexplugin/Weexplugin/Plugins/weex-plugin-amap/WXMapViewMarkerComponent.h: -------------------------------------------------------------------------------- 1 | // 2 | // WXMapViewMarkerComponent.h 3 | // Pods 4 | // 5 | // Created by yangshengtao on 17/2/6. 6 | // 7 | // 8 | 9 | #import 10 | 11 | @interface WXMapViewMarkerComponent : WXComponent 12 | 13 | @property (nonatomic, copy) NSString *icon; 14 | @property (nonatomic, copy) NSString *title; 15 | @property (nonatomic, strong) NSArray *location; 16 | 17 | @property (nonatomic, copy) NSString *clickEvent; 18 | 19 | @property (nonatomic, assign) CGPoint offset; 20 | 21 | @property (nonatomic, assign) BOOL hideCallout; 22 | 23 | @property (nonatomic, assign) NSInteger zIndex; 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /ios/Weexplugin/Weexplugin/Plugins/weex-plugin-amap/WXMapViewMarkerComponent.m: -------------------------------------------------------------------------------- 1 | // 2 | // WXMapViewMarkerComponent.m 3 | // Pods 4 | // 5 | // Created by yangshengtao on 17/2/6. 6 | // 7 | // 8 | 9 | #import "WXMapViewMarkerComponent.h" 10 | #import "WXMapViewComponent.h" 11 | #import "NSDictionary+WXMap.h" 12 | #import "WXConvert+AMapKit.h" 13 | 14 | @implementation WXMapViewMarkerComponent 15 | 16 | @synthesize clickEvent = _clickEvent; 17 | @synthesize icon = _icon; 18 | @synthesize title = _title; 19 | @synthesize location = _location; 20 | @synthesize offset = _offset; 21 | @synthesize hideCallout = _hideCallout; 22 | @synthesize zIndex = _zIndex; 23 | 24 | - (instancetype)initWithRef:(NSString *)ref 25 | type:(NSString*)type 26 | styles:(nullable NSDictionary *)styles 27 | attributes:(nullable NSDictionary *)attributes 28 | events:(nullable NSArray *)events 29 | weexInstance:(WXSDKInstance *)weexInstance 30 | { 31 | self = [super initWithRef:ref type:type styles:styles attributes:attributes events:events weexInstance:weexInstance]; 32 | if (self) { 33 | if ([events containsObject:@"click"]) { 34 | _clickEvent = @"click"; 35 | } 36 | NSArray *offset = attributes[@"offset"]; 37 | if ([WXConvert isValidatedArray:offset]) { 38 | _offset = CGPointMake([WXConvert CGFloat:offset[0]], 39 | [WXConvert CGFloat:offset[1]]);//[WXConvert sizeToWXPixelType:attributes[@"offset"] withInstance:self.weexInstance]; 40 | } 41 | if (styles[@"zIndex"]) { 42 | _zIndex = [styles[@"zIndex"] integerValue]; 43 | } 44 | _hideCallout = [[attributes wxmap_safeObjectForKey:@"hideCallout"] boolValue]; 45 | NSArray *position = [attributes wxmap_safeObjectForKey:@"position"]; 46 | if ([WXConvert isValidatedArray:position]) { 47 | _location = [attributes wxmap_safeObjectForKey:@"position"]; 48 | } 49 | _title = [attributes wxmap_safeObjectForKey:@"title"]; 50 | _icon = [attributes wxmap_safeObjectForKey:@"icon"]; 51 | } 52 | return self; 53 | } 54 | 55 | - (void)updateAttributes:(NSDictionary *)attributes 56 | { 57 | WXMapViewComponent *mapComponent = (WXMapViewComponent *)self.supercomponent; 58 | if (attributes[@"title"]) { 59 | _title = attributes[@"title"]; 60 | [mapComponent updateTitleMarker:self]; 61 | } 62 | 63 | if ([attributes wxmap_safeObjectForKey:@"icon"]) { 64 | _icon = attributes[@"icon"]; 65 | [mapComponent updateIconMarker:self]; 66 | } 67 | 68 | NSArray *position = [attributes wxmap_safeObjectForKey:@"position"]; 69 | if ([WXConvert isValidatedArray:position]) { 70 | _location = position; 71 | [mapComponent updateLocationMarker:self]; 72 | 73 | } 74 | } 75 | 76 | - (void)removeFromSuperview; 77 | { 78 | [super removeFromSuperview]; 79 | [super removeFromSuperview]; 80 | WXMapViewComponent *parentComponent = (WXMapViewComponent *)self.supercomponent; 81 | [parentComponent removeMarker:self]; 82 | } 83 | 84 | - (void)dealloc 85 | { 86 | 87 | } 88 | 89 | @end 90 | -------------------------------------------------------------------------------- /ios/Weexplugin/Weexplugin/Plugins/weex-plugin-amap/WXMapViewModule.h: -------------------------------------------------------------------------------- 1 | // 2 | // WXMapViewModule.h 3 | // Pods 4 | // 5 | // Created by yangshengtao on 17/1/23. 6 | // 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | 13 | @interface WXMapViewModule : NSObject 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /ios/Weexplugin/Weexplugin/Plugins/weex-plugin-amap/WXMapViewModule.m: -------------------------------------------------------------------------------- 1 | // 2 | // WXMapViewModule.m 3 | // Pods 4 | // 5 | // Created by yangshengtao on 17/1/23. 6 | // 7 | // 8 | 9 | #import "WXMapViewModule.h" 10 | #import "WXMapViewComponent.h" 11 | #import "WXConvert+AMapKit.h" 12 | 13 | @implementation WXMapViewModule 14 | 15 | @synthesize weexInstance; 16 | 17 | WX_EXPORT_METHOD(@selector(getUserLocation:callback:)) 18 | WX_EXPORT_METHOD(@selector(getLineDistance:marker:callback:)) 19 | WX_EXPORT_METHOD_SYNC(@selector(polygonContainsMarker:ref:callback:)) 20 | 21 | - (void)getUserLocation:(NSString *)elemRef callback:(WXModuleCallback)callback 22 | { 23 | [self performBlockWithRef:elemRef block:^(WXComponent *component) { 24 | callback([(WXMapViewComponent *)component getUserLocation] ? : nil); 25 | }]; 26 | } 27 | 28 | - (void)getLineDistance:(NSArray *)marker marker:(NSArray *)anotherMarker callback:(WXModuleCallback)callback 29 | { 30 | CLLocationCoordinate2D location1 = [WXConvert CLLocationCoordinate2D:marker]; 31 | CLLocationCoordinate2D location2 = [WXConvert CLLocationCoordinate2D:anotherMarker]; 32 | MAMapPoint p1 = MAMapPointForCoordinate(location1); 33 | MAMapPoint p2 = MAMapPointForCoordinate(location2); 34 | CLLocationDistance distance = MAMetersBetweenMapPoints(p1, p2); 35 | NSDictionary *userDic; 36 | if (distance > 0) { 37 | userDic = @{@"result":@"success",@"data":@{@"distance":[NSNumber numberWithDouble:distance]}}; 38 | }else { 39 | userDic = @{@"resuldt":@"false",@"data":@""}; 40 | } 41 | callback(userDic); 42 | } 43 | 44 | - (void)polygonContainsMarker:(NSArray *)position ref:(NSString *)elemRef callback:(WXModuleCallback)callback 45 | { 46 | [self performBlockWithRef:elemRef block:^(WXComponent *WXMapRenderer) { 47 | CLLocationCoordinate2D loc1 = [WXConvert CLLocationCoordinate2D:position]; 48 | MAMapPoint p1 = MAMapPointForCoordinate(loc1); 49 | NSDictionary *userDic; 50 | 51 | if (![WXMapRenderer.shape isKindOfClass:[MAMultiPoint class]]) { 52 | userDic = @{@"result":@"false",@"data":[NSNumber numberWithBool:NO]}; 53 | return; 54 | } 55 | MAMapPoint *points = ((MAMultiPoint *)WXMapRenderer.shape).points; 56 | NSUInteger pointCount = ((MAMultiPoint *)WXMapRenderer.shape).pointCount; 57 | 58 | if(MAPolygonContainsPoint(p1, points, pointCount)) { 59 | userDic = @{@"result":@"success",@"data":[NSNumber numberWithBool:YES]}; 60 | } else { 61 | userDic = @{@"result":@"false",@"data":[NSNumber numberWithBool:NO]}; 62 | } 63 | callback(userDic); 64 | }]; 65 | } 66 | 67 | - (void)performBlockWithRef:(NSString *)elemRef block:(void (^)(WXComponent *))block { 68 | if (!elemRef) { 69 | return; 70 | } 71 | 72 | __weak typeof(self) weakSelf = self; 73 | 74 | WXPerformBlockOnComponentThread(^{ 75 | WXComponent *component = (WXComponent *)[weakSelf.weexInstance componentForRef:elemRef]; 76 | if (!component) { 77 | return; 78 | } 79 | 80 | [weakSelf performSelectorOnMainThread:@selector(doBlock:) withObject:^() { 81 | block(component); 82 | } waitUntilDone:NO]; 83 | }); 84 | } 85 | 86 | - (void)doBlock:(void (^)())block { 87 | block(); 88 | } 89 | @end 90 | -------------------------------------------------------------------------------- /ios/Weexplugin/Weexplugin/Resources/WeexpluginConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | WeexDemo 4 | 5 | A sample Weex application that responds to the deviceready event. 6 | 7 | 8 | Weex Team 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /ios/Weexplugin/Weexplugin/Resources/greenPin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weex-plugins/Amap-for-Apache-Weex/b6c3f5d615e9979527dc22f68e3ed7898dc27b94/ios/Weexplugin/Weexplugin/Resources/greenPin.png -------------------------------------------------------------------------------- /ios/Weexplugin/Weexplugin/Resources/greenPin@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weex-plugins/Amap-for-Apache-Weex/b6c3f5d615e9979527dc22f68e3ed7898dc27b94/ios/Weexplugin/Weexplugin/Resources/greenPin@2x.png -------------------------------------------------------------------------------- /ios/Weexplugin/Weexplugin/Resources/greenPin@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weex-plugins/Amap-for-Apache-Weex/b6c3f5d615e9979527dc22f68e3ed7898dc27b94/ios/Weexplugin/Weexplugin/Resources/greenPin@3x.png -------------------------------------------------------------------------------- /ios/Weexplugin/Weexplugin/Source/WeexPlugin/WeexPluginConfigParser.h: -------------------------------------------------------------------------------- 1 | // 2 | // WeexConfigParser.h 3 | // WeexDemo 4 | // 5 | // Created by yangshengtao on 16/11/15. 6 | // Copyright © 2016年 taobao. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface WeexPluginConfigParser : NSObject 12 | { 13 | NSString* featureName; 14 | } 15 | 16 | @property (nonatomic, readonly, strong) NSMutableDictionary* pluginsDict; 17 | @property (nonatomic, readonly, strong) NSMutableDictionary* settings; 18 | @property (nonatomic, readonly, strong) NSMutableArray* pluginNames; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /ios/Weexplugin/Weexplugin/Source/WeexPlugin/WeexPluginConfigParser.m: -------------------------------------------------------------------------------- 1 | // 2 | // WeexConfigParser.m 3 | // WeexDemo 4 | // 5 | // Created by yangshengtao on 16/11/15. 6 | // Copyright © 2016年 taobao. All rights reserved. 7 | // 8 | 9 | #import "WeexPluginConfigParser.h" 10 | @interface WeexPluginConfigParser () 11 | 12 | @property (nonatomic, readwrite, strong) NSMutableDictionary* pluginsDict; 13 | @property (nonatomic, readwrite, strong) NSMutableDictionary* settings; 14 | @property (nonatomic, readwrite, strong) NSMutableArray* pluginNames; 15 | 16 | @end 17 | 18 | @implementation WeexPluginConfigParser 19 | 20 | @synthesize pluginsDict, settings, pluginNames; 21 | - (id)init 22 | { 23 | self = [super init]; 24 | if (self != nil) { 25 | self.pluginsDict = [[NSMutableDictionary alloc] initWithCapacity:30]; 26 | self.settings = [[NSMutableDictionary alloc] initWithCapacity:30]; 27 | self.pluginNames = [[NSMutableArray alloc] initWithCapacity:8]; 28 | featureName = nil; 29 | } 30 | return self; 31 | } 32 | 33 | - (void)parser:(NSXMLParser*)parser didStartElement:(NSString*)elementName namespaceURI:(NSString*)namespaceURI qualifiedName:(NSString*)qualifiedName attributes:(NSDictionary*)attributeDict 34 | { 35 | if ([elementName isEqualToString:@"preference"]) { 36 | settings[[attributeDict[@"name"] lowercaseString]] = attributeDict[@"value"]; 37 | } else if ([elementName isEqualToString:@"feature"]) { // store feature name to use with correct parameter set 38 | featureName = [attributeDict[@"name"] lowercaseString]; 39 | pluginsDict[@"name"] = featureName; 40 | } else if ((featureName != nil) && [elementName isEqualToString:@"param"]) { 41 | NSString* paramName = [attributeDict[@"name"] lowercaseString]; 42 | id value = attributeDict[@"value"]; 43 | pluginsDict[paramName] = value; 44 | } 45 | } 46 | 47 | - (void)parser:(NSXMLParser*)parser didEndElement:(NSString*)elementName namespaceURI:(NSString*)namespaceURI qualifiedName:(NSString*)qualifiedName 48 | { 49 | if ([elementName isEqualToString:@"feature"]) { // no longer handling a feature so release 50 | NSDictionary *dic = [NSDictionary dictionaryWithDictionary:pluginsDict]; 51 | [self.pluginNames addObject:dic]; 52 | featureName = nil; 53 | [pluginsDict removeAllObjects]; 54 | } 55 | } 56 | 57 | - (void)parser:(NSXMLParser*)parser parseErrorOccurred:(NSError*)parseError 58 | { 59 | NSAssert(NO, @"config.xml parse error line %ld col %ld", (long)[parser lineNumber], (long)[parser columnNumber]); 60 | } 61 | 62 | 63 | @end 64 | -------------------------------------------------------------------------------- /ios/Weexplugin/Weexplugin/Source/WeexPlugin/WeexPluginLoader.h: -------------------------------------------------------------------------------- 1 | // 2 | // WeexPlugin.h 3 | // WeexDemo 4 | // 5 | // Created by yangshengtao on 16/11/15. 6 | // Copyright © 2016年 taobao. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface WeexPluginLoader : NSObject 12 | 13 | + (NSArray *)getPlugins; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /ios/Weexplugin/Weexplugin/Source/WeexPlugin/WeexPluginLoader.m: -------------------------------------------------------------------------------- 1 | // 2 | // WeexPlugin.m 3 | // WeexDemo 4 | // 5 | // Created by yangshengtao on 16/11/15. 6 | // Copyright © 2016年 taobao. All rights reserved. 7 | // 8 | 9 | #import "WeexPluginLoader.h" 10 | #import "WeexPluginConfigParser.h" 11 | @interface WeexPluginLoader () 12 | 13 | @property (nonatomic, readwrite, strong) NSXMLParser* configParser; 14 | @property (nonatomic, readwrite, strong) NSArray *pluginNames; 15 | @property (nonatomic, readwrite, strong) NSDictionary* settings; 16 | 17 | @end 18 | 19 | @implementation WeexPluginLoader 20 | 21 | @synthesize configParser; 22 | 23 | + (NSArray *)getPlugins 24 | { 25 | WeexPluginConfigParser *delegate = [[WeexPluginConfigParser alloc] init]; 26 | [self parseSettingsWithParser:delegate]; 27 | return [NSArray arrayWithArray:delegate.pluginNames] ?: nil; 28 | } 29 | 30 | + (void)parseSettingsWithParser:(NSObject *)delegate 31 | { 32 | // read from config.xml in the app bundle 33 | NSString* path = [self configFilePath:@"WeexpluginConfig.xml"]; 34 | 35 | NSURL* url = [NSURL fileURLWithPath:path]; 36 | 37 | NSXMLParser *configParser = [[NSXMLParser alloc] initWithContentsOfURL:url]; 38 | if (configParser == nil) { 39 | NSLog(@"Failed to initialize XML parser."); 40 | return; 41 | } 42 | [configParser setDelegate:((id < NSXMLParserDelegate >)delegate)]; 43 | [configParser parse]; 44 | } 45 | 46 | +(NSString*)configFilePath:(NSString *)configPath 47 | { 48 | NSString* path = configPath ?: @"config.xml"; 49 | 50 | // if path is relative, resolve it against the main bundle 51 | if(![path isAbsolutePath]){ 52 | NSString* absolutePath = [[NSBundle mainBundle] pathForResource:path ofType:nil]; 53 | if(!absolutePath){ 54 | NSAssert(NO, @"ERROR: %@ not found in the main bundle!", path); 55 | } 56 | path = absolutePath; 57 | } 58 | 59 | // Assert file exists 60 | if (![[NSFileManager defaultManager] fileExistsAtPath:path]) { 61 | NSAssert(NO, @"ERROR: %@ does not exist. Please run weexpack-ios/bin/weexpack_plist_to_config_xml path/to/project.", path); 62 | return nil; 63 | } 64 | 65 | return path; 66 | } 67 | @end 68 | -------------------------------------------------------------------------------- /ios/Weexplugin/Weexplugin/Source/WeexPlugin/WeexPluginManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // WeexPluginManager.h 3 | // Weexplugin 4 | // 5 | // Created by yangshengtao on 16/12/26. 6 | // Copyright © 2016年 Taobao. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface WeexPluginManager : NSObject 12 | 13 | + (void)registerWeexPlugin; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /ios/Weexplugin/Weexplugin/Source/WeexPlugin/WeexPluginManager.m: -------------------------------------------------------------------------------- 1 | // 2 | // WeexPluginManager.m 3 | // Weexplugin 4 | // 5 | // Created by yangshengtao on 16/12/26. 6 | // Copyright © 2016年 Taobao. All rights reserved. 7 | // 8 | 9 | #import "WeexPluginManager.h" 10 | #import "WeexPluginLoader.h" 11 | #import 12 | 13 | @implementation WeexPluginManager 14 | 15 | + (void)registerWeexPlugin 16 | { 17 | NSArray *pluginNames = [NSArray arrayWithArray:[WeexPluginLoader getPlugins]]; 18 | if (!pluginNames) { 19 | return; 20 | } 21 | [pluginNames enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { 22 | NSDictionary *pluginInfo = (NSDictionary *)obj; 23 | if ([pluginInfo[@"category"] isEqualToString:@"handler"] && pluginInfo[@"protocol"]) { 24 | 25 | [WXSDKEngine registerHandler:[NSClassFromString(pluginInfo[@"ios-package"]) new] 26 | withProtocol:NSProtocolFromString(pluginInfo[@"protocol"])]; 27 | }else if ([pluginInfo[@"category"] isEqualToString:@"component"] && pluginInfo[@"ios-package"]) { 28 | [WXSDKEngine registerComponent:pluginInfo[@"api"] withClass:NSClassFromString(pluginInfo[@"ios-package"])]; 29 | }else if ([pluginInfo[@"category"] isEqualToString:@"module"] && pluginInfo[@"ios-package"]) { 30 | [WXSDKEngine registerModule:pluginInfo[@"api"] withClass:NSClassFromString(pluginInfo[@"ios-package"])]; 31 | } 32 | }]; 33 | } 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /ios/Weexplugin/Weexplugin/Weexplugin-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | $(CURRENT_PROJECT_VERSION) 21 | NSPrincipalClass 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /ios/Weexplugin/Weexplugin/Weexplugin.h: -------------------------------------------------------------------------------- 1 | // 2 | // Weexplugin.h 3 | // Weexplugin 4 | // 5 | // Created by yangshengtao on 16/12/26. 6 | // Copyright © 2016年 Taobao. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for Weexplugin. 12 | FOUNDATION_EXPORT double WeexpluginVersionNumber; 13 | 14 | //! Project version string for Weexplugin. 15 | FOUNDATION_EXPORT const unsigned char WeexpluginVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | #import 19 | 20 | 21 | -------------------------------------------------------------------------------- /ios/Weexplugin/WeexpluginTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /ios/Weexplugin/WeexpluginTests/WeexpluginTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // WeexpluginTests.m 3 | // WeexpluginTests 4 | // 5 | // Created by yangshengtao on 16/12/26. 6 | // Copyright © 2016年 Taobao. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface WeexpluginTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation WeexpluginTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /ios/Weexplugin/frameworks.json: -------------------------------------------------------------------------------- 1 | { 2 | "ImageIO.framework": 2, 3 | "CoreLocation.framework": 2, 4 | "AVFoundation.framework": 2 5 | } -------------------------------------------------------------------------------- /ios/Weexplugin/ios.json: -------------------------------------------------------------------------------- 1 | { 2 | "prepare_queue": { 3 | "installed": [], 4 | "uninstalled": [] 5 | }, 6 | "config_munge": { 7 | "files": { 8 | "WeexpluginConfig.xml": { 9 | "parents": { 10 | "/*": [ 11 | { 12 | "xml": "", 13 | "count": 1 14 | }, 15 | { 16 | "xml": "", 17 | "count": 1 18 | }, 19 | { 20 | "xml": "", 21 | "count": 1 22 | }, 23 | { 24 | "xml": "", 25 | "count": 1 26 | } 27 | ] 28 | } 29 | }, 30 | "*-Info.plist": { 31 | "parents": { 32 | "NSCameraUsageDescription": [ 33 | { 34 | "xml": " ", 35 | "count": 1 36 | } 37 | ], 38 | "NSPhotoLibraryUsageDescription": [ 39 | { 40 | "xml": " ", 41 | "count": 1 42 | } 43 | ], 44 | "NSLocationWhenInUseUsageDescription": [ 45 | { 46 | "xml": "", 47 | "count": 1 48 | } 49 | ] 50 | } 51 | } 52 | } 53 | }, 54 | "installed_plugins": { 55 | "weex-adapter-image": { 56 | "PACKAGE_NAME": "$(PRODUCT_BUNDLE_IDENTIFIER)" 57 | }, 58 | "weex-plugin-amap": { 59 | "CAMERA_USAGE_DESCRIPTION": " ", 60 | "PHOTOLIBRARY_USAGE_DESCRIPTION": " ", 61 | "PACKAGE_NAME": "$(PRODUCT_BUNDLE_IDENTIFIER)" 62 | } 63 | }, 64 | "dependent_plugins": {}, 65 | "modules": [], 66 | "plugin_metadata": { 67 | "weex-adapter-image": "1.0.1", 68 | "weex-plugin-amap": "1.0.0" 69 | } 70 | } -------------------------------------------------------------------------------- /ios/Weexplugin/pods.json: -------------------------------------------------------------------------------- 1 | { 2 | "AMap3DMap": { 3 | "name": "AMap3DMap", 4 | "type": "podspec", 5 | "spec": "", 6 | "count": 1 7 | } 8 | } -------------------------------------------------------------------------------- /ios/weex.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weex-plugins/Amap-for-Apache-Weex/b6c3f5d615e9979527dc22f68e3ed7898dc27b94/ios/weex.png -------------------------------------------------------------------------------- /ios/weex@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weex-plugins/Amap-for-Apache-Weex/b6c3f5d615e9979527dc22f68e3ed7898dc27b94/ios/weex@2x.png -------------------------------------------------------------------------------- /js/demo.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | add points 9 | 10 | 11 | 12 | 34 | 35 | 75 | -------------------------------------------------------------------------------- /js/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "weex-plugin-amap", 3 | "version": "1.0.0", 4 | "platform": [ 5 | "web" 6 | ], 7 | "main": "weex-amap.we", 8 | "description": "weex amap component", 9 | "keywords": [ 10 | "weex", 11 | "amap", 12 | "mapview" 13 | ], 14 | "license": "Apache 2.0", 15 | "dependencies": { 16 | "vue-amap": "^0.1.4" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /js/weex-amap.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 68 | -------------------------------------------------------------------------------- /karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration 2 | // Generated on Mon Jan 23 2017 17:26:28 GMT+0800 (CST) 3 | 4 | module.exports = function(config) { 5 | config.set({ 6 | 7 | // base path that will be used to resolve all patterns (eg. files, exclude) 8 | basePath: '', 9 | 10 | 11 | // frameworks to use 12 | // available frameworks: https://npmjs.org/browse/keyword/karma-adapter 13 | frameworks: ['jasmine'], 14 | 15 | 16 | // list of files / patterns to load in the browser 17 | files: [ 18 | './tests/*.test.js' 19 | ], 20 | 21 | 22 | // list of files to exclude 23 | exclude: [ 24 | ], 25 | 26 | 27 | // preprocess matching files before serving them to the browser 28 | // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor 29 | preprocessors: { 30 | }, 31 | 32 | 33 | // test results reporter to use 34 | // possible values: 'dots', 'progress' 35 | // available reporters: https://npmjs.org/browse/keyword/karma-reporter 36 | reporters: ['progress'], 37 | 38 | 39 | // web server port 40 | port: 9876, 41 | 42 | 43 | // enable / disable colors in the output (reporters and logs) 44 | colors: true, 45 | 46 | 47 | // level of logging 48 | // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG 49 | logLevel: config.LOG_INFO, 50 | 51 | 52 | // enable / disable watching file and executing tests whenever any file changes 53 | autoWatch: true, 54 | 55 | 56 | // start these browsers 57 | // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher 58 | browsers: ['Chrome'], 59 | 60 | 61 | // Continuous Integration mode 62 | // if true, Karma captures browsers, runs the tests and exits 63 | singleRun: false, 64 | 65 | // Concurrency level 66 | // how many browser should be started simultaneous 67 | concurrency: Infinity 68 | }) 69 | } 70 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "weex-plugin--weex-plugin-amap", 3 | "version": "0.0.2", 4 | "platform": [ 5 | "ios" 6 | ], 7 | "main": "./js/index.we", 8 | "description": "weex amap component", 9 | "keywords": [ 10 | "weex", 11 | "amap", 12 | "mapview" 13 | ], 14 | "scripts": { 15 | "eslint": "eslint" 16 | }, 17 | "license": "Apache 2.0", 18 | "devDependencies": { 19 | "babel-eslint": "^7.1.1", 20 | "eslint": "^3.14.0", 21 | "eslint-config-airbnb": "^14.0.0", 22 | "eslint-config-airbnb-base": "^11.0.1", 23 | "eslint-config-standard": "^6.2.1", 24 | "eslint-plugin-html": "^1.7.0", 25 | "eslint-plugin-import": "^2.2.0", 26 | "eslint-plugin-jsx-a11y": "^3.0.2", 27 | "eslint-plugin-promise": "^3.4.0", 28 | "eslint-plugin-react": "^6.9.0", 29 | "eslint-plugin-standard": "^2.0.1", 30 | "jasmine": "^2.5.3", 31 | "karma": "^1.4.0", 32 | "karma-chrome-launcher": "^2.0.0", 33 | "karma-jasmine": "^1.1.0" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /web/components/amap-circle.js: -------------------------------------------------------------------------------- 1 | import components from '../service/components'; 2 | import vendor from '../service/vendor'; 3 | 4 | const componentName = 'circle'; 5 | // prototype methods. 6 | const proto = { 7 | create() { 8 | const node = document.createElement('div'); 9 | const data = this.data.attr; 10 | const comId = data.ref || vendor.gengerateRandomId(componentName); 11 | if (data.center && Array.isArray(data.center)) { 12 | components.registerComponent(componentName, { 13 | center: data.center, 14 | radius: data.radius, 15 | fillColor: data.fillColor, 16 | filOpacity: data.fillOpacity, 17 | strokeWeight: data.strokeWidth, 18 | strokeOpacity: data.strokeOpacity, 19 | strokeColor: data.strokeColor, 20 | strokeStyle: data.strokeStyle, 21 | events: { 22 | click: () => { 23 | this.dispatchEvent('click'); 24 | } 25 | }, 26 | }, comId); 27 | } else { 28 | console.warn('attribute center must be an array.'); 29 | } 30 | this._comId = comId; 31 | return node; 32 | } 33 | }; 34 | 35 | const attr = { 36 | center(val) { 37 | const com = components.getComponent(this._comId); 38 | if (com) { 39 | com.setCenter(val); 40 | } 41 | } 42 | }; 43 | 44 | const event = { 45 | click: { 46 | extra() { 47 | return { isSuccess: true }; 48 | } 49 | } 50 | }; 51 | 52 | function init(Weex) { 53 | const Component = Weex.Component; 54 | const extend = Weex.utils.extend; 55 | 56 | function AmapCircle(data) { 57 | Component.call(this, data); 58 | } 59 | AmapCircle.prototype = Object.create(Component.prototype); 60 | extend(AmapCircle.prototype, proto); 61 | extend(AmapCircle.prototype, { attr }); 62 | extend(AmapCircle.prototype, { event }); 63 | Weex.registerComponent('weex-amap-circle', AmapCircle); 64 | } 65 | 66 | export default { init }; 67 | -------------------------------------------------------------------------------- /web/components/amap-info-window.js: -------------------------------------------------------------------------------- 1 | import components from '../service/components'; 2 | import vendor from '../service/vendor'; 3 | 4 | const componentName = 'InfoWindow'; 5 | // prototype methods. 6 | const proto = { 7 | create() { 8 | const node = document.createElement('div'); 9 | node.style.opacity = 0; 10 | const data = this.data.attr; 11 | const comId = this.data.ref || vendor.gengerateRandomId(componentName); 12 | this.addAppendHandler(() => { 13 | if (data.position && Array.isArray(data.position)) { 14 | components.registerComponent(componentName, { 15 | position: data.position, 16 | offset: data.offset, 17 | isCustom: true, 18 | }, comId, (com, map) => { 19 | let content = data.content; 20 | if (this.node.innerHTML.length > 0) { 21 | content = this.node.innerHTML; 22 | } 23 | if (content) { 24 | com.setContent(content); 25 | } 26 | if (data.open && content) { 27 | com.open(map, this.data.attr.position); 28 | } else { 29 | com.close(); 30 | } 31 | }); 32 | } else { 33 | console.warn('attribute center must be an array.'); 34 | } 35 | }); 36 | this._comId = comId; 37 | return node; 38 | } 39 | }; 40 | 41 | const attr = { 42 | open(val) { 43 | const com = components.getComponent(this.data.ref); 44 | const map = components.getComponentMap(); 45 | if (com) { 46 | if (val) { 47 | com.open(map, this.data.attr.position); 48 | } else { 49 | com.close(); 50 | } 51 | } 52 | } 53 | }; 54 | 55 | const event = { 56 | }; 57 | 58 | function init(Weex) { 59 | const Component = Weex.Component; 60 | const extend = Weex.utils.extend; 61 | 62 | function AmapInfoWindow(data) { 63 | Component.call(this, data); 64 | } 65 | AmapInfoWindow.prototype = Object.create(Component.prototype); 66 | extend(AmapInfoWindow.prototype, proto); 67 | extend(AmapInfoWindow.prototype, { attr }); 68 | extend(AmapInfoWindow.prototype, { event }); 69 | Weex.registerComponent('weex-amap-info-window', AmapInfoWindow); 70 | } 71 | 72 | export default { init }; 73 | -------------------------------------------------------------------------------- /web/components/amap-marker.js: -------------------------------------------------------------------------------- 1 | import markerManager from '../service/marker'; 2 | 3 | const params = { 4 | poistion: [], 5 | title: '', 6 | icon: '' 7 | }; 8 | 9 | // prototype methods. 10 | const proto = { 11 | create() { 12 | const node = document.createElement('div'); 13 | const data = this.data.attr; 14 | markerManager.addMarker({ 15 | position: data.position, 16 | icon: data.icon, 17 | title: data.title, 18 | ref: this.data.ref, 19 | events: { 20 | click: () => { 21 | this.dispatchEvent('click'); 22 | } 23 | }, 24 | map: window.Amap 25 | }); 26 | return node; 27 | }, 28 | updateAttrs(attrs) { 29 | const keys = Object.keys(attrs); 30 | const data = { 31 | ref: this.data.ref 32 | }; 33 | keys.forEach((k) => { 34 | markerManager.updateMarker(data, k, attrs[k]); 35 | }); 36 | } 37 | }; 38 | 39 | const attr = { 40 | position(val) { 41 | console.log(val); 42 | console.log(this); 43 | if (Array.isArray(val) && val.length === 2) { 44 | params.position = val; 45 | } 46 | }, 47 | icon(val) { 48 | params.icon = val; 49 | }, 50 | title(val) { 51 | params.title = val; 52 | } 53 | }; 54 | 55 | const event = { 56 | click: { 57 | extra() { 58 | return { isSuccess: true }; 59 | } 60 | } 61 | }; 62 | 63 | function init(Weex) { 64 | const Component = Weex.Component; 65 | const extend = Weex.utils.extend; 66 | 67 | function AmapMaker(data) { 68 | Component.call(this, data); 69 | } 70 | AmapMaker.prototype = Object.create(Component.prototype); 71 | extend(AmapMaker.prototype, proto); 72 | extend(AmapMaker.prototype, { attr }); 73 | extend(AmapMaker.prototype, { event }); 74 | Weex.registerComponent('weex-amap-marker', AmapMaker); 75 | } 76 | 77 | export default { init }; 78 | -------------------------------------------------------------------------------- /web/components/amap-polygon.js: -------------------------------------------------------------------------------- 1 | import components from '../service/components'; 2 | import vendor from '../service/vendor'; 3 | 4 | const componentName = 'polygon'; 5 | // prototype methods. 6 | const proto = { 7 | create() { 8 | const node = document.createElement('div'); 9 | const data = this.data.attr; 10 | const comId = this.data.ref || vendor.gengerateRandomId(componentName); 11 | if (data.path && Array.isArray(data.path)) { 12 | components.registerComponent(componentName, { 13 | path: data.path, 14 | fillColor: data.fillColor, 15 | filOpacity: data.fillOpacity, 16 | strokeWeight: data.strokeWidth, 17 | strokeOpacity: data.strokeOpacity, 18 | strokeColor: data.strokeColor, 19 | strokeStyle: data.strokeStyle, 20 | events: { 21 | click: () => { 22 | this.dispatchEvent('click'); 23 | } 24 | }, 25 | }, comId); 26 | } else { 27 | console.warn('attribute path must be an array.'); 28 | } 29 | this._comId = comId; 30 | return node; 31 | } 32 | }; 33 | 34 | const attr = { 35 | 36 | }; 37 | 38 | const event = { 39 | click: { 40 | extra() { 41 | return { isSuccess: true }; 42 | } 43 | } 44 | }; 45 | 46 | function init(Weex) { 47 | const Component = Weex.Component; 48 | const extend = Weex.utils.extend; 49 | 50 | function AmapPolygon(data) { 51 | Component.call(this, data); 52 | } 53 | AmapPolygon.prototype = Object.create(Component.prototype); 54 | extend(AmapPolygon.prototype, proto); 55 | extend(AmapPolygon.prototype, { attr }); 56 | extend(AmapPolygon.prototype, { event }); 57 | Weex.registerComponent('weex-amap-polygon', AmapPolygon); 58 | } 59 | 60 | export default { init }; 61 | -------------------------------------------------------------------------------- /web/components/amap-polyline.js: -------------------------------------------------------------------------------- 1 | import components from '../service/components'; 2 | import vendor from '../service/vendor'; 3 | 4 | const componentName = 'polyline'; 5 | 6 | let data = {}; 7 | // prototype methods. 8 | const proto = { 9 | create() { 10 | const node = document.createElement('div'); 11 | data = this.data.attr; 12 | const comId = data.ref || vendor.gengerateRandomId(componentName); 13 | if (data.path && Array.isArray(data.path)) { 14 | components.registerComponent(componentName, { 15 | path: data.path, 16 | strokeWeight: data.strokeWidth, 17 | strokeOpacity: data.strokeOpacity, 18 | strokeColor: data.strokeColor, 19 | strokeStyle: data.strokeStyle, 20 | lineJoin: 'round', 21 | events: { 22 | click: () => { 23 | this.dispatchEvent('click'); 24 | } 25 | }, 26 | }, comId, (com) => { 27 | com.setPath(data.path); 28 | }); 29 | } else { 30 | console.warn('attribute path must be an array.'); 31 | } 32 | this._comId = comId; 33 | return node; 34 | } 35 | }; 36 | 37 | const attr = { 38 | path(val) { 39 | if (Array.isArray(val) && val.length >= 2) { 40 | data.path = val; 41 | const com = components.getComponent(this._comId); 42 | if (com) { 43 | com.setPath(val); 44 | } 45 | } 46 | } 47 | }; 48 | 49 | const event = { 50 | click: { 51 | extra() { 52 | return { isSuccess: true }; 53 | } 54 | } 55 | }; 56 | 57 | function init(Weex) { 58 | const Component = Weex.Component; 59 | const extend = Weex.utils.extend; 60 | 61 | function AmapPolygon(opts) { 62 | Component.call(this, opts); 63 | } 64 | AmapPolygon.prototype = Object.create(Component.prototype); 65 | extend(AmapPolygon.prototype, proto); 66 | extend(AmapPolygon.prototype, { attr }); 67 | extend(AmapPolygon.prototype, { event }); 68 | Weex.registerComponent('weex-amap-polyline', AmapPolygon); 69 | } 70 | 71 | export default { init }; 72 | -------------------------------------------------------------------------------- /web/components/amap.js: -------------------------------------------------------------------------------- 1 | import markerManage from '../service/marker'; 2 | import mapLoader from '../service/map-loader'; 3 | import amapManager from '../service/map-manager'; 4 | import vendor from '../service/vendor'; 5 | 6 | 7 | const loadingGif = 'http://img1.vued.vanthink.cn/vued2113eaa062abbaee0441d16a7848d23e.gif'; 8 | const params = { 9 | center: undefined, 10 | zoom: 11, 11 | toolbar: true, 12 | scale: false, 13 | geolocation: false, 14 | resizeEnable: true, 15 | search: false 16 | }; 17 | const events = [ 18 | 'zoomchange', 19 | 'dragend' 20 | ]; 21 | // prototype methods. 22 | const proto = { 23 | create() { 24 | this.mapwrap = document.createElement('div'); 25 | this.mapwrap.id = vendor.gengerateRandomId('map'); 26 | this.mapwrap.append(this.renderLoadingSpinner()); 27 | return this.mapwrap; 28 | }, 29 | renderLoadingSpinner() { 30 | const el = document.createElement('div'); 31 | el.style.height = 60; 32 | el.style.margin = '20 auto'; 33 | el.style.textAlign = 'center'; 34 | const image = document.createElement('img'); 35 | image.src = loadingGif; 36 | el.appendChild(image); 37 | const text = document.createElement('div'); 38 | text.appendChild(document.createTextNode('高德地图加载中....')); 39 | el.appendChild(text); 40 | return el; 41 | }, 42 | ready() { 43 | const self = this; 44 | if (window.AMap) { 45 | this.map = new AMap.Map(this.mapwrap.id, params); 46 | AMap.plugin(['AMap.ToolBar', 'AMap.Geolocation'], () => { 47 | if (params.scale) { 48 | self.map.addControl(new AMap.ToolBar()); 49 | } 50 | if (params.geolocation) { 51 | self.map.addControl(new AMap.Geolocation()); 52 | } 53 | }); 54 | if (params.search) { 55 | AMap.service('AMap.PlaceSearch', () => { 56 | this.placeSearch = new AMap.PlaceSearch(); 57 | }); 58 | } 59 | this.initEvents(); 60 | amapManager.initMap(this.mapwrap.id, this.map); 61 | } 62 | }, 63 | removeChild(child) { 64 | markerManage.removeMaker(child.data); 65 | }, 66 | initEvents() { 67 | events.forEach((eventName) => { 68 | AMap.event.addListener(this.map, eventName, () => { 69 | this.dispatchEvent(eventName); 70 | }); 71 | }); 72 | } 73 | }; 74 | 75 | const attr = { 76 | center(val) { 77 | if (Array.isArray(val) && val.length === 2) { 78 | params.center = val; 79 | if (window.AMap) { 80 | this.map.setCenter(params.center); 81 | } 82 | } 83 | if (typeof val === 'number') { 84 | const geo = new AMap.Geolocation({ 85 | enableHighAccuracy: true 86 | }); 87 | const self = this; 88 | geo.getCurrentPosition(); 89 | AMap.event.AMap.event.addListener(geo, 'complete', (data) => { 90 | params.center = [data.position.getLng(), data.position.getLat()]; 91 | self.map.setCenter(params.center); 92 | }); 93 | } 94 | }, 95 | zoom(val) { 96 | if (/^[0-9]+$/.test(val)) { 97 | params.zoom = val; 98 | } 99 | if (window.AMap) { 100 | this.map.setZoom(params.zoom); 101 | } 102 | }, 103 | scale(val) { 104 | params.scale = val; 105 | }, 106 | geolocation(val) { 107 | params.geolocation = val; 108 | }, 109 | sdkKey(val) { 110 | let key = ''; 111 | if (val) { 112 | key = val.h5; 113 | } 114 | mapLoader.load({ 115 | key: key 116 | }, this.mapwrap, () => this.ready()); 117 | }, 118 | search(val) { 119 | params.search = val; 120 | if (window.AMap) { 121 | 122 | } 123 | } 124 | }; 125 | 126 | const event = { 127 | zoomchange: { 128 | extra() { 129 | return { isSuccess: true }; 130 | } 131 | }, 132 | dragend: { 133 | extra() { 134 | return { isSuccess: true }; 135 | } 136 | } 137 | }; 138 | 139 | function init(Weex) { 140 | const Component = Weex.Component; 141 | const extend = Weex.utils.extend; 142 | 143 | function Amap(data) { 144 | Component.call(this, data); 145 | } 146 | Amap.prototype = Object.create(Component.prototype); 147 | extend(Amap.prototype, proto); 148 | extend(Amap.prototype, { attr }); 149 | extend(Amap.prototype, { 150 | style: extend(Object.create(Component.prototype.style), {}) 151 | }); 152 | extend(Amap.prototype, { event }); 153 | Weex.registerComponent('weex-amap', Amap); 154 | } 155 | 156 | export default { init }; 157 | -------------------------------------------------------------------------------- /web/index.js: -------------------------------------------------------------------------------- 1 | import amapModuleReg from './module/amap'; 2 | import Amap from './components/amap'; 3 | import AmapMarker from './components/amap-marker'; 4 | import AmapCircle from './components/amap-circle'; 5 | import AmapPolygon from './components/amap-polygon'; 6 | import AmapPolyline from './components/amap-polyline'; 7 | import AmapInfoWindow from './components/amap-info-window'; 8 | // import VueAmap from './vue-amap/index'; 9 | const components = [ 10 | Amap, 11 | AmapMarker, 12 | AmapCircle, 13 | AmapPolygon, 14 | AmapPolyline, 15 | AmapInfoWindow 16 | ]; 17 | 18 | function init(Weex) { 19 | components.forEach((comp) => { 20 | comp.init(Weex); 21 | }); 22 | amapModuleReg(Weex); 23 | } 24 | module.exports = { 25 | init 26 | }; 27 | 28 | -------------------------------------------------------------------------------- /web/module/amap.js: -------------------------------------------------------------------------------- 1 | import components from '../service/components'; 2 | // AMap module 3 | const amap = { 4 | /** get user loaction by browser and IP 5 | * @param {function} callback 6 | * @param {function} errorCallback 7 | **/ 8 | getUserLocation(mapRef, callback) { 9 | const self = this; 10 | const geo = new AMap.Geolocation({ 11 | enableHighAccuracy: true, 12 | timeout: 10000 13 | }); 14 | geo.getCurrentPosition((status, res) => { 15 | if (status !== 'error') { 16 | self.sender.performCallback(callback, { 17 | data: { 18 | position: [res.position.getLng(), res.position.getLat()] 19 | }, 20 | result: 'success' 21 | }); 22 | } else { 23 | console.warn(res.message); 24 | } 25 | }); 26 | }, 27 | /** get distance between two position 28 | * @param coor1 29 | * @param corr2 30 | * @param callback 31 | **/ 32 | getLineDistance(coor1, coor2, callback) { 33 | const lnglat = new AMap.LngLat(coor1[0], coor1[1]); 34 | const result = lnglat.distance(coor2); 35 | this.sender.performCallback(callback, { 36 | result: !result ? 'fail' : 'success', 37 | data: { 38 | distance: result 39 | } 40 | }); 41 | }, 42 | /** tell if the marker in a polygon 43 | * @param coor the marker position 44 | * @param polygonRef 45 | **/ 46 | polygonContainsMarker(coor, polygonRef, callback) { 47 | const polygonCom = components.getComponent(polygonRef); 48 | const result = polygonCom.contains(coor); 49 | this.sender.performCallback(callback, { 50 | result: !result ? 'fail' : 'success', 51 | data: result 52 | }); 53 | } 54 | }; 55 | 56 | const meta = { 57 | amap: [ 58 | { 59 | name: 'getUserLocation', 60 | args: ['string', 'function'], 61 | }, 62 | { 63 | name: 'getLineDistance', 64 | args: ['array', 'array', 'function'] 65 | }, 66 | { 67 | name: 'polygonContainsMarker', 68 | args: ['array', 'string'] 69 | } 70 | ] 71 | }; 72 | 73 | module.exports = function (Weex) { 74 | Weex.registerApiModule('amap', amap, meta); 75 | }; 76 | -------------------------------------------------------------------------------- /web/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "weex-plugin--weex-plugin-amap", 3 | "version": "1.0.0", 4 | "platform": [ 5 | "web" 6 | ], 7 | "main": "./index.js", 8 | "description": "weex amap component", 9 | "keywords": [ 10 | "weex", 11 | "amap", 12 | "mapview" 13 | ], 14 | "license": "Apache 2.0" 15 | } -------------------------------------------------------------------------------- /web/service/components.js: -------------------------------------------------------------------------------- 1 | // manage components 2 | 3 | import amapManager from './map-manager'; 4 | import vendor from './vendor'; 5 | 6 | const components = { 7 | registerComponent(componentName, options, id, callback) { 8 | const opts = options || {}; 9 | if (!this._components) { 10 | this._components = {}; 11 | } 12 | amapManager.addReadyCallback((mapIns) => { 13 | opts.map = mapIns; 14 | // options.center = new AMap.LngLat(options.center[0],options.center[1]); 15 | const className = vendor.setFirstLetterToUppercase(componentName); 16 | if (opts.offset) { 17 | opts.offset = new AMap.Pixel(opts.offset[0], opts.offset[1]); 18 | } else { 19 | // this is a sdk bug polyfill 20 | opts.offset = new AMap.Pixel(0, 0); 21 | } 22 | this._components[id] = new AMap[className](opts); 23 | if (typeof callback === 'function') { 24 | callback(this._components[id], mapIns); 25 | } 26 | }); 27 | }, 28 | getComponent(id) { 29 | if (!this._components) { 30 | return null; 31 | } 32 | if (!id) { 33 | return vendor.getObjectFirstVal(this._components); 34 | } 35 | return this._components[id]; 36 | }, 37 | getComponentMap() { 38 | return amapManager.getMap(); 39 | } 40 | }; 41 | 42 | module.exports = components; 43 | -------------------------------------------------------------------------------- /web/service/map-loader.js: -------------------------------------------------------------------------------- 1 | // load map sdk 2 | const DEFAULT_CONFIG = { 3 | key: '', 4 | v: '1.3', 5 | url: 'https://webapi.amap.com/maps', 6 | callback: 'amapInitComponent' 7 | }; 8 | const gengerateScriptUrl = function (obj) { 9 | const paramArr = []; 10 | for (const key in obj) { 11 | if (key !== 'url') { 12 | paramArr.push(encodeURI(key + '=' + obj[key])); 13 | } 14 | } 15 | const url = obj.url += '?' + paramArr.join('&'); 16 | return url; 17 | }; 18 | 19 | module.exports = { 20 | load(config, container, callback) { 21 | const newConfig = Object.assign({}, DEFAULT_CONFIG, config); 22 | const lib = document.createElement('script'); 23 | lib.async = true; 24 | lib.defer = true; 25 | lib.src = gengerateScriptUrl(newConfig); 26 | console.log(lib.src); 27 | window.amapInitComponent = function () { 28 | window.maploaded = true; 29 | callback(); 30 | }; 31 | document.head.appendChild(lib); 32 | this.loadTimeout(container); 33 | }, 34 | loadTimeout(wrap) { 35 | setTimeout(() => { 36 | if (!window.Amap) { 37 | const el = document.createElement('button'); 38 | el.appendChild(document.createTextNode('重新加载')); 39 | el.addEventListener('click', () => { 40 | location.reload(); 41 | }); 42 | wrap.childNodes[0].remove(); 43 | wrap.appendChild(el); 44 | } 45 | }, 10000); 46 | } 47 | 48 | }; 49 | -------------------------------------------------------------------------------- /web/service/map-manager.js: -------------------------------------------------------------------------------- 1 | /** map instance manager 2 | * 20170204 3 | **/ 4 | let callbackStack = []; 5 | module.exports = { 6 | initMap(id, map) { 7 | if (!this.__maps) { 8 | this.__maps = {}; 9 | } 10 | this.__maps[id] = map; 11 | callbackStack.forEach((cb) => { 12 | cb(map); 13 | }); 14 | callbackStack = []; 15 | }, 16 | getMap(id) { 17 | if (!this.__maps) { 18 | return null; 19 | } 20 | if (!id) { 21 | id = Object.keys(this.__maps)[0]; 22 | } 23 | return this.__maps[id]; 24 | }, 25 | addReadyCallback(callback) { 26 | callbackStack.push(callback); 27 | } 28 | }; 29 | -------------------------------------------------------------------------------- /web/service/marker.js: -------------------------------------------------------------------------------- 1 | // a lib to manage all marker 2 | import amapManager from './map-manager'; 3 | import vendor from './vendor'; 4 | 5 | const markers = {}; 6 | module.exports = { 7 | changeMarker(arr, map) { 8 | for (let i = 0; i < arr.length; i++) { 9 | const data = arr[i]; 10 | const marker = this.findMarker(data); 11 | if (!marker) { 12 | this.addMarker(data, map); 13 | } else { 14 | this.removeMarker(data); 15 | } 16 | } 17 | }, 18 | addMarker(data) { 19 | const map = amapManager.getMap(); 20 | if (!map) { 21 | return amapManager.addReadyCallback((mapIns) => { 22 | this.setMarker(data, mapIns); 23 | }); 24 | } 25 | return this.setMarker(data, map); 26 | }, 27 | setMarker(data, map) { 28 | let icon = null; 29 | if (data.icon) { 30 | icon = new AMap.Icon({ 31 | image: data.icon, 32 | size: new AMap.Size(64, 64) 33 | }); 34 | } 35 | const marker = new AMap.Marker({ 36 | position: data.position, 37 | title: data.title, 38 | icon: icon, 39 | map: map, 40 | }); 41 | markers[this.__getMid(data)] = marker; 42 | this.registerEvents(data.events, marker); 43 | }, 44 | removeMaker(data) { 45 | const marker = this.findMarker(data); 46 | marker.setMap(null); 47 | }, 48 | updateMarker(data, attr, val) { 49 | const marker = this.findMarker(data); 50 | if (!marker) { 51 | return false; 52 | } 53 | const method = vendor.setFirstLetterToUppercase(attr); 54 | marker['set' + method](val); 55 | }, 56 | registerEvents(events, marker) { 57 | if (typeof events === 'object') { 58 | for (const key in events) { 59 | AMap.event.addListener(marker, key, events[key]); 60 | } 61 | } 62 | }, 63 | removeMarker(data) { 64 | let marker = this.findMarker(data); 65 | if (marker) { 66 | marker.visible = true; 67 | marker = null; 68 | } 69 | }, 70 | findMarker(data) { 71 | const mid = this.__getMid(data); 72 | return markers[mid]; 73 | }, 74 | __getMid(data) { 75 | return 'mid-' + data.ref || data.position.join('-'); 76 | }, 77 | __isMaker(obj) { 78 | return typeof obj === 'object' && obj.CLASS_NAME === 'AMap.Marker'; 79 | } 80 | }; 81 | -------------------------------------------------------------------------------- /web/service/vendor.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | gengerateRandomId(prefix) { 3 | return prefix + ((new Date()).getTime().toString().substring(9, 3)) + parseInt(Math.random() * 10000, 10); 4 | }, 5 | setFirstLetterToUppercase(str) { 6 | return str.substr(0, 1).toUpperCase() + str.substring(1); 7 | }, 8 | getObjectFirstVal(obj) { 9 | if(typeof obj === 'object') { 10 | return obj[Object.keys(obj)[0]] 11 | } 12 | return null; 13 | }, 14 | // offset polyfill 15 | calcOffset(x, y) { 16 | var halfY = y / 2; 17 | var newX = x - halfY; 18 | return [newX, y]; 19 | } 20 | }; 21 | --------------------------------------------------------------------------------