├── .circleci └── config.yml ├── .gitignore ├── .gitmodules ├── LICENSE ├── README.md ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── images └── Screenshots.png ├── settings.gradle └── tangramdemos ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src └── main ├── AndroidManifest.xml ├── java └── com │ └── mapzen │ └── tangramdemos │ ├── CachingHttpHandler.java │ ├── DemoDetails.java │ ├── DemoMainActivity.java │ ├── FeaturePickingActivity.java │ ├── MapGesturesActivity.java │ ├── MapMovementActivity.java │ ├── MarkersActivity.java │ ├── MultiMapActivity.java │ ├── SceneUpdatesActivity.java │ ├── SimpleMapActivity.java │ ├── TranslucentMapActivity.java │ └── ViewPaddingActivity.java └── res ├── drawable-v24 └── ic_launcher_foreground.xml ├── drawable ├── ic_launcher_background.xml └── mapzen_logo.png ├── layout ├── activity_featurepicking.xml ├── activity_main.xml ├── activity_mapgestures.xml ├── activity_mapmovement.xml ├── activity_markers.xml ├── activity_multimap.xml ├── activity_sceneupdates.xml ├── activity_simplemap.xml ├── activity_translucency.xml ├── activity_viewpadding.xml └── list_item.xml ├── mipmap-anydpi-v26 ├── ic_launcher.xml └── ic_launcher_round.xml ├── mipmap-hdpi ├── ic_launcher.png └── ic_launcher_round.png ├── mipmap-mdpi ├── ic_launcher.png └── ic_launcher_round.png ├── mipmap-xhdpi ├── ic_launcher.png └── ic_launcher_round.png ├── mipmap-xxhdpi ├── ic_launcher.png └── ic_launcher_round.png ├── mipmap-xxxhdpi ├── ic_launcher.png └── ic_launcher_round.png ├── values-night └── themes.xml └── values ├── colors.xml ├── strings.xml └── themes.xml /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | jobs: 3 | build: 4 | docker: 5 | - image: circleci/android:api-29 6 | environment: 7 | GRADLE_OPTS: -Xmx2048m 8 | steps: 9 | - checkout 10 | - run: git submodule update --init 11 | - run: ./gradlew assembleDebug 12 | workflows: 13 | version: 2 14 | build-samples: 15 | jobs: 16 | # Run on all pushes 17 | - build 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | 15 | # Gradle files 16 | .gradle/ 17 | build/ 18 | 19 | # Local configuration file (sdk path, etc) 20 | local.properties 21 | 22 | # Proguard folder generated by Eclipse 23 | proguard/ 24 | 25 | # Log Files 26 | *.log 27 | 28 | # Android Studio Navigation editor temp files 29 | .navigation/ 30 | 31 | # Android Studio captures folder 32 | captures/ 33 | 34 | # Intellij 35 | *.iml 36 | .idea/ 37 | 38 | # Ignore Gradle GUI config 39 | gradle-app.setting 40 | 41 | # macOS 42 | .DS_Store 43 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "styles/bubble-wrap"] 2 | path = styles/bubble-wrap 3 | url = https://github.com/tangrams/bubble-wrap.git 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Tangram 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # tangram-android-demos 2 | 3 | [![CircleCI](https://circleci.com/gh/tangrams/tangram-android-demos.svg?style=svg)](https://circleci.com/gh/tangrams/tangram-android-demos) 4 | 5 | Application showcasing features of the Tangram Android SDK 6 | 7 | ![screenshots](images/Screenshots.png) 8 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | google() 6 | mavenCentral() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:4.1.3' 10 | 11 | classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' 12 | 13 | // NOTE: Do not place your application dependencies here; they belong 14 | // in the individual module build.gradle files 15 | } 16 | } 17 | 18 | allprojects { 19 | repositories { 20 | google() 21 | mavenCentral() 22 | maven { url "https://oss.jfrog.org/artifactory/oss-snapshot-local/" } 23 | } 24 | } 25 | 26 | task clean(type: Delete) { 27 | delete rootProject.buildDir 28 | } 29 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | android.enableJetifier=true 20 | android.useAndroidX=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tangrams/tangram-android-demos/e0a49058ce168033ec9c1171d1671ba7de8b2e45/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 14 18:27:44 EST 2020 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-6.5-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /images/Screenshots.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tangrams/tangram-android-demos/e0a49058ce168033ec9c1171d1671ba7de8b2e45/images/Screenshots.png -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':tangramdemos' 2 | 3 | // Reference to local project, for testing changes that have not been published yet. 4 | //include ':tangram-dev' 5 | //project(':tangram-dev').projectDir = new File(settingsDir, '../tangram-es/platforms/android/tangram') 6 | -------------------------------------------------------------------------------- /tangramdemos/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /tangramdemos/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.application' 3 | } 4 | 5 | android { 6 | compileSdkVersion 30 7 | 8 | def apiKey = project.hasProperty('nextzenApiKey') ? nextzenApiKey : System.getenv('NEXTZEN_API_KEY') 9 | 10 | defaultConfig { 11 | applicationId "com.mapzen.tangramdemos" 12 | minSdkVersion 21 13 | targetSdkVersion 30 14 | versionCode 1 15 | versionName "1.0" 16 | buildConfigField 'String', 'NEXTZEN_API_KEY', '"' + apiKey + '"' 17 | } 18 | 19 | buildTypes { 20 | release { 21 | minifyEnabled false 22 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 23 | } 24 | } 25 | 26 | sourceSets.main.assets.srcDirs = ['../styles'] 27 | 28 | compileOptions { 29 | sourceCompatibility JavaVersion.VERSION_1_8 30 | targetCompatibility JavaVersion.VERSION_1_8 31 | } 32 | } 33 | 34 | dependencies { 35 | 36 | implementation 'androidx.appcompat:appcompat:1.2.0' 37 | implementation 'com.google.android.material:material:1.3.0' 38 | implementation 'com.mapzen.tangram:tangram:0.17.0' 39 | //implementation project(path: ':tangram-dev') 40 | } -------------------------------------------------------------------------------- /tangramdemos/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /tangramdemos/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 24 | 29 | 34 | 39 | 44 | 49 | 54 | 59 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /tangramdemos/src/main/java/com/mapzen/tangramdemos/CachingHttpHandler.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.tangramdemos; 2 | 3 | import com.mapzen.tangram.networking.DefaultHttpHandler; 4 | 5 | import java.io.File; 6 | import java.util.concurrent.TimeUnit; 7 | 8 | import okhttp3.Cache; 9 | import okhttp3.CacheControl; 10 | import okhttp3.HttpUrl; 11 | import okhttp3.OkHttpClient; 12 | import okhttp3.Request; 13 | 14 | public class CachingHttpHandler extends DefaultHttpHandler { 15 | 16 | private static final int maxCacheSize = 32 * 1024 * 1024; // 32 MB 17 | private static final int maxDaysStale = 7; 18 | private static final String cachedHostName = "tile.nextzen.com"; 19 | 20 | private final CacheControl tileCacheControl = new CacheControl.Builder().maxStale(maxDaysStale, TimeUnit.DAYS).build(); 21 | 22 | private static OkHttpClient.Builder configureBuilder(File cacheDirectory) { 23 | OkHttpClient.Builder builder = getClientBuilder(); 24 | if (cacheDirectory != null && cacheDirectory.exists()) { 25 | builder.cache(new Cache(cacheDirectory, maxCacheSize)); 26 | } 27 | return builder; 28 | } 29 | 30 | public CachingHttpHandler(File cacheDirectory) { 31 | super(configureBuilder(cacheDirectory)); 32 | } 33 | 34 | @Override 35 | protected void configureRequest(HttpUrl url, Request.Builder builder) { 36 | if (cachedHostName.equals(url.host())) { 37 | builder.cacheControl(tileCacheControl); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /tangramdemos/src/main/java/com/mapzen/tangramdemos/DemoDetails.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.tangramdemos; 2 | 3 | import androidx.appcompat.app.AppCompatActivity; 4 | 5 | public class DemoDetails { 6 | 7 | private final int titleId; 8 | 9 | private final int detailId; 10 | 11 | private final Class activityClass; 12 | 13 | /** 14 | * Create object to represent a demoable component of the sdk. 15 | * 16 | * @param titleId title of demo 17 | * @param detailId details about demo 18 | * @param activityClass activity to launch when this list item is clicked 19 | */ 20 | public DemoDetails(int titleId, int detailId, Class activityClass) { 21 | this.titleId = titleId; 22 | this.detailId = detailId; 23 | this.activityClass = activityClass; 24 | } 25 | 26 | /** 27 | * Resource id for title string. 28 | */ 29 | public int getTitleId() { 30 | return titleId; 31 | } 32 | 33 | /** 34 | * Resource id for detail string. 35 | */ 36 | public int getDetailId() { 37 | return detailId; 38 | } 39 | 40 | /** 41 | * Activity class to launch when this demo item is selected from list. 42 | */ 43 | public Class getActivityClass() { 44 | return activityClass; 45 | } 46 | 47 | public static final DemoDetails[] LIST = { 48 | new DemoDetails(R.string.simplemap_title, R.string.simplemap_detail, SimpleMapActivity.class), 49 | new DemoDetails(R.string.featurepicking_title, R.string.featurepicking_detail, FeaturePickingActivity.class), 50 | new DemoDetails(R.string.mapgestures_title, R.string.mapgestures_detail, MapGesturesActivity.class), 51 | new DemoDetails(R.string.mapmovement_title, R.string.mapmovement_detail, MapMovementActivity.class), 52 | new DemoDetails(R.string.markers_title, R.string.markers_detail, MarkersActivity.class), 53 | new DemoDetails(R.string.multimap_title, R.string.multimap_detail, MultiMapActivity.class), 54 | new DemoDetails(R.string.sceneupdates_title, R.string.sceneupdates_detail, SceneUpdatesActivity.class), 55 | new DemoDetails(R.string.translucency_title, R.string.translucency_detail, TranslucentMapActivity.class), 56 | new DemoDetails(R.string.viewpadding_title, R.string.viewpadding_detail, ViewPaddingActivity.class), 57 | }; 58 | } 59 | -------------------------------------------------------------------------------- /tangramdemos/src/main/java/com/mapzen/tangramdemos/DemoMainActivity.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.tangramdemos; 2 | 3 | import androidx.annotation.NonNull; 4 | import androidx.appcompat.app.AppCompatActivity; 5 | import androidx.recyclerview.widget.LinearLayoutManager; 6 | import androidx.recyclerview.widget.RecyclerView; 7 | 8 | import android.content.Intent; 9 | import android.os.Bundle; 10 | import android.view.LayoutInflater; 11 | import android.view.View; 12 | import android.view.ViewGroup; 13 | import android.widget.TextView; 14 | 15 | public class DemoMainActivity extends AppCompatActivity { 16 | 17 | View.OnClickListener onClickListener = v -> { 18 | ViewHolder viewHolder = (ViewHolder) v.getTag(); 19 | startActivity(new Intent(DemoMainActivity.this, viewHolder.activityClass)); 20 | }; 21 | 22 | @Override 23 | protected void onCreate(Bundle savedInstanceState) { 24 | super.onCreate(savedInstanceState); 25 | setContentView(R.layout.activity_main); 26 | 27 | configureListView(); 28 | } 29 | 30 | private static class ViewHolder extends RecyclerView.ViewHolder { 31 | TextView title; 32 | TextView description; 33 | Class activityClass; 34 | 35 | ViewHolder(View view) { 36 | super(view); 37 | title = view.findViewById(R.id.title); 38 | description = view.findViewById(R.id.description); 39 | } 40 | } 41 | 42 | private void configureListView() { 43 | RecyclerView listView = findViewById(R.id.list_view); 44 | listView.setLayoutManager(new LinearLayoutManager(this)); 45 | listView.setAdapter(new RecyclerView.Adapter() { 46 | @Override 47 | public int getItemCount() { 48 | return DemoDetails.LIST.length; 49 | } 50 | 51 | @NonNull 52 | @Override 53 | public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { 54 | View view = LayoutInflater.from(DemoMainActivity.this).inflate(R.layout.list_item, parent, false); 55 | ViewHolder viewHolder = new ViewHolder(view); 56 | view.setTag(viewHolder); 57 | view.setOnClickListener(onClickListener); 58 | return viewHolder; 59 | } 60 | 61 | @Override 62 | public void onBindViewHolder(@NonNull ViewHolder holder, int position) { 63 | DemoDetails demo = DemoDetails.LIST[position]; 64 | holder.title.setText(demo.getTitleId()); 65 | holder.description.setText(demo.getDetailId()); 66 | holder.activityClass = demo.getActivityClass(); 67 | } 68 | }); 69 | } 70 | } -------------------------------------------------------------------------------- /tangramdemos/src/main/java/com/mapzen/tangramdemos/FeaturePickingActivity.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.tangramdemos; 2 | 3 | import android.os.Bundle; 4 | import android.widget.TextView; 5 | 6 | import androidx.annotation.Nullable; 7 | import androidx.appcompat.app.ActionBar; 8 | import androidx.appcompat.app.AppCompatActivity; 9 | 10 | import com.mapzen.tangram.FeaturePickListener; 11 | import com.mapzen.tangram.FeaturePickResult; 12 | import com.mapzen.tangram.MapController; 13 | import com.mapzen.tangram.MapView; 14 | import com.mapzen.tangram.SceneUpdate; 15 | import com.mapzen.tangram.TouchInput; 16 | import com.mapzen.tangram.networking.HttpHandler; 17 | 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | import java.util.Map; 21 | 22 | public class FeaturePickingActivity extends AppCompatActivity implements MapView.MapReadyCallback { 23 | 24 | MapController map; 25 | MapView view; 26 | TextView textWindow; 27 | 28 | @Override 29 | protected void onCreate(Bundle savedInstanceState) { 30 | super.onCreate(savedInstanceState); 31 | setContentView(R.layout.activity_featurepicking); 32 | 33 | // Set up back button to return to the demo list. 34 | ActionBar actionBar = getSupportActionBar(); 35 | if (actionBar != null) { 36 | actionBar.setDisplayHomeAsUpEnabled(true); 37 | } 38 | 39 | view = (MapView)findViewById(R.id.map); 40 | view.onCreate(savedInstanceState); 41 | view.getMapAsync(this, new CachingHttpHandler(getExternalCacheDir())); 42 | 43 | textWindow = (TextView)findViewById(R.id.textWindow); 44 | textWindow.setText("Tap an icon on the map."); 45 | } 46 | 47 | @Override 48 | public void onMapReady(MapController mapController) { 49 | map = mapController; 50 | 51 | // Set our API key as a scene update. 52 | List updates = new ArrayList<>(); 53 | updates.add(new SceneUpdate("global.sdk_api_key", BuildConfig.NEXTZEN_API_KEY)); 54 | 55 | // Customize bubble-wrap by importing the main scene file and then a theme to add more labels. 56 | String sceneYaml = "import: [ bubble-wrap/bubble-wrap-style.yaml, bubble-wrap/themes/label-10.yaml ]"; 57 | map.loadSceneYamlAsync(sceneYaml, "", updates); 58 | 59 | // Increase the radius for feature picking to make selecting labels easier. 60 | map.setPickRadius(10); 61 | 62 | map.setFeaturePickListener(new FeaturePickListener() { 63 | // A scene file can declare certain groups of features to be 'interactive', meaning that 64 | // they can be selected in a call to pickFeature(). If an 'interactive' feature is found 65 | // at the given position, its information is returned in onFeaturePick. If no 66 | // 'interactive' feature is found, onFeaturePick won't be called. 67 | @Override 68 | public void onFeaturePickComplete(@Nullable FeaturePickResult result) { 69 | if (result == null) 70 | { 71 | textWindow.setText("No pick result"); 72 | return; 73 | } 74 | 75 | // After a feature is picked from the map, we receive a map of 'properties' as 76 | // string keys and values, as well as the screen position of the feature's center. 77 | textWindow.setText("Selected feature properties:"); 78 | for (Map.Entry entry : result.getProperties().entrySet()) { 79 | textWindow.append("\n" + entry.getKey() + " : " + entry.getValue()); 80 | } 81 | } 82 | }); 83 | 84 | map.getTouchInput().setTapResponder(new TouchInput.TapResponder() { 85 | @Override 86 | public boolean onSingleTapUp(float x, float y) { 87 | return false; 88 | } 89 | 90 | @Override 91 | public boolean onSingleTapConfirmed(float x, float y) { 92 | map.pickFeature(x, y); 93 | return false; 94 | } 95 | }); 96 | } 97 | 98 | @Override 99 | public void onResume() { 100 | super.onResume(); 101 | view.onResume(); 102 | } 103 | 104 | @Override 105 | public void onPause() { 106 | super.onPause(); 107 | view.onPause(); 108 | } 109 | 110 | @Override 111 | public void onDestroy() { 112 | super.onDestroy(); 113 | view.onDestroy(); 114 | } 115 | 116 | @Override 117 | public void onLowMemory() { 118 | super.onLowMemory(); 119 | view.onLowMemory(); 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /tangramdemos/src/main/java/com/mapzen/tangramdemos/MapGesturesActivity.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.tangramdemos; 2 | 3 | import android.graphics.PointF; 4 | import android.os.Bundle; 5 | 6 | import androidx.appcompat.app.ActionBar; 7 | import androidx.appcompat.app.AppCompatActivity; 8 | 9 | import com.mapzen.tangram.CameraUpdateFactory; 10 | import com.mapzen.tangram.LngLat; 11 | import com.mapzen.tangram.MapController; 12 | import com.mapzen.tangram.MapView; 13 | import com.mapzen.tangram.SceneUpdate; 14 | import com.mapzen.tangram.TouchInput; 15 | 16 | import java.util.ArrayList; 17 | import java.util.List; 18 | 19 | public class MapGesturesActivity extends AppCompatActivity implements MapView.MapReadyCallback { 20 | 21 | MapController map; 22 | MapView view; 23 | 24 | @Override 25 | protected void onCreate(Bundle savedInstanceState) { 26 | super.onCreate(savedInstanceState); 27 | setContentView(R.layout.activity_mapgestures); 28 | 29 | // Set up back button to return to the demo list. 30 | ActionBar actionBar = getSupportActionBar(); 31 | if (actionBar != null) { 32 | actionBar.setDisplayHomeAsUpEnabled(true); 33 | } 34 | 35 | view = (MapView)findViewById(R.id.map); 36 | view.onCreate(savedInstanceState); 37 | view.getMapAsync(this, new CachingHttpHandler(getExternalCacheDir())); 38 | 39 | } 40 | 41 | @Override 42 | public void onMapReady(MapController mapController) { 43 | map = mapController; 44 | 45 | // Set our API key as a scene update. 46 | List updates = new ArrayList<>(); 47 | updates.add(new SceneUpdate("global.sdk_api_key", BuildConfig.NEXTZEN_API_KEY)); 48 | 49 | map.loadSceneFileAsync("bubble-wrap/bubble-wrap-style.yaml", updates); 50 | 51 | TouchInput touchInput = map.getTouchInput(); 52 | 53 | touchInput.setTapResponder(new TouchInput.TapResponder() { 54 | @Override 55 | public boolean onSingleTapUp(float x, float y) { 56 | LngLat point = map.screenPositionToLngLat(new PointF(x, y)); 57 | map.updateCameraPosition(CameraUpdateFactory.setPosition(point), 1000); 58 | return false; 59 | } 60 | 61 | @Override 62 | public boolean onSingleTapConfirmed(float x, float y) { 63 | return false; 64 | } 65 | }); 66 | 67 | touchInput.setPanResponder(new TouchInput.PanResponder() { 68 | @Override 69 | public boolean onPanBegin() { 70 | return false; 71 | } 72 | 73 | @Override 74 | public boolean onPan(float startX, float startY, float endX, float endY) { 75 | float rotate = (startX - endX) / 400; 76 | float tilt = (startY - endY) / 400; 77 | map.updateCameraPosition(CameraUpdateFactory.rotateBy(rotate)); 78 | map.updateCameraPosition(CameraUpdateFactory.tiltBy(tilt)); 79 | 80 | // Returning 'true' means that this gesture event is 'consumed' and won't be passed 81 | // on to any other handlers. We return 'true' here so that the map doesn't do the 82 | // built-in 'panning' behavior. 83 | return true; 84 | } 85 | 86 | @Override 87 | public boolean onPanEnd() { 88 | return false; 89 | } 90 | 91 | @Override 92 | public boolean onFling(float posX, float posY, float velocityX, float velocityY) { 93 | // We return 'true' here as well, otherwise a flinging gesture will make the map pan 94 | return true; 95 | } 96 | 97 | @Override 98 | public boolean onCancelFling() { 99 | return false; 100 | } 101 | }); 102 | 103 | // Disable built-int "shove" gesture to tilt. 104 | touchInput.setGestureDisabled(TouchInput.Gestures.SHOVE); 105 | 106 | } 107 | 108 | @Override 109 | public void onResume() { 110 | super.onResume(); 111 | view.onResume(); 112 | } 113 | 114 | @Override 115 | public void onPause() { 116 | super.onPause(); 117 | view.onPause(); 118 | } 119 | 120 | @Override 121 | public void onDestroy() { 122 | super.onDestroy(); 123 | view.onDestroy(); 124 | } 125 | 126 | @Override 127 | public void onLowMemory() { 128 | super.onLowMemory(); 129 | view.onLowMemory(); 130 | } 131 | 132 | } 133 | -------------------------------------------------------------------------------- /tangramdemos/src/main/java/com/mapzen/tangramdemos/MapMovementActivity.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.tangramdemos; 2 | 3 | import android.os.Bundle; 4 | import android.view.View; 5 | import android.widget.RadioButton; 6 | 7 | import androidx.appcompat.app.ActionBar; 8 | import androidx.appcompat.app.AppCompatActivity; 9 | 10 | import com.mapzen.tangram.CameraPosition; 11 | import com.mapzen.tangram.MapController; 12 | import com.mapzen.tangram.MapView; 13 | import com.mapzen.tangram.SceneUpdate; 14 | 15 | import java.util.ArrayList; 16 | import java.util.List; 17 | 18 | public class MapMovementActivity extends AppCompatActivity implements MapView.MapReadyCallback { 19 | 20 | MapController map; 21 | MapView view; 22 | 23 | // Just for this demo, we define an enum type called 'Landmark' that helps control the map view. 24 | public enum Landmark { 25 | WORLD_TRADE_CENTER(-74.012477, 40.712454, 16f, (float)Math.toRadians(45), (float)Math.toRadians(-15)), 26 | EMPIRE_STATE_BUILDING(-73.986431, 40.748275, 16f, (float)Math.toRadians(65.25), (float)Math.toRadians(85)), 27 | CENTRAL_PARK_ZOO(-73.963918, 40.779414, 14.75f, (float)Math.toRadians(36), (float)Math.toRadians(-36)), 28 | ; 29 | 30 | Landmark(double lng, double lat, float z, float t, float r) { 31 | camera = new CameraPosition(); 32 | camera.longitude = lng; 33 | camera.latitude = lat; 34 | camera.zoom = z; 35 | camera.tilt = t; 36 | camera.rotation = r; 37 | } 38 | 39 | CameraPosition camera; 40 | } 41 | 42 | @Override 43 | protected void onCreate(Bundle savedInstanceState) { 44 | super.onCreate(savedInstanceState); 45 | setContentView(R.layout.activity_mapmovement); 46 | 47 | // Set up back button to return to the demo list. 48 | ActionBar actionBar = getSupportActionBar(); 49 | if (actionBar != null) { 50 | actionBar.setDisplayHomeAsUpEnabled(true); 51 | } 52 | 53 | view = (MapView)findViewById(R.id.map); 54 | view.onCreate(savedInstanceState); 55 | view.getMapAsync(this, new CachingHttpHandler(getExternalCacheDir())); 56 | } 57 | 58 | @Override 59 | public void onMapReady(MapController mapController) { 60 | map = mapController; 61 | 62 | // Set our API key as a scene update. 63 | List updates = new ArrayList<>(); 64 | updates.add(new SceneUpdate("global.sdk_api_key", BuildConfig.NEXTZEN_API_KEY)); 65 | 66 | map.loadSceneFileAsync("bubble-wrap/bubble-wrap-style.yaml", updates); 67 | } 68 | 69 | public void onRadioButtonClicked(View view) { 70 | 71 | boolean checked = ((RadioButton) view).isChecked(); 72 | 73 | if (!checked) { 74 | return; 75 | } 76 | 77 | switch(view.getId()) { 78 | case R.id.radio_wtc: 79 | goToLandmark(Landmark.WORLD_TRADE_CENTER); 80 | break; 81 | case R.id.radio_esb: 82 | goToLandmark(Landmark.EMPIRE_STATE_BUILDING); 83 | break; 84 | case R.id.radio_cpz: 85 | goToLandmark(Landmark.CENTRAL_PARK_ZOO); 86 | break; 87 | } 88 | } 89 | 90 | public void goToLandmark(Landmark landmark) { 91 | 92 | if (map == null) { 93 | return; 94 | } 95 | 96 | int duration = 2000; // Milliseconds 97 | 98 | // We use the position, zoom, tilt, and rotation of the Landmark to move the camera over time. 99 | // Different types of "easing" are available to make the transition smoother or sharper. 100 | map.flyToCameraPosition(landmark.camera, duration, null); 101 | } 102 | 103 | @Override 104 | public void onResume() { 105 | super.onResume(); 106 | view.onResume(); 107 | } 108 | 109 | @Override 110 | public void onPause() { 111 | super.onPause(); 112 | view.onPause(); 113 | } 114 | 115 | @Override 116 | public void onDestroy() { 117 | super.onDestroy(); 118 | view.onDestroy(); 119 | } 120 | 121 | @Override 122 | public void onLowMemory() { 123 | super.onLowMemory(); 124 | view.onLowMemory(); 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /tangramdemos/src/main/java/com/mapzen/tangramdemos/MarkersActivity.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.tangramdemos; 2 | 3 | import android.graphics.PointF; 4 | import android.os.Bundle; 5 | import android.view.View; 6 | import android.widget.Button; 7 | import android.widget.RadioButton; 8 | 9 | import androidx.appcompat.app.ActionBar; 10 | import androidx.appcompat.app.AppCompatActivity; 11 | 12 | import com.mapzen.tangram.LngLat; 13 | import com.mapzen.tangram.MapController; 14 | import com.mapzen.tangram.MapView; 15 | import com.mapzen.tangram.Marker; 16 | import com.mapzen.tangram.SceneUpdate; 17 | import com.mapzen.tangram.TouchInput; 18 | import com.mapzen.tangram.geometry.Polygon; 19 | import com.mapzen.tangram.geometry.Polyline; 20 | 21 | import java.util.ArrayList; 22 | import java.util.List; 23 | 24 | public class MarkersActivity extends AppCompatActivity implements MapView.MapReadyCallback { 25 | 26 | MapController map; 27 | MapView view; 28 | 29 | Marker pointMarker; 30 | Marker lineMarker; 31 | Marker polygonMarker; 32 | 33 | String pointStyle = "{ style: 'points', color: 'white', size: [50px, 50px], order: 2000, collide: false }"; 34 | String lineStyle = "{ style: 'lines', color: '#06a6d4', width: 5px, order: 2000 }"; 35 | String polygonStyle = "{ style: 'polygons', color: '#06a6d4', width: 5px, order: 2000 }"; 36 | 37 | Marker current; 38 | 39 | Button clearButton; 40 | 41 | ArrayList taps = new ArrayList<>(); 42 | 43 | @Override 44 | protected void onCreate(Bundle savedInstanceState) { 45 | super.onCreate(savedInstanceState); 46 | setContentView(R.layout.activity_markers); 47 | 48 | // Set up back button to return to the demo list. 49 | ActionBar actionBar = getSupportActionBar(); 50 | if (actionBar != null) { 51 | actionBar.setDisplayHomeAsUpEnabled(true); 52 | } 53 | 54 | view = (MapView)findViewById(R.id.map); 55 | view.onCreate(savedInstanceState); 56 | view.getMapAsync(this, new CachingHttpHandler(getExternalCacheDir())); 57 | 58 | clearButton = (Button)findViewById(R.id.clear_button); 59 | } 60 | 61 | @Override 62 | public void onMapReady(MapController mapController) { 63 | map = mapController; 64 | 65 | // Set our API key as a scene update. 66 | List updates = new ArrayList<>(); 67 | updates.add(new SceneUpdate("global.sdk_api_key", BuildConfig.NEXTZEN_API_KEY)); 68 | 69 | map.loadSceneFileAsync("bubble-wrap/bubble-wrap-style.yaml", updates); 70 | 71 | resetMarkers(); 72 | 73 | clearButton.setOnClickListener(new View.OnClickListener() { 74 | @Override 75 | public void onClick(View v) { 76 | resetMarkers(); 77 | } 78 | }); 79 | 80 | map.getTouchInput().setTapResponder(new TouchInput.TapResponder() { 81 | @Override 82 | public boolean onSingleTapUp(float x, float y) { 83 | LngLat tap = map.screenPositionToLngLat(new PointF(x, y)); 84 | taps.add(tap); 85 | if (current == pointMarker) { 86 | pointMarker.setPoint(tap); 87 | taps.clear(); 88 | } else if (current == lineMarker && taps.size() >= 2) { 89 | lineMarker.setPolyline(new Polyline(taps, null)); 90 | taps.remove(0); 91 | } else if (current == polygonMarker && taps.size() >= 3) { 92 | ArrayList> polygon = new ArrayList<>(); 93 | polygon.add(taps); 94 | polygonMarker.setPolygon(new Polygon(polygon, null)); 95 | taps.remove(0); 96 | } 97 | map.requestRender(); 98 | return false; 99 | } 100 | 101 | @Override 102 | public boolean onSingleTapConfirmed(float x, float y) { 103 | return false; 104 | } 105 | }); 106 | } 107 | 108 | void resetMarkers() { 109 | map.removeAllMarkers(); 110 | pointMarker = null; 111 | lineMarker = null; 112 | polygonMarker = null; 113 | 114 | pointMarker = map.addMarker(); 115 | pointMarker.setStylingFromString(pointStyle); 116 | pointMarker.setDrawable(R.drawable.mapzen_logo); 117 | 118 | lineMarker = map.addMarker(); 119 | lineMarker.setStylingFromString(lineStyle); 120 | 121 | polygonMarker = map.addMarker(); 122 | polygonMarker.setStylingFromString(polygonStyle); 123 | } 124 | 125 | public void onRadioButtonClicked(View view) { 126 | 127 | boolean checked = ((RadioButton) view).isChecked(); 128 | 129 | if (!checked) { 130 | return; 131 | } 132 | 133 | taps.clear(); 134 | 135 | switch(view.getId()) { 136 | case R.id.radio_points: 137 | current = pointMarker; 138 | break; 139 | case R.id.radio_lines: 140 | current = lineMarker; 141 | break; 142 | case R.id.radio_polygons: 143 | current = polygonMarker; 144 | break; 145 | } 146 | } 147 | 148 | @Override 149 | public void onResume() { 150 | super.onResume(); 151 | view.onResume(); 152 | } 153 | 154 | @Override 155 | public void onPause() { 156 | super.onPause(); 157 | view.onPause(); 158 | } 159 | 160 | @Override 161 | public void onDestroy() { 162 | super.onDestroy(); 163 | view.onDestroy(); 164 | } 165 | 166 | @Override 167 | public void onLowMemory() { 168 | super.onLowMemory(); 169 | view.onLowMemory(); 170 | } 171 | } 172 | -------------------------------------------------------------------------------- /tangramdemos/src/main/java/com/mapzen/tangramdemos/MultiMapActivity.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.tangramdemos; 2 | 3 | import android.os.Bundle; 4 | 5 | import androidx.annotation.Nullable; 6 | import androidx.appcompat.app.ActionBar; 7 | import androidx.appcompat.app.AppCompatActivity; 8 | 9 | import com.mapzen.tangram.MapController; 10 | import com.mapzen.tangram.MapView; 11 | import com.mapzen.tangram.SceneUpdate; 12 | import com.mapzen.tangram.TouchInput; 13 | import com.mapzen.tangram.networking.HttpHandler; 14 | 15 | import java.util.ArrayList; 16 | import java.util.List; 17 | 18 | public class MultiMapActivity extends AppCompatActivity implements TouchInput.RotateResponder { 19 | 20 | // MapController is the main class used to interact with a Tangram map. 21 | MapController mapTop; 22 | MapController mapBottom; 23 | 24 | // MapView is the View used to display the map. 25 | MapView viewTop; 26 | MapView viewBottom; 27 | 28 | @Override 29 | protected void onCreate(Bundle savedInstanceState) { 30 | super.onCreate(savedInstanceState); 31 | setContentView(R.layout.activity_multimap); 32 | 33 | // Set up back button to return to the demo list. 34 | ActionBar actionBar = getSupportActionBar(); 35 | if (actionBar != null) { 36 | actionBar.setDisplayHomeAsUpEnabled(true); 37 | } 38 | 39 | // Our MapView is declared in the layout file. 40 | viewTop = (MapView)findViewById(R.id.map_top); 41 | viewBottom = (MapView)findViewById(R.id.map_bottom); 42 | 43 | // Lifecycle events from the Activity must be forwarded to the MapView. 44 | viewTop.onCreate(savedInstanceState); 45 | viewBottom.onCreate(savedInstanceState); 46 | 47 | // Create an HttpHandler to cache map tiles. 48 | HttpHandler httpHandler = new CachingHttpHandler(getExternalCacheDir()); 49 | 50 | // This starts a background process to set up the map. 51 | viewTop.getMapAsync(new MapView.MapReadyCallback() { 52 | @Override 53 | public void onMapReady(@Nullable MapController mapController) { 54 | mapTop = mapController; 55 | MultiMapActivity.this.onMapReady(mapController); 56 | } 57 | }, httpHandler); 58 | viewBottom.getMapAsync(new MapView.MapReadyCallback() { 59 | @Override 60 | public void onMapReady(@Nullable MapController mapController) { 61 | mapBottom = mapController; 62 | MultiMapActivity.this.onMapReady(mapController); 63 | } 64 | }, httpHandler); 65 | } 66 | 67 | public void onMapReady(MapController mapController) { 68 | // Set our API key as a scene update. 69 | List updates = new ArrayList<>(); 70 | updates.add(new SceneUpdate("global.sdk_api_key", BuildConfig.NEXTZEN_API_KEY)); 71 | 72 | //mapController.getTouchInput().setRotateResponder(this); 73 | 74 | mapController.loadSceneFileAsync("bubble-wrap/bubble-wrap-style.yaml", updates); 75 | } 76 | 77 | // Below are the remaining Activity lifecycle events that must be forwarded to our MapView. 78 | 79 | @Override 80 | public void onResume() { 81 | super.onResume(); 82 | viewTop.onResume(); 83 | viewBottom.onResume(); 84 | } 85 | 86 | @Override 87 | public void onPause() { 88 | super.onPause(); 89 | viewTop.onPause(); 90 | viewBottom.onPause(); 91 | } 92 | 93 | @Override 94 | public void onDestroy() { 95 | super.onDestroy(); 96 | viewTop.onDestroy(); 97 | viewBottom.onDestroy(); 98 | } 99 | 100 | @Override 101 | public void onLowMemory() { 102 | super.onLowMemory(); 103 | viewTop.onLowMemory(); 104 | viewBottom.onLowMemory(); 105 | } 106 | 107 | /** 108 | * Called when a Rotation Gesture begins 109 | * 110 | * @return True if the event is consumed, false if the event should continue to propagate 111 | */ 112 | @Override 113 | public boolean onRotateBegin() { 114 | return false; 115 | } 116 | 117 | /** 118 | * Called repeatedly while two touch points are rotated around a point 119 | * 120 | * @param x The x screen coordinate of the center of rotation 121 | * @param y The y screen coordinate of the center of rotation 122 | * @param rotation The change in rotation of the touch points relative to the previous 123 | * rotation event, in counter-clockwise radians 124 | * @return True if the event is consumed, false if the event should continue to propagate 125 | */ 126 | @Override 127 | public boolean onRotate(float x, float y, float rotation) { 128 | return false; 129 | } 130 | 131 | /** 132 | * Called when Rotation Gesture ends 133 | * 134 | * @return True if the event is consumed, false if the event should continue to propagate 135 | */ 136 | @Override 137 | public boolean onRotateEnd() { 138 | return false; 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /tangramdemos/src/main/java/com/mapzen/tangramdemos/SceneUpdatesActivity.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.tangramdemos; 2 | 3 | import android.os.Bundle; 4 | import android.view.View; 5 | import android.widget.CheckBox; 6 | 7 | import androidx.appcompat.app.ActionBar; 8 | import androidx.appcompat.app.AppCompatActivity; 9 | 10 | import com.mapzen.tangram.MapController; 11 | import com.mapzen.tangram.MapView; 12 | import com.mapzen.tangram.SceneUpdate; 13 | 14 | import java.util.ArrayList; 15 | import java.util.Arrays; 16 | import java.util.List; 17 | 18 | public class SceneUpdatesActivity extends AppCompatActivity implements MapView.MapReadyCallback { 19 | 20 | MapController map; 21 | MapView view; 22 | 23 | SceneUpdate apiKeySceneUpdate = new SceneUpdate("global.sdk_api_key", BuildConfig.NEXTZEN_API_KEY); 24 | String sceneFilePath = "bubble-wrap/bubble-wrap-style.yaml"; 25 | 26 | @Override 27 | protected void onCreate(Bundle savedInstanceState) { 28 | super.onCreate(savedInstanceState); 29 | setContentView(R.layout.activity_sceneupdates); 30 | 31 | // Set up back button to return to the demo list. 32 | ActionBar actionBar = getSupportActionBar(); 33 | if (actionBar != null) { 34 | actionBar.setDisplayHomeAsUpEnabled(true); 35 | } 36 | 37 | view = (MapView)findViewById(R.id.map); 38 | view.onCreate(savedInstanceState); 39 | view.getMapAsync(this, new CachingHttpHandler(getExternalCacheDir())); 40 | 41 | } 42 | 43 | public void onCheckBoxClicked(View view) { 44 | CheckBox checkbox = (CheckBox)view; 45 | String visible = checkbox.isChecked() ? "true" : "false"; 46 | String name = (String)checkbox.getText(); 47 | 48 | if (map == null) { 49 | return; 50 | } 51 | 52 | // Scene updates are written to match the structure of the scene file. 53 | // Our check boxes have the same names as layers in our scene, so we'll use the names to 54 | // turn layers on and off individually using the 'visible' property. 55 | updateScene(new SceneUpdate("layers." + name + ".visible", visible)); 56 | } 57 | 58 | private void updateScene(SceneUpdate... updates) { 59 | List updateList = new ArrayList<>(Arrays.asList(updates)); 60 | 61 | // Always apply the API key to the scene as an update. 62 | updateList.add(apiKeySceneUpdate); 63 | 64 | map.loadSceneFileAsync(sceneFilePath, updateList); 65 | } 66 | 67 | @Override 68 | public void onMapReady(MapController mapController) { 69 | map = mapController; 70 | 71 | updateScene(); 72 | } 73 | 74 | @Override 75 | public void onResume() { 76 | super.onResume(); 77 | view.onResume(); 78 | } 79 | 80 | @Override 81 | public void onPause() { 82 | super.onPause(); 83 | view.onPause(); 84 | } 85 | 86 | @Override 87 | public void onDestroy() { 88 | super.onDestroy(); 89 | view.onDestroy(); 90 | } 91 | 92 | @Override 93 | public void onLowMemory() { 94 | super.onLowMemory(); 95 | view.onLowMemory(); 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /tangramdemos/src/main/java/com/mapzen/tangramdemos/SimpleMapActivity.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.tangramdemos; 2 | 3 | import android.os.Bundle; 4 | 5 | import androidx.appcompat.app.ActionBar; 6 | import androidx.appcompat.app.AppCompatActivity; 7 | 8 | import com.mapzen.tangram.MapController; 9 | import com.mapzen.tangram.MapView; 10 | import com.mapzen.tangram.SceneUpdate; 11 | import com.mapzen.tangram.networking.HttpHandler; 12 | 13 | import java.util.ArrayList; 14 | import java.util.List; 15 | 16 | public class SimpleMapActivity extends AppCompatActivity implements MapView.MapReadyCallback { 17 | 18 | // MapController is the main class used to interact with a Tangram map. 19 | MapController map; 20 | 21 | // MapView is the View used to display the map. 22 | MapView view; 23 | 24 | @Override 25 | protected void onCreate(Bundle savedInstanceState) { 26 | super.onCreate(savedInstanceState); 27 | setContentView(R.layout.activity_simplemap); 28 | 29 | // Set up back button to return to the demo list. 30 | ActionBar actionBar = getSupportActionBar(); 31 | if (actionBar != null) { 32 | actionBar.setDisplayHomeAsUpEnabled(true); 33 | } 34 | 35 | // Our MapView is declared in the layout file. 36 | view = (MapView)findViewById(R.id.map); 37 | 38 | // Lifecycle events from the Activity must be forwarded to the MapView. 39 | view.onCreate(savedInstanceState); 40 | 41 | // Create an HttpHandler to cache map tiles. 42 | HttpHandler httpHandler = new CachingHttpHandler(getExternalCacheDir()); 43 | 44 | // This starts a background process to set up the map. 45 | view.getMapAsync(this, httpHandler); 46 | } 47 | 48 | @Override 49 | public void onMapReady(MapController mapController) { 50 | // We receive a MapController object in this callback when the map is ready for use. 51 | map = mapController; 52 | 53 | // Set our API key as a scene update. 54 | List updates = new ArrayList<>(); 55 | updates.add(new SceneUpdate("global.sdk_api_key", BuildConfig.NEXTZEN_API_KEY)); 56 | 57 | map.loadSceneFileAsync("bubble-wrap/bubble-wrap-style.yaml", updates); 58 | } 59 | 60 | // Below are the remaining Activity lifecycle events that must be forwarded to our MapView. 61 | 62 | @Override 63 | public void onResume() { 64 | super.onResume(); 65 | view.onResume(); 66 | } 67 | 68 | @Override 69 | public void onPause() { 70 | super.onPause(); 71 | view.onPause(); 72 | } 73 | 74 | @Override 75 | public void onDestroy() { 76 | super.onDestroy(); 77 | view.onDestroy(); 78 | } 79 | 80 | @Override 81 | public void onLowMemory() { 82 | super.onLowMemory(); 83 | view.onLowMemory(); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /tangramdemos/src/main/java/com/mapzen/tangramdemos/TranslucentMapActivity.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.tangramdemos; 2 | 3 | import android.os.Bundle; 4 | import android.widget.ImageView; 5 | 6 | import androidx.appcompat.app.ActionBar; 7 | import androidx.appcompat.app.AppCompatActivity; 8 | 9 | import com.mapzen.tangram.MapController; 10 | import com.mapzen.tangram.MapView; 11 | import com.mapzen.tangram.SceneUpdate; 12 | import com.mapzen.tangram.networking.HttpHandler; 13 | import com.mapzen.tangram.viewholder.GLViewHolderFactory; 14 | import com.mapzen.tangram.viewholder.TextureViewHolderFactory; 15 | 16 | import java.util.ArrayList; 17 | import java.util.List; 18 | 19 | public class TranslucentMapActivity extends AppCompatActivity implements MapView.MapReadyCallback { 20 | 21 | // MapController is the main class used to interact with a Tangram map. 22 | MapController map; 23 | 24 | // MapView is the View used to display the map. 25 | MapView view; 26 | 27 | @Override 28 | protected void onCreate(Bundle savedInstanceState) { 29 | super.onCreate(savedInstanceState); 30 | setContentView(R.layout.activity_translucency); 31 | 32 | // Set up back button to return to the demo list. 33 | ActionBar actionBar = getSupportActionBar(); 34 | if (actionBar != null) { 35 | actionBar.setDisplayHomeAsUpEnabled(true); 36 | } 37 | 38 | // Our MapView is declared in the layout file. 39 | view = (MapView)findViewById(R.id.map); 40 | 41 | // Lifecycle events from the Activity must be forwarded to the MapView. 42 | view.onCreate(savedInstanceState); 43 | 44 | // Create an HttpHandler to cache map tiles. 45 | HttpHandler httpHandler = new CachingHttpHandler(getExternalCacheDir()); 46 | 47 | // Create a factory to build a TextureView with translucency enabled. 48 | GLViewHolderFactory factory = new TextureViewHolderFactory(true); 49 | 50 | // Start a background process to set up the map. 51 | view.getMapAsync(this, factory, httpHandler); 52 | } 53 | 54 | @Override 55 | public void onMapReady(MapController mapController) { 56 | // We receive a MapController object in this callback when the map is ready for use. 57 | map = mapController; 58 | 59 | // Set our API key as a scene update. 60 | List updates = new ArrayList<>(); 61 | updates.add(new SceneUpdate("global.sdk_api_key", BuildConfig.NEXTZEN_API_KEY)); 62 | 63 | // Update the scene background color to be translucent. 64 | updates.add(new SceneUpdate("scene.background.color", "[0, 0, 0, 0]")); 65 | 66 | map.loadSceneFileAsync("bubble-wrap/bubble-wrap-style.yaml", updates); 67 | } 68 | 69 | // Below are the remaining Activity lifecycle events that must be forwarded to our MapView. 70 | 71 | @Override 72 | public void onResume() { 73 | super.onResume(); 74 | view.onResume(); 75 | } 76 | 77 | @Override 78 | public void onPause() { 79 | super.onPause(); 80 | view.onPause(); 81 | } 82 | 83 | @Override 84 | public void onDestroy() { 85 | super.onDestroy(); 86 | view.onDestroy(); 87 | } 88 | 89 | @Override 90 | public void onLowMemory() { 91 | super.onLowMemory(); 92 | view.onLowMemory(); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /tangramdemos/src/main/java/com/mapzen/tangramdemos/ViewPaddingActivity.java: -------------------------------------------------------------------------------- 1 | package com.mapzen.tangramdemos; 2 | 3 | import android.os.Bundle; 4 | import android.widget.CheckBox; 5 | 6 | import androidx.appcompat.app.ActionBar; 7 | import androidx.appcompat.app.AppCompatActivity; 8 | 9 | import com.mapzen.tangram.EdgePadding; 10 | import com.mapzen.tangram.MapController; 11 | import com.mapzen.tangram.MapView; 12 | import com.mapzen.tangram.SceneUpdate; 13 | import com.mapzen.tangram.networking.HttpHandler; 14 | 15 | import java.util.ArrayList; 16 | import java.util.List; 17 | 18 | public class ViewPaddingActivity extends AppCompatActivity implements MapView.MapReadyCallback { 19 | 20 | // MapController is the main class used to interact with a Tangram map. 21 | MapController map; 22 | 23 | // MapView is the View used to display the map. 24 | MapView view; 25 | 26 | EdgePadding padding; 27 | 28 | @Override 29 | protected void onCreate(Bundle savedInstanceState) { 30 | super.onCreate(savedInstanceState); 31 | setContentView(R.layout.activity_viewpadding); 32 | 33 | // Set up back button to return to the demo list. 34 | ActionBar actionBar = getSupportActionBar(); 35 | if (actionBar != null) { 36 | actionBar.setDisplayHomeAsUpEnabled(true); 37 | } 38 | 39 | // Our MapView is declared in the layout file. 40 | view = findViewById(R.id.map); 41 | 42 | // Lifecycle events from the Activity must be forwarded to the MapView. 43 | view.onCreate(savedInstanceState); 44 | 45 | // Create an HttpHandler to cache map tiles. 46 | HttpHandler httpHandler = new CachingHttpHandler(getExternalCacheDir()); 47 | 48 | // This starts a background process to set up the map. 49 | view.getMapAsync(this, httpHandler); 50 | } 51 | 52 | @Override 53 | public void onMapReady(MapController mapController) { 54 | // We receive a MapController object in this callback when the map is ready for use. 55 | map = mapController; 56 | 57 | // Set our API key as a scene update. 58 | List updates = new ArrayList<>(); 59 | updates.add(new SceneUpdate("global.sdk_api_key", BuildConfig.NEXTZEN_API_KEY)); 60 | 61 | map.loadSceneFileAsync("bubble-wrap/bubble-wrap-style.yaml", updates); 62 | 63 | padding = new EdgePadding(); 64 | padding.top = findViewById(R.id.layout_viewpadding_overlay).getBottom(); 65 | 66 | CheckBox viewPaddingCheckbox = findViewById(R.id.checkbox_viewpadding); 67 | viewPaddingCheckbox.setOnCheckedChangeListener((buttonView, isChecked) -> { 68 | map.setPadding(isChecked ? padding : null); 69 | map.requestRender(); 70 | }); 71 | } 72 | 73 | // Below are the remaining Activity lifecycle events that must be forwarded to our MapView. 74 | 75 | @Override 76 | public void onResume() { 77 | super.onResume(); 78 | view.onResume(); 79 | } 80 | 81 | @Override 82 | public void onPause() { 83 | super.onPause(); 84 | view.onPause(); 85 | } 86 | 87 | @Override 88 | public void onDestroy() { 89 | super.onDestroy(); 90 | view.onDestroy(); 91 | } 92 | 93 | @Override 94 | public void onLowMemory() { 95 | super.onLowMemory(); 96 | view.onLowMemory(); 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /tangramdemos/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /tangramdemos/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /tangramdemos/src/main/res/drawable/mapzen_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tangrams/tangram-android-demos/e0a49058ce168033ec9c1171d1671ba7de8b2e45/tangramdemos/src/main/res/drawable/mapzen_logo.png -------------------------------------------------------------------------------- /tangramdemos/src/main/res/layout/activity_featurepicking.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 14 | 23 | 24 | -------------------------------------------------------------------------------- /tangramdemos/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 15 | -------------------------------------------------------------------------------- /tangramdemos/src/main/res/layout/activity_mapgestures.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 14 | 24 | 25 | -------------------------------------------------------------------------------- /tangramdemos/src/main/res/layout/activity_mapmovement.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 14 | 22 | 27 | 32 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /tangramdemos/src/main/res/layout/activity_markers.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 14 | 22 | 23 | 28 | 33 | 38 | 43 | 44 | 45 |