diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..126f1dd --- /dev/null +++ b/.gitignore @@ -0,0 +1,239 @@ +.idea/ + +# Created by https://www.gitignore.io/api/macos,android,windows,jetbrains +# Edit at https://www.gitignore.io/?templates=macos,android,windows,jetbrains + +### Android ### +# Built application files +*.apk +*.ap_ +*.aab + +# Files for the ART/Dalvik VM +*.dex + +# Java class files +*.class + +# Generated files +bin/ +gen/ +out/ +release/ + +# Gradle files +.gradle/ +build/ + +# Local configuration file (sdk path, etc) +local.properties + +# Proguard folder generated by Eclipse +proguard/ + +# Log Files +*.log + +# Android Studio Navigation editor temp files +.navigation/ + +# Android Studio captures folder +captures/ + +# IntelliJ +*.iml +.idea/workspace.xml +.idea/tasks.xml +.idea/gradle.xml +.idea/assetWizardSettings.xml +.idea/dictionaries +.idea/libraries +# Android Studio 3 in .gitignore file. +.idea/caches +.idea/modules.xml +# Comment next line if keeping position of elements in Navigation Editor is relevant for you +.idea/navEditor.xml + +# Keystore files +# Uncomment the following lines if you do not want to check your keystore files in. +#*.jks +#*.keystore + +# External native build folder generated in Android Studio 2.2 and later +.externalNativeBuild + +# Google Services (e.g. APIs or Firebase) +# google-services.json + +# Freeline +freeline.py +freeline/ +freeline_project_description.json + +# fastlane +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots +fastlane/test_output +fastlane/readme.md + +# Version control +vcs.xml + +# lint +lint/intermediates/ +lint/generated/ +lint/outputs/ +lint/tmp/ +# lint/reports/ + +### Android Patch ### +gen-external-apklibs +output.json + +# Replacement of .externalNativeBuild directories introduced +# with Android Studio 3.5. +.cxx/ + +### JetBrains ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### JetBrains Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + +# Sonarlint plugin +.idea/**/sonarlint/ + +# SonarQube Plugin +.idea/**/sonarIssues.xml + +# Markdown Navigator plugin +.idea/**/markdown-navigator.xml +.idea/**/markdown-navigator/ + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# End of https://www.gitignore.io/api/macos,android,windows,jetbrains \ No newline at end of file diff --git a/README.md b/README.md index 83eb0c1..6944f7f 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ Place RouteOverlayView over your google map layout in xml. Make sure that the ro android:id="@+id/map" android:layout_width="match_parent" android:layout_height="match_parent" - android:name="com.google.android.gms.maps.SupportMapFragment"/> + android:name="com.google.android.libraries.maps.SupportMapFragment"/> - + - - + + - - - + + - + - - - - - - + + + + + - - - - - - + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/amalbit/animationongooglemap/HomeActivity.java b/app/src/main/java/com/amalbit/animationongooglemap/HomeActivity.java index d0e37c6..ba7a314 100644 --- a/app/src/main/java/com/amalbit/animationongooglemap/HomeActivity.java +++ b/app/src/main/java/com/amalbit/animationongooglemap/HomeActivity.java @@ -2,8 +2,10 @@ import android.content.Intent; import android.os.Bundle; -import android.support.v7.app.AppCompatActivity; import android.view.View; + +import androidx.appcompat.app.AppCompatActivity; + import com.amalbit.animationongooglemap.polylineBased.MapsActivity; import com.amalbit.animationongooglemap.projectionBased.FromToActivity; import com.amalbit.animationongooglemap.projectionBased.OverlayRouteActivity; @@ -11,36 +13,36 @@ public class HomeActivity extends AppCompatActivity implements View.OnClickListener { - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_home); - findViewById(R.id.btn_polyline).setOnClickListener(this); - findViewById(R.id.btn_projection).setOnClickListener(this); - findViewById(R.id.btn_fromto).setOnClickListener(this); - findViewById(R.id.btnViewOverly).setOnClickListener(this); + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_home); + findViewById(R.id.btn_polyline).setOnClickListener(this); + findViewById(R.id.btn_projection).setOnClickListener(this); + findViewById(R.id.btn_fromto).setOnClickListener(this); + findViewById(R.id.btnViewOverly).setOnClickListener(this); - //Debugging + //Debugging // findViewById(R.id.btn_fromto).performClick(); // findViewById(R.id.btn_projection).performClick(); - findViewById(R.id.btnViewOverly).performClick(); - } + findViewById(R.id.btnViewOverly).performClick(); + } - @Override - public void onClick(View v) { - switch (v.getId()) { - case R.id.btn_polyline: - startActivity(new Intent(HomeActivity.this, MapsActivity.class)); - break; - case R.id.btn_projection: - startActivity(new Intent(HomeActivity.this, OverlayRouteActivity.class)); - break; - case R.id.btn_fromto: - startActivity(new Intent(HomeActivity.this, FromToActivity.class)); - break; - case R.id.btnViewOverly: - startActivity(new Intent(HomeActivity.this, ViewOverlayActivity.class)); - break; + @Override + public void onClick(View v) { + switch (v.getId()) { + case R.id.btn_polyline: + startActivity(new Intent(HomeActivity.this, MapsActivity.class)); + break; + case R.id.btn_projection: + startActivity(new Intent(HomeActivity.this, OverlayRouteActivity.class)); + break; + case R.id.btn_fromto: + startActivity(new Intent(HomeActivity.this, FromToActivity.class)); + break; + case R.id.btnViewOverly: + startActivity(new Intent(HomeActivity.this, ViewOverlayActivity.class)); + break; + } } - } } diff --git a/app/src/main/java/com/amalbit/animationongooglemap/U.kt b/app/src/main/java/com/amalbit/animationongooglemap/U.kt index ce1b22f..31405fd 100644 --- a/app/src/main/java/com/amalbit/animationongooglemap/U.kt +++ b/app/src/main/java/com/amalbit/animationongooglemap/U.kt @@ -4,8 +4,9 @@ import android.util.Log class U { companion object { - @JvmStatic fun log(tag: String, msg: String) { - Log.d(tag, msg); + @JvmStatic + fun log(tag: String, msg: String) { + Log.d(tag, msg) } } } \ No newline at end of file diff --git a/app/src/main/java/com/amalbit/animationongooglemap/data/CarData.java b/app/src/main/java/com/amalbit/animationongooglemap/data/CarData.java index f1ec531..7c96ef4 100644 --- a/app/src/main/java/com/amalbit/animationongooglemap/data/CarData.java +++ b/app/src/main/java/com/amalbit/animationongooglemap/data/CarData.java @@ -1,63 +1,65 @@ package com.amalbit.animationongooglemap.data; -import com.google.android.gms.maps.model.LatLng; + +import com.google.android.libraries.maps.model.LatLng; + import java.util.ArrayList; import java.util.List; public class CarData { - public static List getIndiranagarBounds(ArrayList arrayListOfLists) { - List cars = new ArrayList<>(); + public static List getIndiranagarBounds(ArrayList arrayListOfLists) { + List cars = new ArrayList<>(); // List currentPointers = new ArrayList<>(arrayListOfLists.size()); - int currentPointer = 0; - for (int i = 0; i < arrayListOfLists.size(); i++) { - Car carRoute = arrayListOfLists.get(0); + int currentPointer = 0; + for (int i = 0; i < arrayListOfLists.size(); i++) { + Car carRoute = arrayListOfLists.get(0); + + } + return cars; } - return cars; - } + public static class Car { + private int carId = -1; + private int currentPointer; + private boolean isBackwardCounting; + private List route; - public static class Car { - private int carId = -1; - private int currentPointer; - private boolean isBackwardCounting; - private List route; + public int getCarId() { + return carId; + } - public int getCarId() { - return carId; - } + public void setCarId(int carId) { + this.carId = carId; + } - public void setCarId(int carId) { - this.carId = carId; - } + public LatLng getLatLng() { + LatLng latLng = route.get(currentPointer); + next(); + return latLng; + } - public LatLng getLatLng() { - LatLng latLng = route.get(currentPointer); - next(); - return latLng; - } - - public void setRoute(List route) { - this.route = route; - } + public void setRoute(List route) { + this.route = route; + } - private void next() { - if (!isBackwardCounting && currentPointer < route.size()-1 ) { - currentPointer++; - } else if (currentPointer > 0) { - isBackwardCounting = true; - currentPointer--; - } else { - currentPointer++; - isBackwardCounting = false; - } - } + private void next() { + if (!isBackwardCounting && currentPointer < route.size() - 1) { + currentPointer++; + } else if (currentPointer > 0) { + isBackwardCounting = true; + currentPointer--; + } else { + currentPointer++; + isBackwardCounting = false; + } + } - public void setCurrentPointer(int currentPointer) { - this.currentPointer = currentPointer; + public void setCurrentPointer(int currentPointer) { + this.currentPointer = currentPointer; + } } - } } diff --git a/app/src/main/java/com/amalbit/animationongooglemap/data/LatlngData.java b/app/src/main/java/com/amalbit/animationongooglemap/data/LatlngData.java index 89150bc..458275d 100644 --- a/app/src/main/java/com/amalbit/animationongooglemap/data/LatlngData.java +++ b/app/src/main/java/com/amalbit/animationongooglemap/data/LatlngData.java @@ -1,7 +1,8 @@ package com.amalbit.animationongooglemap.data; import com.amalbit.animationongooglemap.data.CarData.Car; -import com.google.android.gms.maps.model.LatLng; +import com.google.android.libraries.maps.model.LatLng; + import java.util.ArrayList; import java.util.List; @@ -11,1106 +12,1133 @@ public class LatlngData { - public static LatLng LATLNG_MUMBAI = new LatLng(19.0821978, 72.7410994); - public static LatLng LATLNG_CHENNAI = new LatLng(13.0474878, 80.0689246); - public static LatLng LATLNG_BENGALURU = new LatLng(12.95396, 77.4908523); - public static LatLng LATLNG_KOLKATA = new LatLng(22.6757521, 88.0495361); + public static LatLng LATLNG_MUMBAI = new LatLng(19.0821978, 72.7410994); + public static LatLng LATLNG_CHENNAI = new LatLng(13.0474878, 80.0689246); + public static LatLng LATLNG_BENGALURU = new LatLng(12.95396, 77.4908523); + public static LatLng LATLNG_KOLKATA = new LatLng(22.6757521, 88.0495361); + + public static List getRoute() { + List mFinalRoute = new ArrayList<>(); + mFinalRoute.add(new LatLng(12.94695, 77.64058)); + mFinalRoute.add(new LatLng(12.94735, 77.64076)); + mFinalRoute.add(new LatLng(12.9476, 77.64081)); + mFinalRoute.add(new LatLng(12.94786, 77.64078)); + mFinalRoute.add(new LatLng(12.94809, 77.6407)); + mFinalRoute.add(new LatLng(12.9483, 77.64058)); + mFinalRoute.add(new LatLng(12.9486, 77.64029)); + mFinalRoute.add(new LatLng(12.94928, 77.63952)); + mFinalRoute.add(new LatLng(12.94946, 77.63936)); + mFinalRoute.add(new LatLng(12.94967, 77.63923)); + mFinalRoute.add(new LatLng(12.94984, 77.63917)); + mFinalRoute.add(new LatLng(12.95006, 77.63912)); + mFinalRoute.add(new LatLng(12.95036, 77.63913)); + mFinalRoute.add(new LatLng(12.95062, 77.63922)); + mFinalRoute.add(new LatLng(12.9517, 77.63978)); + mFinalRoute.add(new LatLng(12.95267, 77.64038)); + mFinalRoute.add(new LatLng(12.95418, 77.64121)); + mFinalRoute.add(new LatLng(12.95443, 77.64125)); + mFinalRoute.add(new LatLng(12.9556, 77.64133)); + mFinalRoute.add(new LatLng(12.95609, 77.64135)); + mFinalRoute.add(new LatLng(12.95698, 77.64136)); + mFinalRoute.add(new LatLng(12.95782, 77.64131)); + mFinalRoute.add(new LatLng(12.95797, 77.64132)); + mFinalRoute.add(new LatLng(12.95818, 77.64135)); + + return mFinalRoute; + } + + public static List getRouteB() { + List mFinalRoute = new ArrayList<>(); + mFinalRoute.add(new LatLng(12.95848, 77.64139)); + mFinalRoute.add(new LatLng(12.95937, 77.64146)); + mFinalRoute.add(new LatLng(12.95968, 77.6415)); + mFinalRoute.add(new LatLng(12.95999, 77.64156)); + mFinalRoute.add(new LatLng(12.96031, 77.64164)); + mFinalRoute.add(new LatLng(12.96054, 77.64169)); + mFinalRoute.add(new LatLng(12.96079, 77.64171)); + mFinalRoute.add(new LatLng(12.96087, 77.64171)); + mFinalRoute.add(new LatLng(12.96099, 77.6417)); + mFinalRoute.add(new LatLng(12.96108, 77.64166)); + mFinalRoute.add(new LatLng(12.96117, 77.64162)); + mFinalRoute.add(new LatLng(12.96122, 77.64158)); + mFinalRoute.add(new LatLng(12.96127, 77.64154)); + mFinalRoute.add(new LatLng(12.96132, 77.64146)); + mFinalRoute.add(new LatLng(12.96136, 77.64131)); + mFinalRoute.add(new LatLng(12.96135, 77.64108)); + mFinalRoute.add(new LatLng(12.9613, 77.64099)); + mFinalRoute.add(new LatLng(12.9612, 77.6409)); + mFinalRoute.add(new LatLng(12.96107, 77.64086)); + mFinalRoute.add(new LatLng(12.96099, 77.64086)); + mFinalRoute.add(new LatLng(12.96091, 77.64089)); + mFinalRoute.add(new LatLng(12.96082, 77.64096)); + mFinalRoute.add(new LatLng(12.96073, 77.64132)); + mFinalRoute.add(new LatLng(12.96066, 77.64208)); + mFinalRoute.add(new LatLng(12.96049, 77.64337)); + mFinalRoute.add(new LatLng(12.96031, 77.6451)); + mFinalRoute.add(new LatLng(12.96023, 77.64577)); + mFinalRoute.add(new LatLng(12.96014, 77.64651)); + mFinalRoute.add(new LatLng(12.96001, 77.64775)); + mFinalRoute.add(new LatLng(12.95981, 77.64909)); + + return mFinalRoute; + } + + public static List getTokyoRoute() { + List mFinalRoute = new ArrayList<>(); + mFinalRoute.add(new LatLng(35.64719, 139.79163)); + mFinalRoute.add(new LatLng(35.64733, 139.7918)); + mFinalRoute.add(new LatLng(35.64752, 139.7919)); + mFinalRoute.add(new LatLng(35.64765, 139.79196)); + mFinalRoute.add(new LatLng(35.6478, 139.79198)); + mFinalRoute.add(new LatLng(35.64806, 139.79196)); + mFinalRoute.add(new LatLng(35.64818, 139.79193)); + mFinalRoute.add(new LatLng(35.6483, 139.79185)); + mFinalRoute.add(new LatLng(35.64847, 139.79172)); + mFinalRoute.add(new LatLng(35.6486, 139.79156)); + mFinalRoute.add(new LatLng(35.64917, 139.79091)); + mFinalRoute.add(new LatLng(35.64914, 139.79088)); + mFinalRoute.add(new LatLng(35.64846, 139.78989)); + mFinalRoute.add(new LatLng(35.64807, 139.78926)); + mFinalRoute.add(new LatLng(35.64769, 139.78963)); + mFinalRoute.add(new LatLng(35.64748, 139.78976)); + mFinalRoute.add(new LatLng(35.64702, 139.79014)); + mFinalRoute.add(new LatLng(35.64635, 139.79064)); + mFinalRoute.add(new LatLng(35.64596, 139.79095)); + mFinalRoute.add(new LatLng(35.64371, 139.79272)); + mFinalRoute.add(new LatLng(35.64293, 139.79335)); + mFinalRoute.add(new LatLng(35.64274, 139.79346)); + mFinalRoute.add(new LatLng(35.6418, 139.79429)); + mFinalRoute.add(new LatLng(35.64019, 139.79558)); + mFinalRoute.add(new LatLng(35.63922, 139.79637)); + mFinalRoute.add(new LatLng(35.63884, 139.79663)); + mFinalRoute.add(new LatLng(35.63851, 139.79674)); + mFinalRoute.add(new LatLng(35.63836, 139.79675)); + mFinalRoute.add(new LatLng(35.63825, 139.79673)); + mFinalRoute.add(new LatLng(35.63809, 139.7967)); + mFinalRoute.add(new LatLng(35.63784, 139.79657)); + mFinalRoute.add(new LatLng(35.63765, 139.79641)); + mFinalRoute.add(new LatLng(35.63747, 139.7962)); + mFinalRoute.add(new LatLng(35.63704, 139.7954)); + mFinalRoute.add(new LatLng(35.63652, 139.79446)); + mFinalRoute.add(new LatLng(35.63583, 139.79319)); + mFinalRoute.add(new LatLng(35.63523, 139.79204)); + mFinalRoute.add(new LatLng(35.63488, 139.79132)); + mFinalRoute.add(new LatLng(35.63469, 139.79085)); + mFinalRoute.add(new LatLng(35.63411, 139.78981)); + mFinalRoute.add(new LatLng(35.63359, 139.78882)); + mFinalRoute.add(new LatLng(35.63337, 139.78853)); + mFinalRoute.add(new LatLng(35.6331, 139.78814)); + mFinalRoute.add(new LatLng(35.63268, 139.7874)); + mFinalRoute.add(new LatLng(35.63173, 139.78565)); + mFinalRoute.add(new LatLng(35.6315, 139.78513)); + mFinalRoute.add(new LatLng(35.63141, 139.78472)); + mFinalRoute.add(new LatLng(35.6314, 139.78439)); + mFinalRoute.add(new LatLng(35.63145, 139.78403)); + mFinalRoute.add(new LatLng(35.63154, 139.78373)); + mFinalRoute.add(new LatLng(35.63171, 139.78343)); + mFinalRoute.add(new LatLng(35.63199, 139.78305)); + mFinalRoute.add(new LatLng(35.63355, 139.7814)); + mFinalRoute.add(new LatLng(35.63478, 139.78039)); + mFinalRoute.add(new LatLng(35.63519, 139.77999)); + mFinalRoute.add(new LatLng(35.63546, 139.77968)); + mFinalRoute.add(new LatLng(35.63561, 139.77943)); + mFinalRoute.add(new LatLng(35.63578, 139.77918)); + mFinalRoute.add(new LatLng(35.6359, 139.77893)); + mFinalRoute.add(new LatLng(35.63617, 139.77829)); + mFinalRoute.add(new LatLng(35.63628, 139.77793)); + mFinalRoute.add(new LatLng(35.63635, 139.77757)); + mFinalRoute.add(new LatLng(35.63645, 139.77696)); + mFinalRoute.add(new LatLng(35.63646, 139.77623)); + mFinalRoute.add(new LatLng(35.6364, 139.77555)); + mFinalRoute.add(new LatLng(35.63626, 139.77471)); + mFinalRoute.add(new LatLng(35.63609, 139.77403)); + mFinalRoute.add(new LatLng(35.63582, 139.77314)); + mFinalRoute.add(new LatLng(35.63549, 139.77222)); + mFinalRoute.add(new LatLng(35.63497, 139.77072)); + mFinalRoute.add(new LatLng(35.63484, 139.77019)); + mFinalRoute.add(new LatLng(35.63479, 139.76986)); + mFinalRoute.add(new LatLng(35.63478, 139.76956)); + mFinalRoute.add(new LatLng(35.6348, 139.7691)); + mFinalRoute.add(new LatLng(35.63487, 139.76851)); + mFinalRoute.add(new LatLng(35.635, 139.76795)); + mFinalRoute.add(new LatLng(35.6354, 139.7667)); + mFinalRoute.add(new LatLng(35.63652, 139.76318)); + mFinalRoute.add(new LatLng(35.63752, 139.76002)); + mFinalRoute.add(new LatLng(35.63781, 139.75913)); + mFinalRoute.add(new LatLng(35.63793, 139.75885)); + mFinalRoute.add(new LatLng(35.6381, 139.75853)); + mFinalRoute.add(new LatLng(35.63834, 139.75823)); + mFinalRoute.add(new LatLng(35.63861, 139.75801)); + mFinalRoute.add(new LatLng(35.63884, 139.75788)); + return mFinalRoute; + } + + public static List getNewYorkRoute() { + List mFinalRoute = new ArrayList<>(); + mFinalRoute.add(new LatLng(40.69293, -73.90815)); + mFinalRoute.add(new LatLng(40.69455, -73.90654)); + mFinalRoute.add(new LatLng(40.69375, -73.90513)); + mFinalRoute.add(new LatLng(40.69304, -73.90387)); + mFinalRoute.add(new LatLng(40.69242, -73.90278)); + mFinalRoute.add(new LatLng(40.69267, -73.90255)); + mFinalRoute.add(new LatLng(40.69283, -73.90238)); + mFinalRoute.add(new LatLng(40.69289, -73.90224)); + mFinalRoute.add(new LatLng(40.69343, -73.90005)); + mFinalRoute.add(new LatLng(40.69347, -73.8999)); + mFinalRoute.add(new LatLng(40.69386, -73.89871)); + mFinalRoute.add(new LatLng(40.69394, -73.89831)); + mFinalRoute.add(new LatLng(40.69411, -73.89733)); + mFinalRoute.add(new LatLng(40.69384, -73.89691)); + mFinalRoute.add(new LatLng(40.69319, -73.89574)); + mFinalRoute.add(new LatLng(40.69266, -73.89479)); + mFinalRoute.add(new LatLng(40.69185, -73.89204)); + mFinalRoute.add(new LatLng(40.69141, -73.89059)); + mFinalRoute.add(new LatLng(40.69107, -73.89054)); + mFinalRoute.add(new LatLng(40.69089, -73.89052)); + mFinalRoute.add(new LatLng(40.69088, -73.89026)); + mFinalRoute.add(new LatLng(40.69084, -73.89006)); + mFinalRoute.add(new LatLng(40.69079, -73.88998)); + mFinalRoute.add(new LatLng(40.69073, -73.88992)); + mFinalRoute.add(new LatLng(40.69059, -73.88986)); + mFinalRoute.add(new LatLng(40.69051, -73.88986)); + mFinalRoute.add(new LatLng(40.69043, -73.88989)); + mFinalRoute.add(new LatLng(40.69026, -73.89001)); + mFinalRoute.add(new LatLng(40.69009, -73.89015)); + mFinalRoute.add(new LatLng(40.68997, -73.89019)); + mFinalRoute.add(new LatLng(40.68974, -73.89038)); + mFinalRoute.add(new LatLng(40.68849, -73.89139)); + mFinalRoute.add(new LatLng(40.68787, -73.89188)); + mFinalRoute.add(new LatLng(40.68692, -73.89266)); + mFinalRoute.add(new LatLng(40.68638, -73.89312)); + mFinalRoute.add(new LatLng(40.68557, -73.89393)); + mFinalRoute.add(new LatLng(40.68497, -73.89454)); + mFinalRoute.add(new LatLng(40.68441, -73.89507)); + mFinalRoute.add(new LatLng(40.68385, -73.89554)); + mFinalRoute.add(new LatLng(40.68335, -73.89594)); + mFinalRoute.add(new LatLng(40.68282, -73.8963)); + mFinalRoute.add(new LatLng(40.68239, -73.89651)); + mFinalRoute.add(new LatLng(40.6821, -73.89659)); + mFinalRoute.add(new LatLng(40.68177, -73.89661)); + mFinalRoute.add(new LatLng(40.68085, -73.89668)); + mFinalRoute.add(new LatLng(40.68062, -73.89672)); + mFinalRoute.add(new LatLng(40.68021, -73.89682)); + mFinalRoute.add(new LatLng(40.67958, -73.89707)); + mFinalRoute.add(new LatLng(40.67893, -73.89741)); + mFinalRoute.add(new LatLng(40.6786, -73.89747)); + mFinalRoute.add(new LatLng(40.67835, -73.89752)); + mFinalRoute.add(new LatLng(40.67821, -73.89753)); + mFinalRoute.add(new LatLng(40.67806, -73.89759)); + mFinalRoute.add(new LatLng(40.67795, -73.89742)); + mFinalRoute.add(new LatLng(40.67721, -73.89722)); + mFinalRoute.add(new LatLng(40.67597, -73.89691)); + mFinalRoute.add(new LatLng(40.6756, -73.89683)); + mFinalRoute.add(new LatLng(40.67294, -73.89614)); + mFinalRoute.add(new LatLng(40.66937, -73.89522)); + mFinalRoute.add(new LatLng(40.6663, -73.89444)); + mFinalRoute.add(new LatLng(40.66476, -73.89406)); + mFinalRoute.add(new LatLng(40.66322, -73.89364)); + mFinalRoute.add(new LatLng(40.66256, -73.89348)); + mFinalRoute.add(new LatLng(40.66234, -73.89341)); + mFinalRoute.add(new LatLng(40.66205, -73.89326)); + mFinalRoute.add(new LatLng(40.66167, -73.89298)); + mFinalRoute.add(new LatLng(40.66145, -73.89278)); + mFinalRoute.add(new LatLng(40.66088, -73.89235)); + mFinalRoute.add(new LatLng(40.65993, -73.89164)); + mFinalRoute.add(new LatLng(40.65909, -73.89104)); + mFinalRoute.add(new LatLng(40.65884, -73.89085)); + mFinalRoute.add(new LatLng(40.65869, -73.89081)); + mFinalRoute.add(new LatLng(40.65859, -73.89075)); + mFinalRoute.add(new LatLng(40.65839, -73.89059)); + mFinalRoute.add(new LatLng(40.65694, -73.88948)); + mFinalRoute.add(new LatLng(40.65546, -73.88839)); + mFinalRoute.add(new LatLng(40.65365, -73.88703)); + mFinalRoute.add(new LatLng(40.65279, -73.8864)); + mFinalRoute.add(new LatLng(40.65267, -73.88636)); + mFinalRoute.add(new LatLng(40.65232, -73.88609)); + mFinalRoute.add(new LatLng(40.65119, -73.88522)); + mFinalRoute.add(new LatLng(40.65073, -73.88489)); + mFinalRoute.add(new LatLng(40.65023, -73.88451)); + mFinalRoute.add(new LatLng(40.65007, -73.88435)); + return mFinalRoute; + } + + public static List getIndiranagarBounds() { + List latLngs = new ArrayList<>(); + latLngs.add(new LatLng(12.9715002, 77.6374856));//NW + latLngs.add(new LatLng(12.9703733, 77.6372037));//NE + latLngs.add(new LatLng(12.9595674, 77.6366595));//SE + latLngs.add(new LatLng(12.9595672, 77.6519803));//SW + return latLngs; + } + + //Indiranagar routes + public static ArrayList getIndiranagarRoutes() { + ArrayList carRoute = new ArrayList<>(); + carRoute.add(getCarForRoute(getRoute1(), 1)); + carRoute.add(getCarForRoute(getRoute2(), 2)); + carRoute.add(getCarForRoute(getRoute3(), 3)); + carRoute.add(getCarForRoute(getRoute4(), 4)); + carRoute.add(getCarForRoute(getRoute5(), 5)); + carRoute.add(getCarForRoute(getRoute6(), 6)); + carRoute.add(getCarForRoute(getRoute7(), 7)); + carRoute.add(getCarForRoute(getRoute8(), 8)); + carRoute.add(getCarForRoute(getRoute9(), 9)); + carRoute.add(getCarForRoute(getRoute10(), 10)); + carRoute.add(getCarForRoute(getRoute11(), 11)); + carRoute.add(getCarForRoute(getRoute12(), 12)); + carRoute.add(getCarForRoute(getRoute13(), 13)); + carRoute.add(getCarForRoute(getRoute14(), 14)); + carRoute.add(getCarForRoute(getRoute15(), 15)); + carRoute.add(getCarForRoute(getRoute16(), 16)); + carRoute.add(getCarForRoute(getRoute17(), 17)); + carRoute.add(getCarForRoute(getRoute18(), 18)); + carRoute.add(getCarForRoute(getRoute19(), 19)); + carRoute.add(getCarForRoute(getRoute20(), 20)); + carRoute.add(getCarForRoute(getRoute21(), 21)); + carRoute.add(getCarForRoute(getRoute22(), 22)); + carRoute.add(getCarForRoute(getRoute23(), 23)); + carRoute.add(getCarForRoute(getRoute24(), 24)); + carRoute.add(getCarForRoute(getRoute25(), 25)); + carRoute.add(getCarForRoute(getRoute26(), 26)); + carRoute.add(getCarForRoute(getRoute27(), 27)); + carRoute.add(getCarForRoute(getRoute28(), 28)); + return carRoute; + } + + private static Car getCarForRoute(List latLngs, int count) { + Car car = new Car(); + car.setCarId(count); + car.setCurrentPointer(0); + car.setRoute(latLngs); + return car; + } + + private static ArrayList getRoute1() { + ArrayList route = new ArrayList<>(); + route.add(new LatLng(12.9710101, 77.638021)); + route.add(new LatLng(12.97104, 77.638741)); + route.add(new LatLng(12.97057, 77.638771)); + route.add(new LatLng(12.9695002, 77.6388)); + route.add(new LatLng(12.96837, 77.63888)); + route.add(new LatLng(12.9684202, 77.639321)); + route.add(new LatLng(12.9685, 77.640121)); + route.add(new LatLng(12.9685301, 77.64069)); + route.add(new LatLng(12.9685801, 77.641281)); + route.add(new LatLng(12.9686, 77.6414)); + route.add(new LatLng(12.96784, 77.64144)); + route.add(new LatLng(12.96696, 77.64148)); + route.add(new LatLng(12.9668401, 77.641501)); + route.add(new LatLng(12.9665902, 77.64234)); + route.add(new LatLng(12.9664502, 77.642671)); + route.add(new LatLng(12.96639, 77.642901)); + route.add(new LatLng(12.9662, 77.644061)); + route.add(new LatLng(12.96616, 77.64457)); + route.add(new LatLng(12.9661301, 77.64476)); + route.add(new LatLng(12.9659901, 77.64515)); + route.add(new LatLng(12.9657902, 77.64546)); + route.add(new LatLng(12.96569, 77.6456)); + route.add(new LatLng(12.9655201, 77.64579)); + route.add(new LatLng(12.96531, 77.64592)); + route.add(new LatLng(12.96513, 77.646031)); + return route; + } + + private static ArrayList getRoute2() { + ArrayList route = new ArrayList<>(); + route.add(new LatLng(12.9694602, 77.63812)); + route.add(new LatLng(12.9695002, 77.6388)); + route.add(new LatLng(12.96959, 77.6397)); + route.add(new LatLng(12.9696101, 77.640161)); + route.add(new LatLng(12.96958, 77.640161)); + route.add(new LatLng(12.96851, 77.64024)); + route.add(new LatLng(12.9685301, 77.64073)); + route.add(new LatLng(12.9686, 77.6414)); + route.add(new LatLng(12.9686102, 77.64203)); + route.add(new LatLng(12.9686, 77.6427)); + route.add(new LatLng(12.96865, 77.644141)); + route.add(new LatLng(12.9687002, 77.64561)); + route.add(new LatLng(12.96874, 77.64632)); + return route; + } + + private static ArrayList getRoute3() { + ArrayList route = new ArrayList<>(); + route.add(new LatLng(12.97633, 77.6379)); + route.add(new LatLng(12.97601, 77.637921)); + route.add(new LatLng(12.97601, 77.63826)); + route.add(new LatLng(12.9760302, 77.638951)); + route.add(new LatLng(12.9760702, 77.63988)); + route.add(new LatLng(12.9760801, 77.64019)); + route.add(new LatLng(12.97572, 77.64022)); + route.add(new LatLng(12.9741902, 77.64028)); + route.add(new LatLng(12.9734101, 77.64031)); + route.add(new LatLng(12.97343, 77.641071)); + route.add(new LatLng(12.9738401, 77.64105)); + route.add(new LatLng(12.97385, 77.641141)); + route.add(new LatLng(12.97389, 77.642681)); + route.add(new LatLng(12.9739102, 77.643531)); + route.add(new LatLng(12.97399, 77.64537)); + route.add(new LatLng(12.9740701, 77.64685)); + route.add(new LatLng(12.9740701, 77.64691)); + route.add(new LatLng(12.9736802, 77.646931)); + route.add(new LatLng(12.97352, 77.646921)); + route.add(new LatLng(12.9731102, 77.64691)); + route.add(new LatLng(12.9724201, 77.647021)); + route.add(new LatLng(12.9719601, 77.64712)); + route.add(new LatLng(12.9704601, 77.647411)); + route.add(new LatLng(12.9694, 77.64763)); + route.add(new LatLng(12.9690001, 77.647731)); + route.add(new LatLng(12.9689001, 77.64779)); + route.add(new LatLng(12.96887, 77.64802)); + route.add(new LatLng(12.9687002, 77.6491)); + route.add(new LatLng(12.96846, 77.65012)); + route.add(new LatLng(12.9684, 77.65058)); + route.add(new LatLng(12.96826, 77.6511)); + route.add(new LatLng(12.9681501, 77.65156)); + route.add(new LatLng(12.9680201, 77.652251)); + route.add(new LatLng(12.96587, 77.65139)); + route.add(new LatLng(12.96385, 77.65054)); + route.add(new LatLng(12.9632801, 77.650331)); + return route; + } + + private static ArrayList getRoute4() { + ArrayList route = new ArrayList<>(); + route.add(new LatLng(12.9627201, 77.64564)); + route.add(new LatLng(12.96264, 77.646021)); + route.add(new LatLng(12.9621101, 77.64591)); + route.add(new LatLng(12.96197, 77.64588)); + route.add(new LatLng(12.9619902, 77.64542)); + route.add(new LatLng(12.9621302, 77.645441)); + route.add(new LatLng(12.9621402, 77.64543)); + route.add(new LatLng(12.9622901, 77.644411)); + route.add(new LatLng(12.9623702, 77.643751)); + route.add(new LatLng(12.96241, 77.64346)); + route.add(new LatLng(12.9626701, 77.6435)); + route.add(new LatLng(12.9632102, 77.64363)); + route.add(new LatLng(12.9633701, 77.642261)); + route.add(new LatLng(12.9633502, 77.64176)); + route.add(new LatLng(12.9633201, 77.641561)); + route.add(new LatLng(12.9635902, 77.64091)); + route.add(new LatLng(12.964, 77.640131)); + route.add(new LatLng(12.9642502, 77.639671)); + route.add(new LatLng(12.96447, 77.63929)); + route.add(new LatLng(12.96475, 77.63888)); + route.add(new LatLng(12.96362, 77.63839)); + route.add(new LatLng(12.9633502, 77.638241)); + return route; + } + + private static ArrayList getRoute5() { + ArrayList route = new ArrayList<>(); + route.add(new LatLng(12.9712402, 77.643651)); + route.add(new LatLng(12.97085, 77.643661)); + route.add(new LatLng(12.9708801, 77.644511)); + route.add(new LatLng(12.97089, 77.64494)); + route.add(new LatLng(12.9703601, 77.64494)); + route.add(new LatLng(12.9703902, 77.64574)); + route.add(new LatLng(12.9704402, 77.64721)); + route.add(new LatLng(12.9704601, 77.647411)); + route.add(new LatLng(12.9701102, 77.64748)); + route.add(new LatLng(12.96958, 77.647591)); + route.add(new LatLng(12.9690802, 77.64771)); + route.add(new LatLng(12.96892, 77.647771)); + route.add(new LatLng(12.9687701, 77.647771)); + route.add(new LatLng(12.96841, 77.647831)); + route.add(new LatLng(12.96836, 77.64788)); + route.add(new LatLng(12.9680201, 77.647951)); + route.add(new LatLng(12.9675901, 77.6481)); + route.add(new LatLng(12.9671301, 77.64829)); + route.add(new LatLng(12.9670602, 77.648221)); + route.add(new LatLng(12.9653001, 77.64734)); + route.add(new LatLng(12.96494, 77.64717)); + route.add(new LatLng(12.9649101, 77.64718)); + route.add(new LatLng(12.96479, 77.64744)); + route.add(new LatLng(12.96475, 77.647551)); + route.add(new LatLng(12.9647202, 77.64752)); + route.add(new LatLng(12.9647, 77.647501)); + route.add(new LatLng(12.9640301, 77.64727)); + route.add(new LatLng(12.964, 77.64726)); + route.add(new LatLng(12.9639602, 77.64745)); + route.add(new LatLng(12.9635902, 77.647321)); + route.add(new LatLng(12.9636001, 77.64725)); + route.add(new LatLng(12.9636802, 77.64669)); + route.add(new LatLng(12.9638901, 77.645811)); + return route; + } + + private static ArrayList getRoute6() { + ArrayList route = new ArrayList<>(); + route.add(new LatLng(12.97347, 77.64583)); + route.add(new LatLng(12.9734501, 77.645441)); + route.add(new LatLng(12.97339, 77.64485)); + route.add(new LatLng(12.97339, 77.644831)); + route.add(new LatLng(12.9739602, 77.64481)); + route.add(new LatLng(12.9739102, 77.643531)); + route.add(new LatLng(12.97389, 77.642681)); + route.add(new LatLng(12.9738801, 77.642351)); + return route; + } + + private static ArrayList getRoute7() { + ArrayList route = new ArrayList<>(); + route.add(new LatLng(12.9617602, 77.646531)); + route.add(new LatLng(12.96193, 77.64664)); + route.add(new LatLng(12.9620402, 77.646751)); + route.add(new LatLng(12.9624202, 77.64691)); + route.add(new LatLng(12.9627502, 77.64703)); + route.add(new LatLng(12.9631301, 77.64713)); + route.add(new LatLng(12.9632701, 77.647201)); + route.add(new LatLng(12.9634002, 77.647281)); + route.add(new LatLng(12.9635902, 77.647321)); + route.add(new LatLng(12.9636802, 77.64669)); + route.add(new LatLng(12.96395, 77.645581)); + route.add(new LatLng(12.9639801, 77.64552)); + route.add(new LatLng(12.96414, 77.64484)); + route.add(new LatLng(12.9643601, 77.643921)); + route.add(new LatLng(12.9646801, 77.643981)); + return route; + } + + private static ArrayList getRoute8() { + ArrayList route = new ArrayList<>(); + route.add(new LatLng(12.96527, 77.64)); + route.add(new LatLng(12.9656701, 77.64011)); + route.add(new LatLng(12.9657701, 77.64015)); + route.add(new LatLng(12.96578, 77.64018)); + route.add(new LatLng(12.9658402, 77.640201)); + route.add(new LatLng(12.9660401, 77.640261)); + route.add(new LatLng(12.9659501, 77.64054)); + route.add(new LatLng(12.9658402, 77.640931)); + route.add(new LatLng(12.9658101, 77.64113)); + route.add(new LatLng(12.96582, 77.641461)); + route.add(new LatLng(12.96644, 77.64143)); + route.add(new LatLng(12.9671, 77.6414)); + route.add(new LatLng(12.9685801, 77.641281)); + route.add(new LatLng(12.9686, 77.6414)); + route.add(new LatLng(12.9686102, 77.64203)); + route.add(new LatLng(12.9686, 77.6427)); + route.add(new LatLng(12.96864, 77.6435)); + route.add(new LatLng(12.96907, 77.6435)); + route.add(new LatLng(12.96972, 77.64346)); + route.add(new LatLng(12.9703201, 77.643431)); + route.add(new LatLng(12.9703201, 77.643291)); + route.add(new LatLng(12.97047, 77.64328)); + route.add(new LatLng(12.9708202, 77.643251)); + route.add(new LatLng(12.9714302, 77.64322)); + return route; + } + + private static ArrayList getRoute9() { + ArrayList route = new ArrayList<>(); + route.add(new LatLng(12.97118, 77.639171)); + route.add(new LatLng(12.97258, 77.63911)); + route.add(new LatLng(12.9726002, 77.63991)); + route.add(new LatLng(12.9726402, 77.641111)); + route.add(new LatLng(12.9738401, 77.64105)); + route.add(new LatLng(12.9738602, 77.641771)); + route.add(new LatLng(12.97389, 77.643081)); + route.add(new LatLng(12.97394, 77.644231)); + route.add(new LatLng(12.97399, 77.64528)); + route.add(new LatLng(12.9744302, 77.645141)); + route.add(new LatLng(12.97446, 77.64519)); + route.add(new LatLng(12.9744802, 77.645271)); + route.add(new LatLng(12.9745, 77.645491)); + return route; + } + + private static ArrayList getRoute10() { + ArrayList route = new ArrayList<>(); + route.add(new LatLng(12.9765402, 77.65004)); + route.add(new LatLng(12.97428, 77.649431)); + route.add(new LatLng(12.9743001, 77.649381)); + route.add(new LatLng(12.9745, 77.648851)); + route.add(new LatLng(12.97455, 77.648721)); + route.add(new LatLng(12.9745401, 77.648671)); + route.add(new LatLng(12.97441, 77.64857)); + route.add(new LatLng(12.97437, 77.6483)); + route.add(new LatLng(12.9743501, 77.64766)); + route.add(new LatLng(12.9743501, 77.64761)); + route.add(new LatLng(12.97503, 77.647561)); + route.add(new LatLng(12.9749902, 77.64686)); + route.add(new LatLng(12.9740701, 77.64691)); + route.add(new LatLng(12.97403, 77.645941)); + route.add(new LatLng(12.97399, 77.64528)); + route.add(new LatLng(12.97394, 77.644231)); + route.add(new LatLng(12.97389, 77.643081)); + route.add(new LatLng(12.9738602, 77.641771)); + route.add(new LatLng(12.97385, 77.641141)); + route.add(new LatLng(12.9734501, 77.64116)); + route.add(new LatLng(12.9720001, 77.641241)); + route.add(new LatLng(12.9701801, 77.6413)); + route.add(new LatLng(12.9688502, 77.6414)); + route.add(new LatLng(12.9686, 77.6414)); + route.add(new LatLng(12.9685801, 77.641281)); + route.add(new LatLng(12.9685301, 77.64069)); + route.add(new LatLng(12.9685, 77.640121)); + route.add(new LatLng(12.9684202, 77.639321)); + route.add(new LatLng(12.96836, 77.63848)); + route.add(new LatLng(12.9679701, 77.63852)); + route.add(new LatLng(12.96765, 77.638591)); + route.add(new LatLng(12.96752, 77.638591)); + route.add(new LatLng(12.9674001, 77.638561)); + route.add(new LatLng(12.9671301, 77.638461)); + route.add(new LatLng(12.9667501, 77.638381)); + route.add(new LatLng(12.9665902, 77.63835)); + return route; + } + + private static ArrayList getRoute11() { + ArrayList route = new ArrayList<>(); + route.add(new LatLng(12.9726502, 77.65013)); + route.add(new LatLng(12.9727101, 77.649831)); + route.add(new LatLng(12.97278, 77.649441)); + route.add(new LatLng(12.97315, 77.6495)); + route.add(new LatLng(12.9736901, 77.649561)); + route.add(new LatLng(12.97376, 77.649571)); + route.add(new LatLng(12.97418, 77.64969)); + route.add(new LatLng(12.97428, 77.649431)); + route.add(new LatLng(12.9745401, 77.648761)); + route.add(new LatLng(12.97455, 77.64869)); + route.add(new LatLng(12.9745202, 77.64864)); + route.add(new LatLng(12.97442, 77.648591)); + route.add(new LatLng(12.9744001, 77.648541)); + route.add(new LatLng(12.9743802, 77.648451)); + route.add(new LatLng(12.9743501, 77.647991)); + route.add(new LatLng(12.9743501, 77.64761)); + route.add(new LatLng(12.97503, 77.647561)); + route.add(new LatLng(12.9749902, 77.64686)); + route.add(new LatLng(12.9740701, 77.64691)); + route.add(new LatLng(12.9740701, 77.64685)); + route.add(new LatLng(12.97399, 77.64537)); + route.add(new LatLng(12.9739102, 77.643531)); + route.add(new LatLng(12.97389, 77.643081)); + route.add(new LatLng(12.97334, 77.643121)); + route.add(new LatLng(12.9733201, 77.64265)); + route.add(new LatLng(12.9731102, 77.64266)); + return route; + } + + private static ArrayList getRoute12() { + ArrayList route = new ArrayList<>(); + route.add(new LatLng(12.9750501, 77.644641)); + route.add(new LatLng(12.9750501, 77.6435)); + route.add(new LatLng(12.9744501, 77.64351)); + route.add(new LatLng(12.9739102, 77.643531)); + route.add(new LatLng(12.97389, 77.643081)); + route.add(new LatLng(12.9738602, 77.641771)); + route.add(new LatLng(12.97385, 77.641141)); + route.add(new LatLng(12.9734501, 77.64116)); + route.add(new LatLng(12.9720001, 77.641241)); + route.add(new LatLng(12.9701801, 77.6413)); + route.add(new LatLng(12.9688502, 77.6414)); + route.add(new LatLng(12.96784, 77.64144)); + route.add(new LatLng(12.96696, 77.64148)); + route.add(new LatLng(12.9668401, 77.641501)); + route.add(new LatLng(12.9665902, 77.64234)); + route.add(new LatLng(12.9664502, 77.642671)); + route.add(new LatLng(12.96639, 77.642901)); + route.add(new LatLng(12.9662, 77.644061)); + route.add(new LatLng(12.9661901, 77.644191)); + route.add(new LatLng(12.9659501, 77.64413)); + route.add(new LatLng(12.96569, 77.644111)); + route.add(new LatLng(12.9654702, 77.644101)); + route.add(new LatLng(12.96513, 77.644061)); + route.add(new LatLng(12.9643601, 77.643921)); + route.add(new LatLng(12.96413, 77.64489)); + return route; + } + + private static ArrayList getRoute13() { + ArrayList route = new ArrayList<>(); + route.add(new LatLng(12.9658501, 77.636621)); + route.add(new LatLng(12.9658902, 77.636581)); + route.add(new LatLng(12.96615, 77.63691)); + route.add(new LatLng(12.9665201, 77.63664)); + route.add(new LatLng(12.96686, 77.63706)); + route.add(new LatLng(12.9669702, 77.637121)); + route.add(new LatLng(12.96808, 77.63724)); + route.add(new LatLng(12.9682501, 77.637291)); + route.add(new LatLng(12.9683001, 77.637351)); + route.add(new LatLng(12.96836, 77.63848)); + route.add(new LatLng(12.9684202, 77.639321)); + route.add(new LatLng(12.9685, 77.640121)); + route.add(new LatLng(12.9685301, 77.64069)); + route.add(new LatLng(12.9685801, 77.641281)); + route.add(new LatLng(12.9686102, 77.64203)); + route.add(new LatLng(12.9686, 77.6427)); + route.add(new LatLng(12.96864, 77.6435)); + route.add(new LatLng(12.9686701, 77.64484)); + route.add(new LatLng(12.9687002, 77.64561)); + route.add(new LatLng(12.9688402, 77.6477)); + route.add(new LatLng(12.9688402, 77.647771)); + route.add(new LatLng(12.96892, 77.647771)); + route.add(new LatLng(12.9688902, 77.647821)); + route.add(new LatLng(12.96887, 77.647991)); + route.add(new LatLng(12.9687502, 77.64875)); + route.add(new LatLng(12.9692301, 77.648811)); + route.add(new LatLng(12.9699401, 77.64891)); + route.add(new LatLng(12.9699702, 77.64972)); + return route; + } + + private static ArrayList getRoute14() { + ArrayList route = new ArrayList<>(); + route.add(new LatLng(12.9742101, 77.63459)); + route.add(new LatLng(12.9739301, 77.63459)); + route.add(new LatLng(12.97371, 77.6346)); + route.add(new LatLng(12.9733601, 77.634651)); + route.add(new LatLng(12.97328, 77.634701)); + route.add(new LatLng(12.97324, 77.634801)); + route.add(new LatLng(12.9729702, 77.63473)); + route.add(new LatLng(12.973, 77.634891)); + route.add(new LatLng(12.9730301, 77.635191)); + route.add(new LatLng(12.9731202, 77.6359)); + route.add(new LatLng(12.9727101, 77.63594)); + route.add(new LatLng(12.9720001, 77.63599)); + route.add(new LatLng(12.9716701, 77.63597)); + route.add(new LatLng(12.9715, 77.63598)); + route.add(new LatLng(12.9704402, 77.63597)); + route.add(new LatLng(12.9698501, 77.635951)); + route.add(new LatLng(12.96934, 77.63598)); + route.add(new LatLng(12.9694301, 77.637621)); + route.add(new LatLng(12.9694701, 77.63843)); + route.add(new LatLng(12.9695502, 77.639271)); + route.add(new LatLng(12.9696101, 77.640161)); + route.add(new LatLng(12.96855, 77.64024)); + route.add(new LatLng(12.96851, 77.64024)); + route.add(new LatLng(12.96851, 77.64028)); + route.add(new LatLng(12.9685301, 77.64069)); + route.add(new LatLng(12.9685801, 77.641281)); + route.add(new LatLng(12.9686, 77.6414)); + route.add(new LatLng(12.96784, 77.64144)); + route.add(new LatLng(12.96696, 77.64148)); + route.add(new LatLng(12.9637802, 77.641641)); + route.add(new LatLng(12.9633201, 77.64166)); + route.add(new LatLng(12.96264, 77.641691)); + route.add(new LatLng(12.96254, 77.64243)); + route.add(new LatLng(12.9623702, 77.643751)); + route.add(new LatLng(12.96231, 77.64408)); + route.add(new LatLng(12.9631801, 77.644291)); + + return route; + } + + private static ArrayList getRoute15() { + ArrayList route = new ArrayList<>(); + route.add(new LatLng(12.9728802, 77.64905)); + route.add(new LatLng(12.97278, 77.649441)); + route.add(new LatLng(12.9727101, 77.649831)); + route.add(new LatLng(12.9726502, 77.65013)); + route.add(new LatLng(12.9726002, 77.65016)); + route.add(new LatLng(12.97239, 77.650141)); + route.add(new LatLng(12.9724102, 77.650331)); + route.add(new LatLng(12.9724602, 77.65061)); + route.add(new LatLng(12.9721401, 77.65067)); + route.add(new LatLng(12.9715401, 77.650771)); + route.add(new LatLng(12.9714401, 77.650781)); + route.add(new LatLng(12.9714202, 77.650561)); + route.add(new LatLng(12.97127, 77.649621)); + route.add(new LatLng(12.97123, 77.649391)); + route.add(new LatLng(12.97112, 77.648681)); + route.add(new LatLng(12.97103, 77.64838)); + route.add(new LatLng(12.97098, 77.647911)); + route.add(new LatLng(12.97095, 77.64731)); + route.add(new LatLng(12.9704601, 77.647411)); + route.add(new LatLng(12.97042, 77.64685)); + route.add(new LatLng(12.97038, 77.64551)); + route.add(new LatLng(12.9691302, 77.645581)); + route.add(new LatLng(12.9687002, 77.64561)); + route.add(new LatLng(12.96794, 77.64564)); + route.add(new LatLng(12.9677202, 77.64564)); + route.add(new LatLng(12.9676302, 77.64557)); + route.add(new LatLng(12.9676001, 77.645441)); + route.add(new LatLng(12.9675802, 77.64448)); + route.add(new LatLng(12.9674902, 77.64275)); + route.add(new LatLng(12.9675001, 77.64206)); + route.add(new LatLng(12.9674902, 77.64144)); + route.add(new LatLng(12.96696, 77.64148)); + route.add(new LatLng(12.9668401, 77.641501)); + route.add(new LatLng(12.96685, 77.641421)); + route.add(new LatLng(12.9670801, 77.64059)); + route.add(new LatLng(12.96723, 77.640131)); + route.add(new LatLng(12.9671201, 77.639851)); + route.add(new LatLng(12.9670701, 77.639591)); + return route; + } + + private static ArrayList getRoute16() { + ArrayList route = new ArrayList<>(); + route.add(new LatLng(12.9631301, 77.63907)); + route.add(new LatLng(12.9633102, 77.638771)); + route.add(new LatLng(12.96362, 77.63839)); + route.add(new LatLng(12.9631702, 77.63814)); + route.add(new LatLng(12.9626502, 77.63782)); + route.add(new LatLng(12.96236, 77.637611)); + route.add(new LatLng(12.9616702, 77.638191)); + route.add(new LatLng(12.96119, 77.638641)); + route.add(new LatLng(12.96109, 77.638691)); + route.add(new LatLng(12.96105, 77.6387)); + route.add(new LatLng(12.9610301, 77.63898)); + route.add(new LatLng(12.9608901, 77.63956)); + route.add(new LatLng(12.9608301, 77.64009)); + route.add(new LatLng(12.96076, 77.64073)); + route.add(new LatLng(12.9606901, 77.641831)); + route.add(new LatLng(12.9605501, 77.642941)); + route.add(new LatLng(12.96047, 77.64337)); + route.add(new LatLng(12.96062, 77.643381)); + route.add(new LatLng(12.96127, 77.64341)); + route.add(new LatLng(12.96146, 77.643441)); + route.add(new LatLng(12.96241, 77.64346)); + route.add(new LatLng(12.96291, 77.64355)); + route.add(new LatLng(12.96352, 77.643711)); + route.add(new LatLng(12.9639301, 77.64381)); + route.add(new LatLng(12.9643601, 77.643921)); + route.add(new LatLng(12.96414, 77.64484)); + route.add(new LatLng(12.96465, 77.64498)); + route.add(new LatLng(12.9649502, 77.64502)); + route.add(new LatLng(12.9647701, 77.6456)); + return route; + } + + private static ArrayList getRoute17() { + ArrayList route = new ArrayList<>(); + route.add(new LatLng(12.97577, 77.63826)); + route.add(new LatLng(12.97601, 77.63826)); + route.add(new LatLng(12.9760302, 77.638951)); + route.add(new LatLng(12.9760702, 77.63988)); + route.add(new LatLng(12.9760801, 77.64019)); + route.add(new LatLng(12.97572, 77.64022)); + route.add(new LatLng(12.9741902, 77.64028)); + route.add(new LatLng(12.9734101, 77.64031)); + route.add(new LatLng(12.97343, 77.641071)); + route.add(new LatLng(12.9738401, 77.64105)); + route.add(new LatLng(12.97385, 77.641141)); + route.add(new LatLng(12.97389, 77.642681)); + route.add(new LatLng(12.9739102, 77.643531)); + route.add(new LatLng(12.9739602, 77.64481)); + route.add(new LatLng(12.9726902, 77.644861)); + route.add(new LatLng(12.9716301, 77.64494)); + route.add(new LatLng(12.9716201, 77.644591)); + return route; + } - public static List getRoute() { - List mFinalRoute = new ArrayList<>(); - mFinalRoute.add(new LatLng(12.94695, 77.64058)); - mFinalRoute.add(new LatLng(12.94735, 77.64076)); - mFinalRoute.add(new LatLng(12.9476, 77.64081)); - mFinalRoute.add(new LatLng(12.94786, 77.64078)); - mFinalRoute.add(new LatLng(12.94809, 77.6407)); - mFinalRoute.add(new LatLng(12.9483, 77.64058)); - mFinalRoute.add(new LatLng(12.9486, 77.64029)); - mFinalRoute.add(new LatLng(12.94928, 77.63952)); - mFinalRoute.add(new LatLng(12.94946, 77.63936)); - mFinalRoute.add(new LatLng(12.94967, 77.63923)); - mFinalRoute.add(new LatLng(12.94984, 77.63917)); - mFinalRoute.add(new LatLng(12.95006, 77.63912)); - mFinalRoute.add(new LatLng(12.95036, 77.63913)); - mFinalRoute.add(new LatLng(12.95062, 77.63922)); - mFinalRoute.add(new LatLng(12.9517, 77.63978)); - mFinalRoute.add(new LatLng(12.95267, 77.64038)); - mFinalRoute.add(new LatLng(12.95418, 77.64121)); - mFinalRoute.add(new LatLng(12.95443, 77.64125)); - mFinalRoute.add(new LatLng(12.9556, 77.64133)); - mFinalRoute.add(new LatLng(12.95609, 77.64135)); - mFinalRoute.add(new LatLng(12.95698, 77.64136)); - mFinalRoute.add(new LatLng(12.95782, 77.64131)); - mFinalRoute.add(new LatLng(12.95797, 77.64132)); - mFinalRoute.add(new LatLng(12.95818, 77.64135)); + private static ArrayList getRoute18() { + ArrayList route = new ArrayList<>(); + route.add(new LatLng(12.9587301, 77.639411)); + route.add(new LatLng(12.9588601, 77.63845)); + route.add(new LatLng(12.9588601, 77.63836)); + route.add(new LatLng(12.9602301, 77.63854)); + route.add(new LatLng(12.96076, 77.638601)); + route.add(new LatLng(12.96095, 77.638691)); + route.add(new LatLng(12.96105, 77.6387)); + route.add(new LatLng(12.9610301, 77.63898)); + route.add(new LatLng(12.9608901, 77.63956)); + route.add(new LatLng(12.9608301, 77.64009)); + route.add(new LatLng(12.96076, 77.64073)); + route.add(new LatLng(12.9606901, 77.641831)); + route.add(new LatLng(12.9605501, 77.642941)); + route.add(new LatLng(12.96047, 77.64337)); + route.add(new LatLng(12.96034, 77.644551)); + route.add(new LatLng(12.9602, 77.645591)); + route.add(new LatLng(12.96133, 77.645801)); + route.add(new LatLng(12.9621101, 77.64591)); + route.add(new LatLng(12.96264, 77.646021)); + route.add(new LatLng(12.9627101, 77.645711)); - return mFinalRoute; - } + return route; + } - public static List getRouteB() { - List mFinalRoute = new ArrayList<>(); - mFinalRoute.add(new LatLng(12.95848, 77.64139)); - mFinalRoute.add(new LatLng(12.95937, 77.64146)); - mFinalRoute.add(new LatLng(12.95968, 77.6415)); - mFinalRoute.add(new LatLng(12.95999, 77.64156)); - mFinalRoute.add(new LatLng(12.96031, 77.64164)); - mFinalRoute.add(new LatLng(12.96054, 77.64169)); - mFinalRoute.add(new LatLng(12.96079, 77.64171)); - mFinalRoute.add(new LatLng(12.96087, 77.64171)); - mFinalRoute.add(new LatLng(12.96099, 77.6417)); - mFinalRoute.add(new LatLng(12.96108, 77.64166)); - mFinalRoute.add(new LatLng(12.96117, 77.64162)); - mFinalRoute.add(new LatLng(12.96122, 77.64158)); - mFinalRoute.add(new LatLng(12.96127, 77.64154)); - mFinalRoute.add(new LatLng(12.96132, 77.64146)); - mFinalRoute.add(new LatLng(12.96136, 77.64131)); - mFinalRoute.add(new LatLng(12.96135, 77.64108)); - mFinalRoute.add(new LatLng(12.9613, 77.64099)); - mFinalRoute.add(new LatLng(12.9612, 77.6409)); - mFinalRoute.add(new LatLng(12.96107, 77.64086)); - mFinalRoute.add(new LatLng(12.96099, 77.64086)); - mFinalRoute.add(new LatLng(12.96091, 77.64089)); - mFinalRoute.add(new LatLng(12.96082, 77.64096)); - mFinalRoute.add(new LatLng(12.96073, 77.64132)); - mFinalRoute.add(new LatLng(12.96066, 77.64208)); - mFinalRoute.add(new LatLng(12.96049, 77.64337)); - mFinalRoute.add(new LatLng(12.96031, 77.6451)); - mFinalRoute.add(new LatLng(12.96023, 77.64577)); - mFinalRoute.add(new LatLng(12.96014, 77.64651)); - mFinalRoute.add(new LatLng(12.96001, 77.64775)); - mFinalRoute.add(new LatLng(12.95981, 77.64909)); + private static ArrayList getRoute19() { + ArrayList route = new ArrayList<>(); + route.add(new LatLng(12.9674501, 77.6393)); + route.add(new LatLng(12.96775, 77.63942)); + route.add(new LatLng(12.96766, 77.63961)); + route.add(new LatLng(12.9675302, 77.63987)); + route.add(new LatLng(12.9674802, 77.640071)); + route.add(new LatLng(12.96746, 77.64019)); + route.add(new LatLng(12.96738, 77.640161)); + route.add(new LatLng(12.96723, 77.640131)); + route.add(new LatLng(12.9672002, 77.64018)); + route.add(new LatLng(12.9669702, 77.64099)); + route.add(new LatLng(12.9668401, 77.641501)); + route.add(new LatLng(12.96606, 77.64152)); + route.add(new LatLng(12.9634002, 77.64166)); + route.add(new LatLng(12.9625, 77.6417)); + route.add(new LatLng(12.96245, 77.64175)); + route.add(new LatLng(12.96194, 77.64179)); + route.add(new LatLng(12.9617801, 77.641821)); + route.add(new LatLng(12.9616, 77.64193)); + route.add(new LatLng(12.9615202, 77.642011)); + route.add(new LatLng(12.9614401, 77.64215)); + route.add(new LatLng(12.96118, 77.64309)); + route.add(new LatLng(12.96113, 77.64318)); + route.add(new LatLng(12.96104, 77.643291)); + route.add(new LatLng(12.9608801, 77.6434)); + route.add(new LatLng(12.96047, 77.64337)); + route.add(new LatLng(12.9602701, 77.645041)); + route.add(new LatLng(12.96011, 77.646351)); + route.add(new LatLng(12.9599901, 77.64743)); + route.add(new LatLng(12.9599302, 77.64802)); + route.add(new LatLng(12.95982, 77.649071)); + route.add(new LatLng(12.95973, 77.64906)); + route.add(new LatLng(12.95982, 77.64837)); + route.add(new LatLng(12.9599302, 77.647381)); + route.add(new LatLng(12.9600702, 77.645991)); + route.add(new LatLng(12.9598001, 77.645901)); + route.add(new LatLng(12.95959, 77.64579)); + route.add(new LatLng(12.95889, 77.645501)); + route.add(new LatLng(12.9583802, 77.64524)); + route.add(new LatLng(12.9580502, 77.6451)); + route.add(new LatLng(12.9577202, 77.64493)); + route.add(new LatLng(12.9576901, 77.644911)); + route.add(new LatLng(12.9577901, 77.64472)); + route.add(new LatLng(12.9578602, 77.644561)); + route.add(new LatLng(12.95809, 77.64386)); + return route; + } - return mFinalRoute; - } + private static ArrayList getRoute20() { + ArrayList route = new ArrayList<>(); + route.add(new LatLng(12.96982, 77.64345)); + route.add(new LatLng(12.9703201, 77.643431)); + route.add(new LatLng(12.9703101, 77.64306)); + route.add(new LatLng(12.97029, 77.642401)); + route.add(new LatLng(12.9702601, 77.6422)); + route.add(new LatLng(12.9702201, 77.64198)); + route.add(new LatLng(12.9701801, 77.6413)); + route.add(new LatLng(12.9688502, 77.6414)); + route.add(new LatLng(12.96784, 77.64144)); + route.add(new LatLng(12.96696, 77.64148)); + route.add(new LatLng(12.9668401, 77.641501)); + route.add(new LatLng(12.9665902, 77.64234)); + route.add(new LatLng(12.9664502, 77.642671)); + route.add(new LatLng(12.96639, 77.642901)); + route.add(new LatLng(12.9662, 77.644061)); + route.add(new LatLng(12.96616, 77.64457)); + route.add(new LatLng(12.9661301, 77.64476)); + route.add(new LatLng(12.9660901, 77.64488)); + route.add(new LatLng(12.9659901, 77.64515)); + route.add(new LatLng(12.9657902, 77.64546)); + route.add(new LatLng(12.9655201, 77.64579)); + route.add(new LatLng(12.9651402, 77.646021)); + return route; + } - public static List getTokyoRoute() { - List mFinalRoute = new ArrayList<>(); - mFinalRoute.add(new LatLng(35.64719, 139.79163)); - mFinalRoute.add(new LatLng(35.64733, 139.7918)); - mFinalRoute.add(new LatLng(35.64752, 139.7919)); - mFinalRoute.add(new LatLng(35.64765, 139.79196)); - mFinalRoute.add(new LatLng(35.6478, 139.79198)); - mFinalRoute.add(new LatLng(35.64806, 139.79196)); - mFinalRoute.add(new LatLng(35.64818, 139.79193)); - mFinalRoute.add(new LatLng(35.6483, 139.79185)); - mFinalRoute.add(new LatLng(35.64847, 139.79172)); - mFinalRoute.add(new LatLng(35.6486, 139.79156)); - mFinalRoute.add(new LatLng(35.64917, 139.79091)); - mFinalRoute.add(new LatLng(35.64914, 139.79088)); - mFinalRoute.add(new LatLng(35.64846, 139.78989)); - mFinalRoute.add(new LatLng(35.64807, 139.78926)); - mFinalRoute.add(new LatLng(35.64769, 139.78963)); - mFinalRoute.add(new LatLng(35.64748, 139.78976)); - mFinalRoute.add(new LatLng(35.64702, 139.79014)); - mFinalRoute.add(new LatLng(35.64635, 139.79064)); - mFinalRoute.add(new LatLng(35.64596, 139.79095)); - mFinalRoute.add(new LatLng(35.64371, 139.79272)); - mFinalRoute.add(new LatLng(35.64293, 139.79335)); - mFinalRoute.add(new LatLng(35.64274, 139.79346)); - mFinalRoute.add(new LatLng(35.6418, 139.79429)); - mFinalRoute.add(new LatLng(35.64019, 139.79558)); - mFinalRoute.add(new LatLng(35.63922, 139.79637)); - mFinalRoute.add(new LatLng(35.63884, 139.79663)); - mFinalRoute.add(new LatLng(35.63851, 139.79674)); - mFinalRoute.add(new LatLng(35.63836, 139.79675)); - mFinalRoute.add(new LatLng(35.63825, 139.79673)); - mFinalRoute.add(new LatLng(35.63809, 139.7967)); - mFinalRoute.add(new LatLng(35.63784, 139.79657)); - mFinalRoute.add(new LatLng(35.63765, 139.79641)); - mFinalRoute.add(new LatLng(35.63747, 139.7962)); - mFinalRoute.add(new LatLng(35.63704, 139.7954)); - mFinalRoute.add(new LatLng(35.63652, 139.79446)); - mFinalRoute.add(new LatLng(35.63583, 139.79319)); - mFinalRoute.add(new LatLng(35.63523, 139.79204)); - mFinalRoute.add(new LatLng(35.63488, 139.79132)); - mFinalRoute.add(new LatLng(35.63469, 139.79085)); - mFinalRoute.add(new LatLng(35.63411, 139.78981)); - mFinalRoute.add(new LatLng(35.63359, 139.78882)); - mFinalRoute.add(new LatLng(35.63337, 139.78853)); - mFinalRoute.add(new LatLng(35.6331, 139.78814)); - mFinalRoute.add(new LatLng(35.63268, 139.7874)); - mFinalRoute.add(new LatLng(35.63173, 139.78565)); - mFinalRoute.add(new LatLng(35.6315, 139.78513)); - mFinalRoute.add(new LatLng(35.63141, 139.78472)); - mFinalRoute.add(new LatLng(35.6314, 139.78439)); - mFinalRoute.add(new LatLng(35.63145, 139.78403)); - mFinalRoute.add(new LatLng(35.63154, 139.78373)); - mFinalRoute.add(new LatLng(35.63171, 139.78343)); - mFinalRoute.add(new LatLng(35.63199, 139.78305)); - mFinalRoute.add(new LatLng(35.63355, 139.7814)); - mFinalRoute.add(new LatLng(35.63478, 139.78039)); - mFinalRoute.add(new LatLng(35.63519, 139.77999)); - mFinalRoute.add(new LatLng(35.63546, 139.77968)); - mFinalRoute.add(new LatLng(35.63561, 139.77943)); - mFinalRoute.add(new LatLng(35.63578, 139.77918)); - mFinalRoute.add(new LatLng(35.6359, 139.77893)); - mFinalRoute.add(new LatLng(35.63617, 139.77829)); - mFinalRoute.add(new LatLng(35.63628, 139.77793)); - mFinalRoute.add(new LatLng(35.63635, 139.77757)); - mFinalRoute.add(new LatLng(35.63645, 139.77696)); - mFinalRoute.add(new LatLng(35.63646, 139.77623)); - mFinalRoute.add(new LatLng(35.6364, 139.77555)); - mFinalRoute.add(new LatLng(35.63626, 139.77471)); - mFinalRoute.add(new LatLng(35.63609, 139.77403)); - mFinalRoute.add(new LatLng(35.63582, 139.77314)); - mFinalRoute.add(new LatLng(35.63549, 139.77222)); - mFinalRoute.add(new LatLng(35.63497, 139.77072)); - mFinalRoute.add(new LatLng(35.63484, 139.77019)); - mFinalRoute.add(new LatLng(35.63479, 139.76986)); - mFinalRoute.add(new LatLng(35.63478, 139.76956)); - mFinalRoute.add(new LatLng(35.6348, 139.7691)); - mFinalRoute.add(new LatLng(35.63487, 139.76851)); - mFinalRoute.add(new LatLng(35.635, 139.76795)); - mFinalRoute.add(new LatLng(35.6354, 139.7667)); - mFinalRoute.add(new LatLng(35.63652, 139.76318)); - mFinalRoute.add(new LatLng(35.63752, 139.76002)); - mFinalRoute.add(new LatLng(35.63781, 139.75913)); - mFinalRoute.add(new LatLng(35.63793, 139.75885)); - mFinalRoute.add(new LatLng(35.6381, 139.75853)); - mFinalRoute.add(new LatLng(35.63834, 139.75823)); - mFinalRoute.add(new LatLng(35.63861, 139.75801)); - mFinalRoute.add(new LatLng(35.63884, 139.75788)); - return mFinalRoute; - } + private static ArrayList getRoute21() { + ArrayList route = new ArrayList<>(); + route.add(new LatLng(12.96714, 77.63919)); + route.add(new LatLng(12.9670701, 77.63956)); + route.add(new LatLng(12.9670801, 77.639721)); + route.add(new LatLng(12.96723, 77.640131)); + route.add(new LatLng(12.9670801, 77.64059)); + route.add(new LatLng(12.96685, 77.641421)); + route.add(new LatLng(12.9685801, 77.641281)); + route.add(new LatLng(12.9694301, 77.641241)); + route.add(new LatLng(12.9702701, 77.641191)); + route.add(new LatLng(12.97343, 77.641071)); + route.add(new LatLng(12.9761, 77.64094)); + route.add(new LatLng(12.9760901, 77.640341)); + route.add(new LatLng(12.97605, 77.63946)); + route.add(new LatLng(12.9760302, 77.638951)); + route.add(new LatLng(12.9760302, 77.63858)); + route.add(new LatLng(12.9750402, 77.638641)); + return route; + } - public static List getNewYorkRoute() { - List mFinalRoute = new ArrayList<>(); - mFinalRoute.add(new LatLng(40.69293, -73.90815)); - mFinalRoute.add(new LatLng(40.69455, -73.90654)); - mFinalRoute.add(new LatLng(40.69375, -73.90513)); - mFinalRoute.add(new LatLng(40.69304, -73.90387)); - mFinalRoute.add(new LatLng(40.69242, -73.90278)); - mFinalRoute.add(new LatLng(40.69267, -73.90255)); - mFinalRoute.add(new LatLng(40.69283, -73.90238)); - mFinalRoute.add(new LatLng(40.69289, -73.90224)); - mFinalRoute.add(new LatLng(40.69343, -73.90005)); - mFinalRoute.add(new LatLng(40.69347, -73.8999)); - mFinalRoute.add(new LatLng(40.69386, -73.89871)); - mFinalRoute.add(new LatLng(40.69394, -73.89831)); - mFinalRoute.add(new LatLng(40.69411, -73.89733)); - mFinalRoute.add(new LatLng(40.69384, -73.89691)); - mFinalRoute.add(new LatLng(40.69319, -73.89574)); - mFinalRoute.add(new LatLng(40.69266, -73.89479)); - mFinalRoute.add(new LatLng(40.69185, -73.89204)); - mFinalRoute.add(new LatLng(40.69141, -73.89059)); - mFinalRoute.add(new LatLng(40.69107, -73.89054)); - mFinalRoute.add(new LatLng(40.69089, -73.89052)); - mFinalRoute.add(new LatLng(40.69088, -73.89026)); - mFinalRoute.add(new LatLng(40.69084, -73.89006)); - mFinalRoute.add(new LatLng(40.69079, -73.88998)); - mFinalRoute.add(new LatLng(40.69073, -73.88992)); - mFinalRoute.add(new LatLng(40.69059, -73.88986)); - mFinalRoute.add(new LatLng(40.69051, -73.88986)); - mFinalRoute.add(new LatLng(40.69043, -73.88989)); - mFinalRoute.add(new LatLng(40.69026, -73.89001)); - mFinalRoute.add(new LatLng(40.69009, -73.89015)); - mFinalRoute.add(new LatLng(40.68997, -73.89019)); - mFinalRoute.add(new LatLng(40.68974, -73.89038)); - mFinalRoute.add(new LatLng(40.68849, -73.89139)); - mFinalRoute.add(new LatLng(40.68787, -73.89188)); - mFinalRoute.add(new LatLng(40.68692, -73.89266)); - mFinalRoute.add(new LatLng(40.68638, -73.89312)); - mFinalRoute.add(new LatLng(40.68557, -73.89393)); - mFinalRoute.add(new LatLng(40.68497, -73.89454)); - mFinalRoute.add(new LatLng(40.68441, -73.89507)); - mFinalRoute.add(new LatLng(40.68385, -73.89554)); - mFinalRoute.add(new LatLng(40.68335, -73.89594)); - mFinalRoute.add(new LatLng(40.68282, -73.8963)); - mFinalRoute.add(new LatLng(40.68239, -73.89651)); - mFinalRoute.add(new LatLng(40.6821, -73.89659)); - mFinalRoute.add(new LatLng(40.68177, -73.89661)); - mFinalRoute.add(new LatLng(40.68085, -73.89668)); - mFinalRoute.add(new LatLng(40.68062, -73.89672)); - mFinalRoute.add(new LatLng(40.68021, -73.89682)); - mFinalRoute.add(new LatLng(40.67958, -73.89707)); - mFinalRoute.add(new LatLng(40.67893, -73.89741)); - mFinalRoute.add(new LatLng(40.6786, -73.89747)); - mFinalRoute.add(new LatLng(40.67835, -73.89752)); - mFinalRoute.add(new LatLng(40.67821, -73.89753)); - mFinalRoute.add(new LatLng(40.67806, -73.89759)); - mFinalRoute.add(new LatLng(40.67795, -73.89742)); - mFinalRoute.add(new LatLng(40.67721, -73.89722)); - mFinalRoute.add(new LatLng(40.67597, -73.89691)); - mFinalRoute.add(new LatLng(40.6756, -73.89683)); - mFinalRoute.add(new LatLng(40.67294, -73.89614)); - mFinalRoute.add(new LatLng(40.66937, -73.89522)); - mFinalRoute.add(new LatLng(40.6663, -73.89444)); - mFinalRoute.add(new LatLng(40.66476, -73.89406)); - mFinalRoute.add(new LatLng(40.66322, -73.89364)); - mFinalRoute.add(new LatLng(40.66256, -73.89348)); - mFinalRoute.add(new LatLng(40.66234, -73.89341)); - mFinalRoute.add(new LatLng(40.66205, -73.89326)); - mFinalRoute.add(new LatLng(40.66167, -73.89298)); - mFinalRoute.add(new LatLng(40.66145, -73.89278)); - mFinalRoute.add(new LatLng(40.66088, -73.89235)); - mFinalRoute.add(new LatLng(40.65993, -73.89164)); - mFinalRoute.add(new LatLng(40.65909, -73.89104)); - mFinalRoute.add(new LatLng(40.65884, -73.89085)); - mFinalRoute.add(new LatLng(40.65869, -73.89081)); - mFinalRoute.add(new LatLng(40.65859, -73.89075)); - mFinalRoute.add(new LatLng(40.65839, -73.89059)); - mFinalRoute.add(new LatLng(40.65694, -73.88948)); - mFinalRoute.add(new LatLng(40.65546, -73.88839)); - mFinalRoute.add(new LatLng(40.65365, -73.88703)); - mFinalRoute.add(new LatLng(40.65279, -73.8864)); - mFinalRoute.add(new LatLng(40.65267, -73.88636)); - mFinalRoute.add(new LatLng(40.65232, -73.88609)); - mFinalRoute.add(new LatLng(40.65119, -73.88522)); - mFinalRoute.add(new LatLng(40.65073, -73.88489)); - mFinalRoute.add(new LatLng(40.65023, -73.88451)); - mFinalRoute.add(new LatLng(40.65007, -73.88435)); - return mFinalRoute; - } + private static ArrayList getRoute22() { + ArrayList route = new ArrayList<>(); + route.add(new LatLng(12.9750501, 77.644011)); + route.add(new LatLng(12.9750501, 77.6435)); + route.add(new LatLng(12.9744501, 77.64351)); + route.add(new LatLng(12.9739102, 77.643531)); + route.add(new LatLng(12.97389, 77.643081)); + route.add(new LatLng(12.9726101, 77.64319)); + route.add(new LatLng(12.9716, 77.643211)); + route.add(new LatLng(12.97047, 77.64328)); + route.add(new LatLng(12.9703201, 77.643291)); + route.add(new LatLng(12.9703201, 77.643431)); + route.add(new LatLng(12.97034, 77.64407)); + route.add(new LatLng(12.97014, 77.64408)); + return route; + } - public static List getIndiranagarBounds() { - List latLngs = new ArrayList<>(); - latLngs.add(new LatLng(12.9715002,77.6374856));//NW - latLngs.add(new LatLng(12.9703733,77.6372037));//NE - latLngs.add(new LatLng(12.9595674,77.6366595));//SE - latLngs.add(new LatLng(12.9595672,77.6519803));//SW - return latLngs; - } + private static ArrayList getRoute23() { + ArrayList route = new ArrayList<>(); + route.add(new LatLng(12.97577, 77.64529)); + route.add(new LatLng(12.9757601, 77.644861)); + route.add(new LatLng(12.9757101, 77.64346)); + route.add(new LatLng(12.9750501, 77.6435)); + route.add(new LatLng(12.9739102, 77.643531)); + route.add(new LatLng(12.97389, 77.642681)); + route.add(new LatLng(12.97385, 77.641141)); + route.add(new LatLng(12.9738401, 77.64105)); + route.add(new LatLng(12.9761, 77.64094)); + route.add(new LatLng(12.9760901, 77.640341)); + route.add(new LatLng(12.9760702, 77.63988)); + route.add(new LatLng(12.97605, 77.63946)); + route.add(new LatLng(12.9760302, 77.63898)); + route.add(new LatLng(12.9751401, 77.639011)); + route.add(new LatLng(12.9745202, 77.639041)); + route.add(new LatLng(12.9745, 77.6389)); + route.add(new LatLng(12.9744802, 77.638591)); + route.add(new LatLng(12.97446, 77.63826)); + route.add(new LatLng(12.9744001, 77.63799)); + route.add(new LatLng(12.9743501, 77.637891)); + route.add(new LatLng(12.9744501, 77.637841)); + route.add(new LatLng(12.97456, 77.63778)); + route.add(new LatLng(12.9745702, 77.63778)); + return route; + } - //Indiranagar routes - public static ArrayList getIndiranagarRoutes() { - ArrayList carRoute = new ArrayList<>(); - carRoute.add(getCarForRoute(getRoute1(), 1)); - carRoute.add(getCarForRoute(getRoute2(), 2)); - carRoute.add(getCarForRoute(getRoute3(), 3)); - carRoute.add(getCarForRoute(getRoute4(), 4)); - carRoute.add(getCarForRoute(getRoute5(), 5)); - carRoute.add(getCarForRoute(getRoute6(), 6)); - carRoute.add(getCarForRoute(getRoute7(), 7)); - carRoute.add(getCarForRoute(getRoute8(), 8)); - carRoute.add(getCarForRoute(getRoute9(), 9)); - carRoute.add(getCarForRoute(getRoute10(), 10)); - carRoute.add(getCarForRoute(getRoute11(), 11)); - carRoute.add(getCarForRoute(getRoute12(), 12)); - carRoute.add(getCarForRoute(getRoute13(), 13)); - carRoute.add(getCarForRoute(getRoute14(), 14)); - carRoute.add(getCarForRoute(getRoute15(), 15)); - carRoute.add(getCarForRoute(getRoute16(), 16)); - carRoute.add(getCarForRoute(getRoute17(), 17)); - carRoute.add(getCarForRoute(getRoute18(), 18)); - carRoute.add(getCarForRoute(getRoute19(), 19)); - carRoute.add(getCarForRoute(getRoute20(), 20)); - carRoute.add(getCarForRoute(getRoute21(), 21)); - carRoute.add(getCarForRoute(getRoute22(), 22)); - carRoute.add(getCarForRoute(getRoute23(), 23)); - carRoute.add(getCarForRoute(getRoute24(), 24)); - carRoute.add(getCarForRoute(getRoute25(), 25)); - carRoute.add(getCarForRoute(getRoute26(), 26)); - carRoute.add(getCarForRoute(getRoute27(), 27)); - carRoute.add(getCarForRoute(getRoute28(), 28)); - return carRoute; - } + private static ArrayList getRoute24() { + ArrayList route = new ArrayList<>(); + route.add(new LatLng(12.9738, 77.637831)); + route.add(new LatLng(12.9736802, 77.63787)); + route.add(new LatLng(12.9737202, 77.63812)); + route.add(new LatLng(12.97375, 77.638461)); + route.add(new LatLng(12.97375, 77.638471)); + route.add(new LatLng(12.97334, 77.638501)); + route.add(new LatLng(12.97338, 77.639411)); + route.add(new LatLng(12.97343, 77.641071)); + route.add(new LatLng(12.9738401, 77.64105)); + route.add(new LatLng(12.97385, 77.641141)); + route.add(new LatLng(12.97389, 77.642681)); + route.add(new LatLng(12.9739102, 77.643531)); + route.add(new LatLng(12.9739602, 77.64481)); + route.add(new LatLng(12.9726902, 77.644861)); + route.add(new LatLng(12.9716301, 77.64494)); + route.add(new LatLng(12.97089, 77.64494)); + route.add(new LatLng(12.9709102, 77.64561)); + route.add(new LatLng(12.9709102, 77.64636)); + route.add(new LatLng(12.97141, 77.646351)); + return route; + } - private static Car getCarForRoute(List latLngs, int count) { - Car car = new Car(); - car.setCarId(count); - car.setCurrentPointer(0); - car.setRoute(latLngs); - return car; - } + private static ArrayList getRoute25() { + ArrayList route = new ArrayList<>(); + route.add(new LatLng(12.9783702, 77.64228)); + route.add(new LatLng(12.9783, 77.640261)); + route.add(new LatLng(12.9782501, 77.63934)); + route.add(new LatLng(12.9782401, 77.63888)); + route.add(new LatLng(12.97807, 77.63888)); + route.add(new LatLng(12.9775901, 77.63885)); + route.add(new LatLng(12.97723, 77.638921)); + route.add(new LatLng(12.9766901, 77.638951)); + route.add(new LatLng(12.9760302, 77.63898)); + route.add(new LatLng(12.9760302, 77.638951)); + route.add(new LatLng(12.9760302, 77.63858)); + route.add(new LatLng(12.9756502, 77.63861)); + return route; + } - private static ArrayList getRoute1() { - ArrayList route = new ArrayList<>(); - route.add(new LatLng(12.9710101, 77.638021)); - route.add(new LatLng(12.97104, 77.638741)); - route.add(new LatLng(12.97057, 77.638771)); - route.add(new LatLng(12.9695002, 77.6388)); - route.add(new LatLng(12.96837, 77.63888)); - route.add(new LatLng(12.9684202, 77.639321)); - route.add(new LatLng(12.9685, 77.640121)); - route.add(new LatLng(12.9685301, 77.64069)); - route.add(new LatLng(12.9685801, 77.641281)); - route.add(new LatLng(12.9686, 77.6414)); - route.add(new LatLng(12.96784, 77.64144)); - route.add(new LatLng(12.96696, 77.64148)); - route.add(new LatLng(12.9668401, 77.641501)); - route.add(new LatLng(12.9665902, 77.64234)); - route.add(new LatLng(12.9664502, 77.642671)); - route.add(new LatLng(12.96639, 77.642901)); - route.add(new LatLng(12.9662, 77.644061)); - route.add(new LatLng(12.96616, 77.64457)); - route.add(new LatLng(12.9661301, 77.64476)); - route.add(new LatLng(12.9659901, 77.64515)); - route.add(new LatLng(12.9657902, 77.64546)); - route.add(new LatLng(12.96569, 77.6456)); - route.add(new LatLng(12.9655201, 77.64579)); - route.add(new LatLng(12.96531, 77.64592)); - route.add(new LatLng(12.96513, 77.646031)); - return route; - } - private static ArrayList getRoute2() { - ArrayList route = new ArrayList<>(); - route.add(new LatLng(12.9694602, 77.63812)); - route.add(new LatLng(12.9695002, 77.6388)); - route.add(new LatLng(12.96959, 77.6397)); - route.add(new LatLng(12.9696101, 77.640161)); - route.add(new LatLng(12.96958, 77.640161)); - route.add(new LatLng(12.96851, 77.64024)); - route.add(new LatLng(12.9685301, 77.64073)); - route.add(new LatLng(12.9686, 77.6414)); - route.add(new LatLng(12.9686102, 77.64203)); - route.add(new LatLng(12.9686, 77.6427)); - route.add(new LatLng(12.96865, 77.644141)); - route.add(new LatLng(12.9687002, 77.64561)); - route.add(new LatLng(12.96874, 77.64632)); - return route; - } - private static ArrayList getRoute3() { - ArrayList route = new ArrayList<>(); - route.add(new LatLng(12.97633, 77.6379)); - route.add(new LatLng(12.97601, 77.637921)); - route.add(new LatLng(12.97601, 77.63826)); - route.add(new LatLng(12.9760302, 77.638951)); - route.add(new LatLng(12.9760702, 77.63988)); - route.add(new LatLng(12.9760801, 77.64019)); - route.add(new LatLng(12.97572, 77.64022)); - route.add(new LatLng(12.9741902, 77.64028)); - route.add(new LatLng(12.9734101, 77.64031)); - route.add(new LatLng(12.97343, 77.641071)); - route.add(new LatLng(12.9738401, 77.64105)); - route.add(new LatLng(12.97385, 77.641141)); - route.add(new LatLng(12.97389, 77.642681)); - route.add(new LatLng(12.9739102, 77.643531)); - route.add(new LatLng(12.97399, 77.64537)); - route.add(new LatLng(12.9740701, 77.64685)); - route.add(new LatLng(12.9740701, 77.64691)); - route.add(new LatLng(12.9736802, 77.646931)); - route.add(new LatLng(12.97352, 77.646921)); - route.add(new LatLng(12.9731102, 77.64691)); - route.add(new LatLng(12.9724201, 77.647021)); - route.add(new LatLng(12.9719601, 77.64712)); - route.add(new LatLng(12.9704601, 77.647411)); - route.add(new LatLng(12.9694, 77.64763)); - route.add(new LatLng(12.9690001, 77.647731)); - route.add(new LatLng(12.9689001, 77.64779)); - route.add(new LatLng(12.96887, 77.64802)); - route.add(new LatLng(12.9687002, 77.6491)); - route.add(new LatLng(12.96846, 77.65012)); - route.add(new LatLng(12.9684, 77.65058)); - route.add(new LatLng(12.96826, 77.6511)); - route.add(new LatLng(12.9681501, 77.65156)); - route.add(new LatLng(12.9680201, 77.652251)); - route.add(new LatLng(12.96587, 77.65139)); - route.add(new LatLng(12.96385, 77.65054)); - route.add(new LatLng(12.9632801, 77.650331)); - return route; - } - private static ArrayList getRoute4() { - ArrayList route = new ArrayList<>(); - route.add(new LatLng(12.9627201, 77.64564)); - route.add(new LatLng(12.96264, 77.646021)); - route.add(new LatLng(12.9621101, 77.64591)); - route.add(new LatLng(12.96197, 77.64588)); - route.add(new LatLng(12.9619902, 77.64542)); - route.add(new LatLng(12.9621302, 77.645441)); - route.add(new LatLng(12.9621402, 77.64543)); - route.add(new LatLng(12.9622901, 77.644411)); - route.add(new LatLng(12.9623702, 77.643751)); - route.add(new LatLng(12.96241, 77.64346)); - route.add(new LatLng(12.9626701, 77.6435)); - route.add(new LatLng(12.9632102, 77.64363)); - route.add(new LatLng(12.9633701, 77.642261)); - route.add(new LatLng(12.9633502, 77.64176)); - route.add(new LatLng(12.9633201, 77.641561)); - route.add(new LatLng(12.9635902, 77.64091)); - route.add(new LatLng(12.964, 77.640131)); - route.add(new LatLng(12.9642502, 77.639671)); - route.add(new LatLng(12.96447, 77.63929)); - route.add(new LatLng(12.96475, 77.63888)); - route.add(new LatLng(12.96362, 77.63839)); - route.add(new LatLng(12.9633502, 77.638241)); - return route; - } - private static ArrayList getRoute5() { - ArrayList route = new ArrayList<>(); - route.add(new LatLng(12.9712402, 77.643651)); - route.add(new LatLng(12.97085, 77.643661)); - route.add(new LatLng(12.9708801, 77.644511)); - route.add(new LatLng(12.97089, 77.64494)); - route.add(new LatLng(12.9703601, 77.64494)); - route.add(new LatLng(12.9703902, 77.64574)); - route.add(new LatLng(12.9704402, 77.64721)); - route.add(new LatLng(12.9704601, 77.647411)); - route.add(new LatLng(12.9701102, 77.64748)); - route.add(new LatLng(12.96958, 77.647591)); - route.add(new LatLng(12.9690802, 77.64771)); - route.add(new LatLng(12.96892, 77.647771)); - route.add(new LatLng(12.9687701, 77.647771)); - route.add(new LatLng(12.96841, 77.647831)); - route.add(new LatLng(12.96836, 77.64788)); - route.add(new LatLng(12.9680201, 77.647951)); - route.add(new LatLng(12.9675901, 77.6481)); - route.add(new LatLng(12.9671301, 77.64829)); - route.add(new LatLng(12.9670602, 77.648221)); - route.add(new LatLng(12.9653001, 77.64734)); - route.add(new LatLng(12.96494, 77.64717)); - route.add(new LatLng(12.9649101, 77.64718)); - route.add(new LatLng(12.96479, 77.64744)); - route.add(new LatLng(12.96475, 77.647551)); - route.add(new LatLng(12.9647202, 77.64752)); - route.add(new LatLng(12.9647, 77.647501)); - route.add(new LatLng(12.9640301, 77.64727)); - route.add(new LatLng(12.964, 77.64726)); - route.add(new LatLng(12.9639602, 77.64745)); - route.add(new LatLng(12.9635902, 77.647321)); - route.add(new LatLng(12.9636001, 77.64725)); - route.add(new LatLng(12.9636802, 77.64669)); - route.add(new LatLng(12.9638901, 77.645811)); - return route; - } - private static ArrayList getRoute6() { - ArrayList route = new ArrayList<>(); - route.add(new LatLng(12.97347, 77.64583)); - route.add(new LatLng(12.9734501, 77.645441)); - route.add(new LatLng(12.97339, 77.64485)); - route.add(new LatLng(12.97339, 77.644831)); - route.add(new LatLng(12.9739602, 77.64481)); - route.add(new LatLng(12.9739102, 77.643531)); - route.add(new LatLng(12.97389, 77.642681)); - route.add(new LatLng(12.9738801, 77.642351)); - return route; - } - private static ArrayList getRoute7() { - ArrayList route = new ArrayList<>(); - route.add(new LatLng(12.9617602, 77.646531)); - route.add(new LatLng(12.96193, 77.64664)); - route.add(new LatLng(12.9620402, 77.646751)); - route.add(new LatLng(12.9624202, 77.64691)); - route.add(new LatLng(12.9627502, 77.64703)); - route.add(new LatLng(12.9631301, 77.64713)); - route.add(new LatLng(12.9632701, 77.647201)); - route.add(new LatLng(12.9634002, 77.647281)); - route.add(new LatLng(12.9635902, 77.647321)); - route.add(new LatLng(12.9636802, 77.64669)); - route.add(new LatLng(12.96395, 77.645581)); - route.add(new LatLng(12.9639801, 77.64552)); - route.add(new LatLng(12.96414, 77.64484)); - route.add(new LatLng(12.9643601, 77.643921)); - route.add(new LatLng(12.9646801, 77.643981)); - return route; - } - private static ArrayList getRoute8() { - ArrayList route = new ArrayList<>(); - route.add(new LatLng(12.96527, 77.64)); - route.add(new LatLng(12.9656701, 77.64011)); - route.add(new LatLng(12.9657701, 77.64015)); - route.add(new LatLng(12.96578, 77.64018)); - route.add(new LatLng(12.9658402, 77.640201)); - route.add(new LatLng(12.9660401, 77.640261)); - route.add(new LatLng(12.9659501, 77.64054)); - route.add(new LatLng(12.9658402, 77.640931)); - route.add(new LatLng(12.9658101, 77.64113)); - route.add(new LatLng(12.96582, 77.641461)); - route.add(new LatLng(12.96644, 77.64143)); - route.add(new LatLng(12.9671, 77.6414)); - route.add(new LatLng(12.9685801, 77.641281)); - route.add(new LatLng(12.9686, 77.6414)); - route.add(new LatLng(12.9686102, 77.64203)); - route.add(new LatLng(12.9686, 77.6427)); - route.add(new LatLng(12.96864, 77.6435)); - route.add(new LatLng(12.96907, 77.6435)); - route.add(new LatLng(12.96972, 77.64346)); - route.add(new LatLng(12.9703201, 77.643431)); - route.add(new LatLng(12.9703201, 77.643291)); - route.add(new LatLng(12.97047, 77.64328)); - route.add(new LatLng(12.9708202, 77.643251)); - route.add(new LatLng(12.9714302, 77.64322)); - return route; - } - private static ArrayList getRoute9() { - ArrayList route = new ArrayList<>(); - route.add(new LatLng(12.97118, 77.639171)); - route.add(new LatLng(12.97258, 77.63911)); - route.add(new LatLng(12.9726002, 77.63991)); - route.add(new LatLng(12.9726402, 77.641111)); - route.add(new LatLng(12.9738401, 77.64105)); - route.add(new LatLng(12.9738602, 77.641771)); - route.add(new LatLng(12.97389, 77.643081)); - route.add(new LatLng(12.97394, 77.644231)); - route.add(new LatLng(12.97399, 77.64528)); - route.add(new LatLng(12.9744302, 77.645141)); - route.add(new LatLng(12.97446, 77.64519)); - route.add(new LatLng(12.9744802, 77.645271)); - route.add(new LatLng(12.9745, 77.645491)); - return route; - } - private static ArrayList getRoute10() { - ArrayList route = new ArrayList<>(); - route.add(new LatLng(12.9765402, 77.65004)); - route.add(new LatLng(12.97428, 77.649431)); - route.add(new LatLng(12.9743001, 77.649381)); - route.add(new LatLng(12.9745, 77.648851)); - route.add(new LatLng(12.97455, 77.648721)); - route.add(new LatLng(12.9745401, 77.648671)); - route.add(new LatLng(12.97441, 77.64857)); - route.add(new LatLng(12.97437, 77.6483)); - route.add(new LatLng(12.9743501, 77.64766)); - route.add(new LatLng(12.9743501, 77.64761)); - route.add(new LatLng(12.97503, 77.647561)); - route.add(new LatLng(12.9749902, 77.64686)); - route.add(new LatLng(12.9740701, 77.64691)); - route.add(new LatLng(12.97403, 77.645941)); - route.add(new LatLng(12.97399, 77.64528)); - route.add(new LatLng(12.97394, 77.644231)); - route.add(new LatLng(12.97389, 77.643081)); - route.add(new LatLng(12.9738602, 77.641771)); - route.add(new LatLng(12.97385, 77.641141)); - route.add(new LatLng(12.9734501, 77.64116)); - route.add(new LatLng(12.9720001, 77.641241)); - route.add(new LatLng(12.9701801, 77.6413)); - route.add(new LatLng(12.9688502, 77.6414)); - route.add(new LatLng(12.9686, 77.6414)); - route.add(new LatLng(12.9685801, 77.641281)); - route.add(new LatLng(12.9685301, 77.64069)); - route.add(new LatLng(12.9685, 77.640121)); - route.add(new LatLng(12.9684202, 77.639321)); - route.add(new LatLng(12.96836, 77.63848)); - route.add(new LatLng(12.9679701, 77.63852)); - route.add(new LatLng(12.96765, 77.638591)); - route.add(new LatLng(12.96752, 77.638591)); - route.add(new LatLng(12.9674001, 77.638561)); - route.add(new LatLng(12.9671301, 77.638461)); - route.add(new LatLng(12.9667501, 77.638381)); - route.add(new LatLng(12.9665902, 77.63835)); - return route; - } - private static ArrayList getRoute11() { - ArrayList route = new ArrayList<>(); - route.add(new LatLng(12.9726502, 77.65013)); - route.add(new LatLng(12.9727101, 77.649831)); - route.add(new LatLng(12.97278, 77.649441)); - route.add(new LatLng(12.97315, 77.6495)); - route.add(new LatLng(12.9736901, 77.649561)); - route.add(new LatLng(12.97376, 77.649571)); - route.add(new LatLng(12.97418, 77.64969)); - route.add(new LatLng(12.97428, 77.649431)); - route.add(new LatLng(12.9745401, 77.648761)); - route.add(new LatLng(12.97455, 77.64869)); - route.add(new LatLng(12.9745202, 77.64864)); - route.add(new LatLng(12.97442, 77.648591)); - route.add(new LatLng(12.9744001, 77.648541)); - route.add(new LatLng(12.9743802, 77.648451)); - route.add(new LatLng(12.9743501, 77.647991)); - route.add(new LatLng(12.9743501, 77.64761)); - route.add(new LatLng(12.97503, 77.647561)); - route.add(new LatLng(12.9749902, 77.64686)); - route.add(new LatLng(12.9740701, 77.64691)); - route.add(new LatLng(12.9740701, 77.64685)); - route.add(new LatLng(12.97399, 77.64537)); - route.add(new LatLng(12.9739102, 77.643531)); - route.add(new LatLng(12.97389, 77.643081)); - route.add(new LatLng(12.97334, 77.643121)); - route.add(new LatLng(12.9733201, 77.64265)); - route.add(new LatLng(12.9731102, 77.64266)); - return route; - } - private static ArrayList getRoute12() { - ArrayList route = new ArrayList<>(); - route.add(new LatLng(12.9750501, 77.644641)); - route.add(new LatLng(12.9750501, 77.6435)); - route.add(new LatLng(12.9744501, 77.64351)); - route.add(new LatLng(12.9739102, 77.643531)); - route.add(new LatLng(12.97389, 77.643081)); - route.add(new LatLng(12.9738602, 77.641771)); - route.add(new LatLng(12.97385, 77.641141)); - route.add(new LatLng(12.9734501, 77.64116)); - route.add(new LatLng(12.9720001, 77.641241)); - route.add(new LatLng(12.9701801, 77.6413)); - route.add(new LatLng(12.9688502, 77.6414)); - route.add(new LatLng(12.96784, 77.64144)); - route.add(new LatLng(12.96696, 77.64148)); - route.add(new LatLng(12.9668401, 77.641501)); - route.add(new LatLng(12.9665902, 77.64234)); - route.add(new LatLng(12.9664502, 77.642671)); - route.add(new LatLng(12.96639, 77.642901)); - route.add(new LatLng(12.9662, 77.644061)); - route.add(new LatLng(12.9661901, 77.644191)); - route.add(new LatLng(12.9659501, 77.64413)); - route.add(new LatLng(12.96569, 77.644111)); - route.add(new LatLng(12.9654702, 77.644101)); - route.add(new LatLng(12.96513, 77.644061)); - route.add(new LatLng(12.9643601, 77.643921)); - route.add(new LatLng(12.96413, 77.64489)); - return route; - } - private static ArrayList getRoute13() { - ArrayList route = new ArrayList<>(); - route.add(new LatLng(12.9658501, 77.636621)); - route.add(new LatLng(12.9658902, 77.636581)); - route.add(new LatLng(12.96615, 77.63691)); - route.add(new LatLng(12.9665201, 77.63664)); - route.add(new LatLng(12.96686, 77.63706)); - route.add(new LatLng(12.9669702, 77.637121)); - route.add(new LatLng(12.96808, 77.63724)); - route.add(new LatLng(12.9682501, 77.637291)); - route.add(new LatLng(12.9683001, 77.637351)); - route.add(new LatLng(12.96836, 77.63848)); - route.add(new LatLng(12.9684202, 77.639321)); - route.add(new LatLng(12.9685, 77.640121)); - route.add(new LatLng(12.9685301, 77.64069)); - route.add(new LatLng(12.9685801, 77.641281)); - route.add(new LatLng(12.9686102, 77.64203)); - route.add(new LatLng(12.9686, 77.6427)); - route.add(new LatLng(12.96864, 77.6435)); - route.add(new LatLng(12.9686701, 77.64484)); - route.add(new LatLng(12.9687002, 77.64561)); - route.add(new LatLng(12.9688402, 77.6477)); - route.add(new LatLng(12.9688402, 77.647771)); - route.add(new LatLng(12.96892, 77.647771)); - route.add(new LatLng(12.9688902, 77.647821)); - route.add(new LatLng(12.96887, 77.647991)); - route.add(new LatLng(12.9687502, 77.64875)); - route.add(new LatLng(12.9692301, 77.648811)); - route.add(new LatLng(12.9699401, 77.64891)); - route.add(new LatLng(12.9699702, 77.64972)); - return route; - } - private static ArrayList getRoute14() { - ArrayList route = new ArrayList<>(); - route.add(new LatLng(12.9742101, 77.63459)); - route.add(new LatLng(12.9739301, 77.63459)); - route.add(new LatLng(12.97371, 77.6346)); - route.add(new LatLng(12.9733601, 77.634651)); - route.add(new LatLng(12.97328, 77.634701)); - route.add(new LatLng(12.97324, 77.634801)); - route.add(new LatLng(12.9729702, 77.63473)); - route.add(new LatLng(12.973, 77.634891)); - route.add(new LatLng(12.9730301, 77.635191)); - route.add(new LatLng(12.9731202, 77.6359)); - route.add(new LatLng(12.9727101, 77.63594)); - route.add(new LatLng(12.9720001, 77.63599)); - route.add(new LatLng(12.9716701, 77.63597)); - route.add(new LatLng(12.9715, 77.63598)); - route.add(new LatLng(12.9704402, 77.63597)); - route.add(new LatLng(12.9698501, 77.635951)); - route.add(new LatLng(12.96934, 77.63598)); - route.add(new LatLng(12.9694301, 77.637621)); - route.add(new LatLng(12.9694701, 77.63843)); - route.add(new LatLng(12.9695502, 77.639271)); - route.add(new LatLng(12.9696101, 77.640161)); - route.add(new LatLng(12.96855, 77.64024)); - route.add(new LatLng(12.96851, 77.64024)); - route.add(new LatLng(12.96851, 77.64028)); - route.add(new LatLng(12.9685301, 77.64069)); - route.add(new LatLng(12.9685801, 77.641281)); - route.add(new LatLng(12.9686, 77.6414)); - route.add(new LatLng(12.96784, 77.64144)); - route.add(new LatLng(12.96696, 77.64148)); - route.add(new LatLng(12.9637802, 77.641641)); - route.add(new LatLng(12.9633201, 77.64166)); - route.add(new LatLng(12.96264, 77.641691)); - route.add(new LatLng(12.96254, 77.64243)); - route.add(new LatLng(12.9623702, 77.643751)); - route.add(new LatLng(12.96231, 77.64408)); - route.add(new LatLng(12.9631801, 77.644291)); + private static ArrayList getRoute26() { + ArrayList route = new ArrayList<>(); + route.add(new LatLng(12.9772601, 77.643921)); + route.add(new LatLng(12.97722, 77.64278)); + route.add(new LatLng(12.97714, 77.640981)); + route.add(new LatLng(12.97558, 77.64105)); + route.add(new LatLng(12.9720001, 77.641241)); + route.add(new LatLng(12.9701801, 77.6413)); + route.add(new LatLng(12.9688502, 77.6414)); + route.add(new LatLng(12.96784, 77.64144)); + route.add(new LatLng(12.96696, 77.64148)); + route.add(new LatLng(12.9637802, 77.641641)); + route.add(new LatLng(12.96352, 77.641651)); + route.add(new LatLng(12.9634002, 77.64166)); + route.add(new LatLng(12.9633502, 77.64176)); + route.add(new LatLng(12.9633701, 77.642261)); + route.add(new LatLng(12.9632102, 77.64363)); + route.add(new LatLng(12.96381, 77.64378)); + route.add(new LatLng(12.9639301, 77.64381)); + route.add(new LatLng(12.96386, 77.64413)); + route.add(new LatLng(12.9634101, 77.644021)); + return route; + } - return route; - } - private static ArrayList getRoute15() { - ArrayList route = new ArrayList<>(); - route.add(new LatLng(12.9728802, 77.64905)); - route.add(new LatLng(12.97278, 77.649441)); - route.add(new LatLng(12.9727101, 77.649831)); - route.add(new LatLng(12.9726502, 77.65013)); - route.add(new LatLng(12.9726002, 77.65016)); - route.add(new LatLng(12.97239, 77.650141)); - route.add(new LatLng(12.9724102, 77.650331)); - route.add(new LatLng(12.9724602, 77.65061)); - route.add(new LatLng(12.9721401, 77.65067)); - route.add(new LatLng(12.9715401, 77.650771)); - route.add(new LatLng(12.9714401, 77.650781)); - route.add(new LatLng(12.9714202, 77.650561)); - route.add(new LatLng(12.97127, 77.649621)); - route.add(new LatLng(12.97123, 77.649391)); - route.add(new LatLng(12.97112, 77.648681)); - route.add(new LatLng(12.97103, 77.64838)); - route.add(new LatLng(12.97098, 77.647911)); - route.add(new LatLng(12.97095, 77.64731)); - route.add(new LatLng(12.9704601, 77.647411)); - route.add(new LatLng(12.97042, 77.64685)); - route.add(new LatLng(12.97038, 77.64551)); - route.add(new LatLng(12.9691302, 77.645581)); - route.add(new LatLng(12.9687002, 77.64561)); - route.add(new LatLng(12.96794, 77.64564)); - route.add(new LatLng(12.9677202, 77.64564)); - route.add(new LatLng(12.9676302, 77.64557)); - route.add(new LatLng(12.9676001, 77.645441)); - route.add(new LatLng(12.9675802, 77.64448)); - route.add(new LatLng(12.9674902, 77.64275)); - route.add(new LatLng(12.9675001, 77.64206)); - route.add(new LatLng(12.9674902, 77.64144)); - route.add(new LatLng(12.96696, 77.64148)); - route.add(new LatLng(12.9668401, 77.641501)); - route.add(new LatLng(12.96685, 77.641421)); - route.add(new LatLng(12.9670801, 77.64059)); - route.add(new LatLng(12.96723, 77.640131)); - route.add(new LatLng(12.9671201, 77.639851)); - route.add(new LatLng(12.9670701, 77.639591)); - return route; - } - private static ArrayList getRoute16() { - ArrayList route = new ArrayList<>(); - route.add(new LatLng(12.9631301, 77.63907)); - route.add(new LatLng(12.9633102, 77.638771)); - route.add(new LatLng(12.96362, 77.63839)); - route.add(new LatLng(12.9631702, 77.63814)); - route.add(new LatLng(12.9626502, 77.63782)); - route.add(new LatLng(12.96236, 77.637611)); - route.add(new LatLng(12.9616702, 77.638191)); - route.add(new LatLng(12.96119, 77.638641)); - route.add(new LatLng(12.96109, 77.638691)); - route.add(new LatLng(12.96105, 77.6387)); - route.add(new LatLng(12.9610301, 77.63898)); - route.add(new LatLng(12.9608901, 77.63956)); - route.add(new LatLng(12.9608301, 77.64009)); - route.add(new LatLng(12.96076, 77.64073)); - route.add(new LatLng(12.9606901, 77.641831)); - route.add(new LatLng(12.9605501, 77.642941)); - route.add(new LatLng(12.96047, 77.64337)); - route.add(new LatLng(12.96062, 77.643381)); - route.add(new LatLng(12.96127, 77.64341)); - route.add(new LatLng(12.96146, 77.643441)); - route.add(new LatLng(12.96241, 77.64346)); - route.add(new LatLng(12.96291, 77.64355)); - route.add(new LatLng(12.96352, 77.643711)); - route.add(new LatLng(12.9639301, 77.64381)); - route.add(new LatLng(12.9643601, 77.643921)); - route.add(new LatLng(12.96414, 77.64484)); - route.add(new LatLng(12.96465, 77.64498)); - route.add(new LatLng(12.9649502, 77.64502)); - route.add(new LatLng(12.9647701, 77.6456)); - return route; - } - private static ArrayList getRoute17() { - ArrayList route = new ArrayList<>(); - route.add(new LatLng(12.97577, 77.63826)); - route.add(new LatLng(12.97601, 77.63826)); - route.add(new LatLng(12.9760302, 77.638951)); - route.add(new LatLng(12.9760702, 77.63988)); - route.add(new LatLng(12.9760801, 77.64019)); - route.add(new LatLng(12.97572, 77.64022)); - route.add(new LatLng(12.9741902, 77.64028)); - route.add(new LatLng(12.9734101, 77.64031)); - route.add(new LatLng(12.97343, 77.641071)); - route.add(new LatLng(12.9738401, 77.64105)); - route.add(new LatLng(12.97385, 77.641141)); - route.add(new LatLng(12.97389, 77.642681)); - route.add(new LatLng(12.9739102, 77.643531)); - route.add(new LatLng(12.9739602, 77.64481)); - route.add(new LatLng(12.9726902, 77.644861)); - route.add(new LatLng(12.9716301, 77.64494)); - route.add(new LatLng(12.9716201, 77.644591)); - return route; - } - private static ArrayList getRoute18() { - ArrayList route = new ArrayList<>(); - route.add(new LatLng(12.9587301, 77.639411)); - route.add(new LatLng(12.9588601, 77.63845)); - route.add(new LatLng(12.9588601, 77.63836)); - route.add(new LatLng(12.9602301, 77.63854)); - route.add(new LatLng(12.96076, 77.638601)); - route.add(new LatLng(12.96095, 77.638691)); - route.add(new LatLng(12.96105, 77.6387)); - route.add(new LatLng(12.9610301, 77.63898)); - route.add(new LatLng(12.9608901, 77.63956)); - route.add(new LatLng(12.9608301, 77.64009)); - route.add(new LatLng(12.96076, 77.64073)); - route.add(new LatLng(12.9606901, 77.641831)); - route.add(new LatLng(12.9605501, 77.642941)); - route.add(new LatLng(12.96047, 77.64337)); - route.add(new LatLng(12.96034, 77.644551)); - route.add(new LatLng(12.9602, 77.645591)); - route.add(new LatLng(12.96133, 77.645801)); - route.add(new LatLng(12.9621101, 77.64591)); - route.add(new LatLng(12.96264, 77.646021)); - route.add(new LatLng(12.9627101, 77.645711)); + private static ArrayList getRoute27() { + ArrayList route = new ArrayList<>(); + route.add(new LatLng(12.9671701, 77.63903)); + route.add(new LatLng(12.96724, 77.638821)); + route.add(new LatLng(12.96729, 77.63872)); + route.add(new LatLng(12.9673402, 77.638651)); + route.add(new LatLng(12.9674001, 77.638561)); + route.add(new LatLng(12.96747, 77.63858)); + route.add(new LatLng(12.9675802, 77.638591)); + route.add(new LatLng(12.9677202, 77.63858)); + route.add(new LatLng(12.9679701, 77.63852)); + route.add(new LatLng(12.9681601, 77.638501)); + route.add(new LatLng(12.96836, 77.63848)); + route.add(new LatLng(12.96837, 77.63888)); + route.add(new LatLng(12.9684702, 77.63978)); + route.add(new LatLng(12.96851, 77.64024)); + route.add(new LatLng(12.9685301, 77.64073)); + route.add(new LatLng(12.9686, 77.6414)); + route.add(new LatLng(12.9686102, 77.64203)); + route.add(new LatLng(12.9686, 77.6427)); + route.add(new LatLng(12.96865, 77.644141)); + route.add(new LatLng(12.9687002, 77.64561)); + route.add(new LatLng(12.9688402, 77.647771)); + route.add(new LatLng(12.96892, 77.647771)); + route.add(new LatLng(12.9689001, 77.64779)); + route.add(new LatLng(12.96888, 77.647871)); + route.add(new LatLng(12.96887, 77.64802)); + route.add(new LatLng(12.9687002, 77.6491)); + route.add(new LatLng(12.96846, 77.65012)); + route.add(new LatLng(12.96841, 77.650421)); + route.add(new LatLng(12.9685202, 77.650461)); + route.add(new LatLng(12.9700202, 77.650861)); + route.add(new LatLng(12.9703201, 77.65085)); + route.add(new LatLng(12.97038, 77.651861)); + return route; + } - return route; - } - private static ArrayList getRoute19() { - ArrayList route = new ArrayList<>(); - route.add(new LatLng(12.9674501, 77.6393)); - route.add(new LatLng(12.96775, 77.63942)); - route.add(new LatLng(12.96766, 77.63961)); - route.add(new LatLng(12.9675302, 77.63987)); - route.add(new LatLng(12.9674802, 77.640071)); - route.add(new LatLng(12.96746, 77.64019)); - route.add(new LatLng(12.96738, 77.640161)); - route.add(new LatLng(12.96723, 77.640131)); - route.add(new LatLng(12.9672002, 77.64018)); - route.add(new LatLng(12.9669702, 77.64099)); - route.add(new LatLng(12.9668401, 77.641501)); - route.add(new LatLng(12.96606, 77.64152)); - route.add(new LatLng(12.9634002, 77.64166)); - route.add(new LatLng(12.9625, 77.6417)); - route.add(new LatLng(12.96245, 77.64175)); - route.add(new LatLng(12.96194, 77.64179)); - route.add(new LatLng(12.9617801, 77.641821)); - route.add(new LatLng(12.9616, 77.64193)); - route.add(new LatLng(12.9615202, 77.642011)); - route.add(new LatLng(12.9614401, 77.64215)); - route.add(new LatLng(12.96118, 77.64309)); - route.add(new LatLng(12.96113, 77.64318)); - route.add(new LatLng(12.96104, 77.643291)); - route.add(new LatLng(12.9608801, 77.6434)); - route.add(new LatLng(12.96047, 77.64337)); - route.add(new LatLng(12.9602701, 77.645041)); - route.add(new LatLng(12.96011, 77.646351)); - route.add(new LatLng(12.9599901, 77.64743)); - route.add(new LatLng(12.9599302, 77.64802)); - route.add(new LatLng(12.95982, 77.649071)); - route.add(new LatLng(12.95973, 77.64906)); - route.add(new LatLng(12.95982, 77.64837)); - route.add(new LatLng(12.9599302, 77.647381)); - route.add(new LatLng(12.9600702, 77.645991)); - route.add(new LatLng(12.9598001, 77.645901)); - route.add(new LatLng(12.95959, 77.64579)); - route.add(new LatLng(12.95889, 77.645501)); - route.add(new LatLng(12.9583802, 77.64524)); - route.add(new LatLng(12.9580502, 77.6451)); - route.add(new LatLng(12.9577202, 77.64493)); - route.add(new LatLng(12.9576901, 77.644911)); - route.add(new LatLng(12.9577901, 77.64472)); - route.add(new LatLng(12.9578602, 77.644561)); - route.add(new LatLng(12.95809, 77.64386)); - return route; - } - private static ArrayList getRoute20() { - ArrayList route = new ArrayList<>(); - route.add(new LatLng(12.96982, 77.64345)); - route.add(new LatLng(12.9703201, 77.643431)); - route.add(new LatLng(12.9703101, 77.64306)); - route.add(new LatLng(12.97029, 77.642401)); - route.add(new LatLng(12.9702601, 77.6422)); - route.add(new LatLng(12.9702201, 77.64198)); - route.add(new LatLng(12.9701801, 77.6413)); - route.add(new LatLng(12.9688502, 77.6414)); - route.add(new LatLng(12.96784, 77.64144)); - route.add(new LatLng(12.96696, 77.64148)); - route.add(new LatLng(12.9668401, 77.641501)); - route.add(new LatLng(12.9665902, 77.64234)); - route.add(new LatLng(12.9664502, 77.642671)); - route.add(new LatLng(12.96639, 77.642901)); - route.add(new LatLng(12.9662, 77.644061)); - route.add(new LatLng(12.96616, 77.64457)); - route.add(new LatLng(12.9661301, 77.64476)); - route.add(new LatLng(12.9660901, 77.64488)); - route.add(new LatLng(12.9659901, 77.64515)); - route.add(new LatLng(12.9657902, 77.64546)); - route.add(new LatLng(12.9655201, 77.64579)); - route.add(new LatLng(12.9651402, 77.646021)); - return route; - } - private static ArrayList getRoute21() { - ArrayList route = new ArrayList<>(); - route.add(new LatLng(12.96714, 77.63919)); - route.add(new LatLng(12.9670701, 77.63956)); - route.add(new LatLng(12.9670801, 77.639721)); - route.add(new LatLng(12.96723, 77.640131)); - route.add(new LatLng(12.9670801, 77.64059)); - route.add(new LatLng(12.96685, 77.641421)); - route.add(new LatLng(12.9685801, 77.641281)); - route.add(new LatLng(12.9694301, 77.641241)); - route.add(new LatLng(12.9702701, 77.641191)); - route.add(new LatLng(12.97343, 77.641071)); - route.add(new LatLng(12.9761, 77.64094)); - route.add(new LatLng(12.9760901, 77.640341)); - route.add(new LatLng(12.97605, 77.63946)); - route.add(new LatLng(12.9760302, 77.638951)); - route.add(new LatLng(12.9760302, 77.63858)); - route.add(new LatLng(12.9750402, 77.638641)); - return route; - } - private static ArrayList getRoute22() { - ArrayList route = new ArrayList<>(); - route.add(new LatLng(12.9750501, 77.644011)); - route.add(new LatLng(12.9750501, 77.6435)); - route.add(new LatLng(12.9744501, 77.64351)); - route.add(new LatLng(12.9739102, 77.643531)); - route.add(new LatLng(12.97389, 77.643081)); - route.add(new LatLng(12.9726101, 77.64319)); - route.add(new LatLng(12.9716, 77.643211)); - route.add(new LatLng(12.97047, 77.64328)); - route.add(new LatLng(12.9703201, 77.643291)); - route.add(new LatLng(12.9703201, 77.643431)); - route.add(new LatLng(12.97034, 77.64407)); - route.add(new LatLng(12.97014, 77.64408)); - return route; - } - private static ArrayList getRoute23() { - ArrayList route = new ArrayList<>(); - route.add(new LatLng(12.97577, 77.64529)); - route.add(new LatLng(12.9757601, 77.644861)); - route.add(new LatLng(12.9757101, 77.64346)); - route.add(new LatLng(12.9750501, 77.6435)); - route.add(new LatLng(12.9739102, 77.643531)); - route.add(new LatLng(12.97389, 77.642681)); - route.add(new LatLng(12.97385, 77.641141)); - route.add(new LatLng(12.9738401, 77.64105)); - route.add(new LatLng(12.9761, 77.64094)); - route.add(new LatLng(12.9760901, 77.640341)); - route.add(new LatLng(12.9760702, 77.63988)); - route.add(new LatLng(12.97605, 77.63946)); - route.add(new LatLng(12.9760302, 77.63898)); - route.add(new LatLng(12.9751401, 77.639011)); - route.add(new LatLng(12.9745202, 77.639041)); - route.add(new LatLng(12.9745, 77.6389)); - route.add(new LatLng(12.9744802, 77.638591)); - route.add(new LatLng(12.97446, 77.63826)); - route.add(new LatLng(12.9744001, 77.63799)); - route.add(new LatLng(12.9743501, 77.637891)); - route.add(new LatLng(12.9744501, 77.637841)); - route.add(new LatLng(12.97456, 77.63778)); - route.add(new LatLng(12.9745702, 77.63778)); - return route; - } - private static ArrayList getRoute24() { - ArrayList route = new ArrayList<>(); - route.add(new LatLng(12.9738, 77.637831)); - route.add(new LatLng(12.9736802, 77.63787)); - route.add(new LatLng(12.9737202, 77.63812)); - route.add(new LatLng(12.97375, 77.638461)); - route.add(new LatLng(12.97375, 77.638471)); - route.add(new LatLng(12.97334, 77.638501)); - route.add(new LatLng(12.97338, 77.639411)); - route.add(new LatLng(12.97343, 77.641071)); - route.add(new LatLng(12.9738401, 77.64105)); - route.add(new LatLng(12.97385, 77.641141)); - route.add(new LatLng(12.97389, 77.642681)); - route.add(new LatLng(12.9739102, 77.643531)); - route.add(new LatLng(12.9739602, 77.64481)); - route.add(new LatLng(12.9726902, 77.644861)); - route.add(new LatLng(12.9716301, 77.64494)); - route.add(new LatLng(12.97089, 77.64494)); - route.add(new LatLng(12.9709102, 77.64561)); - route.add(new LatLng(12.9709102, 77.64636)); - route.add(new LatLng(12.97141, 77.646351)); - return route; - } - private static ArrayList getRoute25() { - ArrayList route = new ArrayList<>(); - route.add(new LatLng(12.9783702, 77.64228)); - route.add(new LatLng(12.9783, 77.640261)); - route.add(new LatLng(12.9782501, 77.63934)); - route.add(new LatLng(12.9782401, 77.63888)); - route.add(new LatLng(12.97807, 77.63888)); - route.add(new LatLng(12.9775901, 77.63885)); - route.add(new LatLng(12.97723, 77.638921)); - route.add(new LatLng(12.9766901, 77.638951)); - route.add(new LatLng(12.9760302, 77.63898)); - route.add(new LatLng(12.9760302, 77.638951)); - route.add(new LatLng(12.9760302, 77.63858)); - route.add(new LatLng(12.9756502, 77.63861)); - return route; - } - private static ArrayList getRoute26() { - ArrayList route = new ArrayList<>(); - route.add(new LatLng(12.9772601, 77.643921)); - route.add(new LatLng(12.97722, 77.64278)); - route.add(new LatLng(12.97714, 77.640981)); - route.add(new LatLng(12.97558, 77.64105)); - route.add(new LatLng(12.9720001, 77.641241)); - route.add(new LatLng(12.9701801, 77.6413)); - route.add(new LatLng(12.9688502, 77.6414)); - route.add(new LatLng(12.96784, 77.64144)); - route.add(new LatLng(12.96696, 77.64148)); - route.add(new LatLng(12.9637802, 77.641641)); - route.add(new LatLng(12.96352, 77.641651)); - route.add(new LatLng(12.9634002, 77.64166)); - route.add(new LatLng(12.9633502, 77.64176)); - route.add(new LatLng(12.9633701, 77.642261)); - route.add(new LatLng(12.9632102, 77.64363)); - route.add(new LatLng(12.96381, 77.64378)); - route.add(new LatLng(12.9639301, 77.64381)); - route.add(new LatLng(12.96386, 77.64413)); - route.add(new LatLng(12.9634101, 77.644021)); - return route; - } - private static ArrayList getRoute27() { - ArrayList route = new ArrayList<>(); - route.add(new LatLng(12.9671701, 77.63903)); - route.add(new LatLng(12.96724, 77.638821)); - route.add(new LatLng(12.96729, 77.63872)); - route.add(new LatLng(12.9673402, 77.638651)); - route.add(new LatLng(12.9674001, 77.638561)); - route.add(new LatLng(12.96747, 77.63858)); - route.add(new LatLng(12.9675802, 77.638591)); - route.add(new LatLng(12.9677202, 77.63858)); - route.add(new LatLng(12.9679701, 77.63852)); - route.add(new LatLng(12.9681601, 77.638501)); - route.add(new LatLng(12.96836, 77.63848)); - route.add(new LatLng(12.96837, 77.63888)); - route.add(new LatLng(12.9684702, 77.63978)); - route.add(new LatLng(12.96851, 77.64024)); - route.add(new LatLng(12.9685301, 77.64073)); - route.add(new LatLng(12.9686, 77.6414)); - route.add(new LatLng(12.9686102, 77.64203)); - route.add(new LatLng(12.9686, 77.6427)); - route.add(new LatLng(12.96865, 77.644141)); - route.add(new LatLng(12.9687002, 77.64561)); - route.add(new LatLng(12.9688402, 77.647771)); - route.add(new LatLng(12.96892, 77.647771)); - route.add(new LatLng(12.9689001, 77.64779)); - route.add(new LatLng(12.96888, 77.647871)); - route.add(new LatLng(12.96887, 77.64802)); - route.add(new LatLng(12.9687002, 77.6491)); - route.add(new LatLng(12.96846, 77.65012)); - route.add(new LatLng(12.96841, 77.650421)); - route.add(new LatLng(12.9685202, 77.650461)); - route.add(new LatLng(12.9700202, 77.650861)); - route.add(new LatLng(12.9703201, 77.65085)); - route.add(new LatLng(12.97038, 77.651861)); - return route; - } - private static ArrayList getRoute28() { - ArrayList route = new ArrayList<>(); - route.add(new LatLng(12.95865, 77.64378)); - route.add(new LatLng(12.95879, 77.643611)); - route.add(new LatLng(12.9590802, 77.64346)); - route.add(new LatLng(12.9597501, 77.64328)); - route.add(new LatLng(12.95983, 77.643261)); - route.add(new LatLng(12.9598901, 77.64314)); - route.add(new LatLng(12.9599401, 77.64282)); - route.add(new LatLng(12.96025, 77.642761)); - route.add(new LatLng(12.96044, 77.64275)); - route.add(new LatLng(12.96052, 77.64193)); - route.add(new LatLng(12.96053, 77.64139)); - route.add(new LatLng(12.9606802, 77.640251)); - route.add(new LatLng(12.9606901, 77.640211)); - route.add(new LatLng(12.96075, 77.64011)); - route.add(new LatLng(12.96086, 77.64002)); - route.add(new LatLng(12.9609701, 77.639981)); - route.add(new LatLng(12.96109, 77.63997)); - route.add(new LatLng(12.96122, 77.64)); - route.add(new LatLng(12.9613101, 77.640071)); - route.add(new LatLng(12.9613802, 77.640171)); - route.add(new LatLng(12.96141, 77.64024)); - route.add(new LatLng(12.9615001, 77.64136)); - route.add(new LatLng(12.9615302, 77.64145)); - route.add(new LatLng(12.9615901, 77.64153)); - route.add(new LatLng(12.9617, 77.64158)); - route.add(new LatLng(12.9624602, 77.64157)); - route.add(new LatLng(12.96259, 77.641591)); - route.add(new LatLng(12.9631, 77.641561)); - route.add(new LatLng(12.9634002, 77.64157)); - route.add(new LatLng(12.96349, 77.64157)); - route.add(new LatLng(12.96353, 77.64157)); - route.add(new LatLng(12.96582, 77.641461)); - route.add(new LatLng(12.96685, 77.641421)); - route.add(new LatLng(12.9685801, 77.641281)); - route.add(new LatLng(12.9702701, 77.641191)); - route.add(new LatLng(12.97343, 77.641071)); - route.add(new LatLng(12.9761, 77.64094)); - route.add(new LatLng(12.97831, 77.640801)); - route.add(new LatLng(12.97952, 77.64073)); - route.add(new LatLng(12.9799602, 77.64073)); - route.add(new LatLng(12.97995, 77.6397)); - route.add(new LatLng(12.9799602, 77.63925)); - route.add(new LatLng(12.9807701, 77.639181)); - route.add(new LatLng(12.98103, 77.63916)); - return route; - } + private static ArrayList getRoute28() { + ArrayList route = new ArrayList<>(); + route.add(new LatLng(12.95865, 77.64378)); + route.add(new LatLng(12.95879, 77.643611)); + route.add(new LatLng(12.9590802, 77.64346)); + route.add(new LatLng(12.9597501, 77.64328)); + route.add(new LatLng(12.95983, 77.643261)); + route.add(new LatLng(12.9598901, 77.64314)); + route.add(new LatLng(12.9599401, 77.64282)); + route.add(new LatLng(12.96025, 77.642761)); + route.add(new LatLng(12.96044, 77.64275)); + route.add(new LatLng(12.96052, 77.64193)); + route.add(new LatLng(12.96053, 77.64139)); + route.add(new LatLng(12.9606802, 77.640251)); + route.add(new LatLng(12.9606901, 77.640211)); + route.add(new LatLng(12.96075, 77.64011)); + route.add(new LatLng(12.96086, 77.64002)); + route.add(new LatLng(12.9609701, 77.639981)); + route.add(new LatLng(12.96109, 77.63997)); + route.add(new LatLng(12.96122, 77.64)); + route.add(new LatLng(12.9613101, 77.640071)); + route.add(new LatLng(12.9613802, 77.640171)); + route.add(new LatLng(12.96141, 77.64024)); + route.add(new LatLng(12.9615001, 77.64136)); + route.add(new LatLng(12.9615302, 77.64145)); + route.add(new LatLng(12.9615901, 77.64153)); + route.add(new LatLng(12.9617, 77.64158)); + route.add(new LatLng(12.9624602, 77.64157)); + route.add(new LatLng(12.96259, 77.641591)); + route.add(new LatLng(12.9631, 77.641561)); + route.add(new LatLng(12.9634002, 77.64157)); + route.add(new LatLng(12.96349, 77.64157)); + route.add(new LatLng(12.96353, 77.64157)); + route.add(new LatLng(12.96582, 77.641461)); + route.add(new LatLng(12.96685, 77.641421)); + route.add(new LatLng(12.9685801, 77.641281)); + route.add(new LatLng(12.9702701, 77.641191)); + route.add(new LatLng(12.97343, 77.641071)); + route.add(new LatLng(12.9761, 77.64094)); + route.add(new LatLng(12.97831, 77.640801)); + route.add(new LatLng(12.97952, 77.64073)); + route.add(new LatLng(12.9799602, 77.64073)); + route.add(new LatLng(12.97995, 77.6397)); + route.add(new LatLng(12.9799602, 77.63925)); + route.add(new LatLng(12.9807701, 77.639181)); + route.add(new LatLng(12.98103, 77.63916)); + return route; + } } diff --git a/app/src/main/java/com/amalbit/animationongooglemap/marker/LatLngInterpolator.java b/app/src/main/java/com/amalbit/animationongooglemap/marker/LatLngInterpolator.java index aaa60ca..62e54fe 100644 --- a/app/src/main/java/com/amalbit/animationongooglemap/marker/LatLngInterpolator.java +++ b/app/src/main/java/com/amalbit/animationongooglemap/marker/LatLngInterpolator.java @@ -1,17 +1,18 @@ package com.amalbit.animationongooglemap.marker; -import com.google.android.gms.maps.model.LatLng; + +import com.google.android.libraries.maps.model.LatLng; public interface LatLngInterpolator { - public LatLng interpolate(float fraction, LatLng a, LatLng b); + public LatLng interpolate(float fraction, LatLng a, LatLng b); - public class Linear implements LatLngInterpolator { - @Override - public LatLng interpolate(float fraction, LatLng a, LatLng b) { - double lat = (b.latitude - a.latitude) * fraction + a.latitude; - double lng = (b.longitude - a.longitude) * fraction + a.longitude; - return new LatLng(lat, lng); + public class Linear implements LatLngInterpolator { + @Override + public LatLng interpolate(float fraction, LatLng a, LatLng b) { + double lat = (b.latitude - a.latitude) * fraction + a.latitude; + double lng = (b.longitude - a.longitude) * fraction + a.longitude; + return new LatLng(lat, lng); + } } - } } diff --git a/app/src/main/java/com/amalbit/animationongooglemap/marker/Repeat.java b/app/src/main/java/com/amalbit/animationongooglemap/marker/Repeat.java index 0abc146..e3a63cc 100644 --- a/app/src/main/java/com/amalbit/animationongooglemap/marker/Repeat.java +++ b/app/src/main/java/com/amalbit/animationongooglemap/marker/Repeat.java @@ -4,56 +4,56 @@ import android.os.Looper; public class Repeat { - // Create a Handler that uses the Main Looper to run in - private Handler handler = new Handler(Looper.getMainLooper()); + // Create a Handler that uses the Main Looper to run in + private Handler handler = new Handler(Looper.getMainLooper()); - private Runnable statusChecker; - private int updateInterval = 2000; + private Runnable statusChecker; + private int updateInterval = 2000; - /** - * Creates an Repeat object, that can be used to - * perform UIUpdates on a specified time interval. - * - * @param uiUpdater A runnable containing the update routine. - */ - public Repeat(final Runnable uiUpdater) { - statusChecker = new Runnable() { - @Override - public void run() { - // Run the passed runnable - uiUpdater.run(); - // Re-run it after the update interval - handler.postDelayed(this, updateInterval); - } - }; - } + /** + * Creates an Repeat object, that can be used to + * perform UIUpdates on a specified time interval. + * + * @param uiUpdater A runnable containing the update routine. + */ + public Repeat(final Runnable uiUpdater) { + statusChecker = new Runnable() { + @Override + public void run() { + // Run the passed runnable + uiUpdater.run(); + // Re-run it after the update interval + handler.postDelayed(this, updateInterval); + } + }; + } - /** - * The same as the default constructor, but specifying the - * intended update interval. - * - * @param uiUpdater A runnable containing the update routine. - * @param interval The interval over which the routine - * should run (milliseconds). - */ - public Repeat(Runnable uiUpdater, int interval){ - this(uiUpdater); - updateInterval = interval; - } + /** + * The same as the default constructor, but specifying the + * intended update interval. + * + * @param uiUpdater A runnable containing the update routine. + * @param interval The interval over which the routine + * should run (milliseconds). + */ + public Repeat(Runnable uiUpdater, int interval) { + this(uiUpdater); + updateInterval = interval; + } - /** - * Starts the periodical update routine (statusChecker - * adds the callback to the handler). - */ - public synchronized void startUpdates(){ - statusChecker.run(); - } + /** + * Starts the periodical update routine (statusChecker + * adds the callback to the handler). + */ + public synchronized void startUpdates() { + statusChecker.run(); + } - /** - * Stops the periodical update routine from running, - * by removing the callback. - */ - public synchronized void stopUpdates(){ - handler.removeCallbacks(statusChecker); - } + /** + * Stops the periodical update routine from running, + * by removing the callback. + */ + public synchronized void stopUpdates() { + handler.removeCallbacks(statusChecker); + } } diff --git a/app/src/main/java/com/amalbit/animationongooglemap/polylineBased/MapAnimator.java b/app/src/main/java/com/amalbit/animationongooglemap/polylineBased/MapAnimator.java index 47f7930..03d3d2b 100644 --- a/app/src/main/java/com/amalbit/animationongooglemap/polylineBased/MapAnimator.java +++ b/app/src/main/java/com/amalbit/animationongooglemap/polylineBased/MapAnimator.java @@ -9,10 +9,12 @@ import android.view.animation.AccelerateDecelerateInterpolator; import android.view.animation.AccelerateInterpolator; import android.view.animation.DecelerateInterpolator; -import com.google.android.gms.maps.GoogleMap; -import com.google.android.gms.maps.model.LatLng; -import com.google.android.gms.maps.model.Polyline; -import com.google.android.gms.maps.model.PolylineOptions; + +import com.google.android.libraries.maps.GoogleMap; +import com.google.android.libraries.maps.model.LatLng; +import com.google.android.libraries.maps.model.Polyline; +import com.google.android.libraries.maps.model.PolylineOptions; + import java.util.List; /** @@ -21,203 +23,203 @@ public class MapAnimator { - private static MapAnimator mapAnimator; + private static MapAnimator mapAnimator; - private Polyline backgroundPolyline; + private Polyline backgroundPolyline; - private Polyline foregroundPolyline; + private Polyline foregroundPolyline; - private PolylineOptions optionsForeground; + private PolylineOptions optionsForeground; - private AnimatorSet firstRunAnimSet; + private AnimatorSet firstRunAnimSet; - private AnimatorSet secondLoopRunAnimSet; + private AnimatorSet secondLoopRunAnimSet; - static final int GREY = Color.parseColor("#FFA7A6A6"); + static final int GREY = Color.parseColor("#FFA7A6A6"); - private MapAnimator() { + private MapAnimator() { - } - - public static MapAnimator getInstance() { - if (mapAnimator == null) { - mapAnimator = new MapAnimator(); - } - return mapAnimator; - } - - public void animateRoute(GoogleMap googleMap, List bangaloreRoute) { - if (firstRunAnimSet == null) { - firstRunAnimSet = new AnimatorSet(); - } else { - firstRunAnimSet.removeAllListeners(); - firstRunAnimSet.end(); - firstRunAnimSet.cancel(); - - firstRunAnimSet = new AnimatorSet(); } - if (secondLoopRunAnimSet == null) { - secondLoopRunAnimSet = new AnimatorSet(); - } else { - secondLoopRunAnimSet.removeAllListeners(); - secondLoopRunAnimSet.end(); - secondLoopRunAnimSet.cancel(); - - secondLoopRunAnimSet = new AnimatorSet(); - } - //Reset the polylines - if (foregroundPolyline != null) { - foregroundPolyline.remove(); - } - if (backgroundPolyline != null) { - backgroundPolyline.remove(); - } - - PolylineOptions optionsBackground = new PolylineOptions().add(bangaloreRoute.get(0)).color(GREY).width(5); - backgroundPolyline = googleMap.addPolyline(optionsBackground); - - optionsForeground = new PolylineOptions().add(bangaloreRoute.get(0)).color(Color.BLACK).width(5); - foregroundPolyline = googleMap.addPolyline(optionsForeground); - - final ValueAnimator percentageCompletion = ValueAnimator.ofInt(0, 100); - percentageCompletion.setDuration(2000); - percentageCompletion.setInterpolator(new DecelerateInterpolator()); - percentageCompletion.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { - @Override - public void onAnimationUpdate(ValueAnimator animation) { - List foregroundPoints = backgroundPolyline.getPoints(); - - int percentageValue = (int) animation.getAnimatedValue(); - int pointcount = foregroundPoints.size(); - int countTobeRemoved = (int) (pointcount * (percentageValue / 100.0f)); - List subListTobeRemoved = foregroundPoints.subList(0, countTobeRemoved); - subListTobeRemoved.clear(); - - foregroundPolyline.setPoints(foregroundPoints); - } - }); - percentageCompletion.addListener(new Animator.AnimatorListener() { - @Override - public void onAnimationStart(Animator animation) { - } - - @Override - public void onAnimationEnd(Animator animation) { - foregroundPolyline.setColor(GREY); - foregroundPolyline.setPoints(backgroundPolyline.getPoints()); - } - - @Override - public void onAnimationCancel(Animator animation) { - } - - @Override - public void onAnimationRepeat(Animator animation) { - - } - }); - - ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), GREY, Color.BLACK); - colorAnimation.setInterpolator(new AccelerateInterpolator()); - colorAnimation.setDuration(1200); // milliseconds - - colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { - @Override - public void onAnimationUpdate(ValueAnimator animator) { - foregroundPolyline.setColor((int) animator.getAnimatedValue()); - } - - }); - - ObjectAnimator foregroundRouteAnimator = ObjectAnimator - .ofObject(this, "routeIncreaseForward", new RouteEvaluator(), bangaloreRoute.toArray()); - foregroundRouteAnimator.setInterpolator(new AccelerateDecelerateInterpolator()); - foregroundRouteAnimator.addListener(new Animator.AnimatorListener() { - @Override - public void onAnimationStart(Animator animation) { - - } - - @Override - public void onAnimationEnd(Animator animation) { - backgroundPolyline.setPoints(foregroundPolyline.getPoints()); - } - - @Override - public void onAnimationCancel(Animator animation) { - - } - - @Override - public void onAnimationRepeat(Animator animation) { + public static MapAnimator getInstance() { + if (mapAnimator == null) { + mapAnimator = new MapAnimator(); + } + return mapAnimator; + } - } - }); - foregroundRouteAnimator.setDuration(1600); + public void animateRoute(GoogleMap googleMap, List bangaloreRoute) { + if (firstRunAnimSet == null) { + firstRunAnimSet = new AnimatorSet(); + } else { + firstRunAnimSet.removeAllListeners(); + firstRunAnimSet.end(); + firstRunAnimSet.cancel(); + + firstRunAnimSet = new AnimatorSet(); + } + if (secondLoopRunAnimSet == null) { + secondLoopRunAnimSet = new AnimatorSet(); + } else { + secondLoopRunAnimSet.removeAllListeners(); + secondLoopRunAnimSet.end(); + secondLoopRunAnimSet.cancel(); + + secondLoopRunAnimSet = new AnimatorSet(); + } + //Reset the polylines + if (foregroundPolyline != null) { + foregroundPolyline.remove(); + } + if (backgroundPolyline != null) { + backgroundPolyline.remove(); + } + + PolylineOptions optionsBackground = new PolylineOptions().add(bangaloreRoute.get(0)).color(GREY).width(5); + backgroundPolyline = googleMap.addPolyline(optionsBackground); + + optionsForeground = new PolylineOptions().add(bangaloreRoute.get(0)).color(Color.BLACK).width(5); + foregroundPolyline = googleMap.addPolyline(optionsForeground); + + final ValueAnimator percentageCompletion = ValueAnimator.ofInt(0, 100); + percentageCompletion.setDuration(2000); + percentageCompletion.setInterpolator(new DecelerateInterpolator()); + percentageCompletion.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { + @Override + public void onAnimationUpdate(ValueAnimator animation) { + List foregroundPoints = backgroundPolyline.getPoints(); + + int percentageValue = (int) animation.getAnimatedValue(); + int pointcount = foregroundPoints.size(); + int countTobeRemoved = (int) (pointcount * (percentageValue / 100.0f)); + List subListTobeRemoved = foregroundPoints.subList(0, countTobeRemoved); + subListTobeRemoved.clear(); + + foregroundPolyline.setPoints(foregroundPoints); + } + }); + percentageCompletion.addListener(new Animator.AnimatorListener() { + @Override + public void onAnimationStart(Animator animation) { + } + + @Override + public void onAnimationEnd(Animator animation) { + foregroundPolyline.setColor(GREY); + foregroundPolyline.setPoints(backgroundPolyline.getPoints()); + } + + @Override + public void onAnimationCancel(Animator animation) { + + } + + @Override + public void onAnimationRepeat(Animator animation) { + + } + }); + + ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), GREY, Color.BLACK); + colorAnimation.setInterpolator(new AccelerateInterpolator()); + colorAnimation.setDuration(1200); // milliseconds + + colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { + @Override + public void onAnimationUpdate(ValueAnimator animator) { + foregroundPolyline.setColor((int) animator.getAnimatedValue()); + } + + }); + + ObjectAnimator foregroundRouteAnimator = ObjectAnimator + .ofObject(this, "routeIncreaseForward", new RouteEvaluator(), bangaloreRoute.toArray()); + foregroundRouteAnimator.setInterpolator(new AccelerateDecelerateInterpolator()); + foregroundRouteAnimator.addListener(new Animator.AnimatorListener() { + @Override + public void onAnimationStart(Animator animation) { + + } + + @Override + public void onAnimationEnd(Animator animation) { + backgroundPolyline.setPoints(foregroundPolyline.getPoints()); + } + + @Override + public void onAnimationCancel(Animator animation) { + + } + + @Override + public void onAnimationRepeat(Animator animation) { + + } + }); + foregroundRouteAnimator.setDuration(1600); // foregroundRouteAnimator.start(); - firstRunAnimSet.playSequentially(foregroundRouteAnimator, - percentageCompletion); - firstRunAnimSet.addListener(new Animator.AnimatorListener() { - @Override - public void onAnimationStart(Animator animation) { + firstRunAnimSet.playSequentially(foregroundRouteAnimator, + percentageCompletion); + firstRunAnimSet.addListener(new Animator.AnimatorListener() { + @Override + public void onAnimationStart(Animator animation) { - } + } - @Override - public void onAnimationEnd(Animator animation) { - secondLoopRunAnimSet.start(); - } + @Override + public void onAnimationEnd(Animator animation) { + secondLoopRunAnimSet.start(); + } - @Override - public void onAnimationCancel(Animator animation) { + @Override + public void onAnimationCancel(Animator animation) { - } + } - @Override - public void onAnimationRepeat(Animator animation) { + @Override + public void onAnimationRepeat(Animator animation) { - } - }); + } + }); - secondLoopRunAnimSet.playSequentially(colorAnimation, - percentageCompletion); - secondLoopRunAnimSet.setStartDelay(200); + secondLoopRunAnimSet.playSequentially(colorAnimation, + percentageCompletion); + secondLoopRunAnimSet.setStartDelay(200); - secondLoopRunAnimSet.addListener(new Animator.AnimatorListener() { - @Override - public void onAnimationStart(Animator animation) { + secondLoopRunAnimSet.addListener(new Animator.AnimatorListener() { + @Override + public void onAnimationStart(Animator animation) { - } + } - @Override - public void onAnimationEnd(Animator animation) { - secondLoopRunAnimSet.start(); - } + @Override + public void onAnimationEnd(Animator animation) { + secondLoopRunAnimSet.start(); + } - @Override - public void onAnimationCancel(Animator animation) { + @Override + public void onAnimationCancel(Animator animation) { - } + } - @Override - public void onAnimationRepeat(Animator animation) { + @Override + public void onAnimationRepeat(Animator animation) { - } - }); + } + }); - firstRunAnimSet.start(); - } + firstRunAnimSet.start(); + } - /** - * This will be invoked by the ObjectAnimator multiple times. Mostly every 16ms. - **/ - public void setRouteIncreaseForward(LatLng endLatLng) { - List foregroundPoints = foregroundPolyline.getPoints(); - foregroundPoints.add(endLatLng); - foregroundPolyline.setPoints(foregroundPoints); - } + /** + * This will be invoked by the ObjectAnimator multiple times. Mostly every 16ms. + **/ + public void setRouteIncreaseForward(LatLng endLatLng) { + List foregroundPoints = foregroundPolyline.getPoints(); + foregroundPoints.add(endLatLng); + foregroundPolyline.setPoints(foregroundPoints); + } } diff --git a/app/src/main/java/com/amalbit/animationongooglemap/polylineBased/MapsActivity.java b/app/src/main/java/com/amalbit/animationongooglemap/polylineBased/MapsActivity.java index d34988f..2ce5114 100644 --- a/app/src/main/java/com/amalbit/animationongooglemap/polylineBased/MapsActivity.java +++ b/app/src/main/java/com/amalbit/animationongooglemap/polylineBased/MapsActivity.java @@ -1,106 +1,109 @@ package com.amalbit.animationongooglemap.polylineBased; import android.os.Bundle; -import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.Toast; + +import androidx.appcompat.app.AppCompatActivity; + import com.amalbit.animationongooglemap.R; -import com.google.android.gms.maps.CameraUpdate; -import com.google.android.gms.maps.CameraUpdateFactory; -import com.google.android.gms.maps.GoogleMap; -import com.google.android.gms.maps.OnMapReadyCallback; -import com.google.android.gms.maps.SupportMapFragment; -import com.google.android.gms.maps.model.LatLng; -import com.google.android.gms.maps.model.LatLngBounds; +import com.google.android.libraries.maps.CameraUpdate; +import com.google.android.libraries.maps.CameraUpdateFactory; +import com.google.android.libraries.maps.GoogleMap; +import com.google.android.libraries.maps.OnMapReadyCallback; +import com.google.android.libraries.maps.SupportMapFragment; +import com.google.android.libraries.maps.model.LatLng; +import com.google.android.libraries.maps.model.LatLngBounds; + import java.util.ArrayList; import java.util.List; public class MapsActivity extends AppCompatActivity implements OnMapReadyCallback { - private static final LatLng POINT_A = new LatLng(12.922294704121231, 77.61939525604248); + private static final LatLng POINT_A = new LatLng(12.922294704121231, 77.61939525604248); - private static final LatLng POINT_B = new LatLng(12.933065305628435, 77.62390136718749); + private static final LatLng POINT_B = new LatLng(12.933065305628435, 77.62390136718749); - private List bangaloreRoute; + private List bangaloreRoute; - private GoogleMap mMap; + private GoogleMap mMap; - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_maps); - // Obtain the SupportMapFragment and get notified when the map is ready to be used. - SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() - .findFragmentById(R.id.map); - mapFragment.getMapAsync(this); + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_maps); + // Obtain the SupportMapFragment and get notified when the map is ready to be used. + SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() + .findFragmentById(R.id.map); + mapFragment.getMapAsync(this); - createRoute(); - } + createRoute(); + } - private void createRoute() { - if (bangaloreRoute == null) { - bangaloreRoute = new ArrayList<>(); - } else { - bangaloreRoute.clear(); + private void createRoute() { + if (bangaloreRoute == null) { + bangaloreRoute = new ArrayList<>(); + } else { + bangaloreRoute.clear(); + } + + bangaloreRoute.add(new LatLng(12.922294704121231, 77.61939525604248)); + bangaloreRoute.add(new LatLng(12.924637088068884, 77.6180648803711)); + bangaloreRoute.add(new LatLng(12.925557304321782, 77.6200819015503)); + bangaloreRoute.add(new LatLng(12.927104933097784, 77.62081146240234)); + bangaloreRoute.add(new LatLng(12.928234277770715, 77.62111186981201)); + bangaloreRoute.add(new LatLng(12.92990737159723, 77.6218843460083)); + bangaloreRoute.add(new LatLng(12.9337554448302, 77.62342929840088)); + bangaloreRoute.add(new LatLng(12.9346338010532, 77.62390136718749)); + bangaloreRoute.add(new LatLng(12.935177543831987, 77.62437343597412)); + bangaloreRoute.add(new LatLng(12.934487408564122, 77.62561798095703)); + bangaloreRoute.add(new LatLng(12.934320102757125, 77.62589693069457)); + bangaloreRoute.add(new LatLng(12.933860011209374, 77.62572526931763)); + bangaloreRoute.add(new LatLng(12.934550148212828, 77.62460947036743)); + bangaloreRoute.add(new LatLng(12.933379005502244, 77.62398719787598)); + bangaloreRoute.add(new LatLng(12.933065305628435, 77.62390136718749)); } - bangaloreRoute.add(new LatLng(12.922294704121231, 77.61939525604248)); - bangaloreRoute.add(new LatLng(12.924637088068884, 77.6180648803711)); - bangaloreRoute.add(new LatLng(12.925557304321782, 77.6200819015503)); - bangaloreRoute.add(new LatLng(12.927104933097784, 77.62081146240234)); - bangaloreRoute.add(new LatLng(12.928234277770715, 77.62111186981201)); - bangaloreRoute.add(new LatLng(12.92990737159723, 77.6218843460083)); - bangaloreRoute.add(new LatLng(12.9337554448302, 77.62342929840088)); - bangaloreRoute.add(new LatLng(12.9346338010532, 77.62390136718749)); - bangaloreRoute.add(new LatLng(12.935177543831987, 77.62437343597412)); - bangaloreRoute.add(new LatLng(12.934487408564122, 77.62561798095703)); - bangaloreRoute.add(new LatLng(12.934320102757125, 77.62589693069457)); - bangaloreRoute.add(new LatLng(12.933860011209374, 77.62572526931763)); - bangaloreRoute.add(new LatLng(12.934550148212828, 77.62460947036743)); - bangaloreRoute.add(new LatLng(12.933379005502244, 77.62398719787598)); - bangaloreRoute.add(new LatLng(12.933065305628435, 77.62390136718749)); - } - - - /** - * Manipulates the map once available. - * This callback is triggered when the map is ready to be used. - * This is where we can add markers or lines, add listeners or move the camera. In this case, - * we just add a marker near Sydney, Australia. - * If Google Play services is not installed on the device, the user will be prompted to install - * it inside the SupportMapFragment. This method will only be triggered once the user has - * installed Google Play services and returned to the app. - */ - @Override - public void onMapReady(GoogleMap map) { - mMap = map; - - mMap.setOnMapLoadedCallback(new GoogleMap.OnMapLoadedCallback() { - @Override - public void onMapLoaded() { - LatLngBounds.Builder builder = new LatLngBounds.Builder(); - builder.include(POINT_A); - builder.include(POINT_B); - LatLngBounds bounds = builder.build(); - CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, 200); - - mMap.moveCamera(cu); - mMap.animateCamera(CameraUpdateFactory.zoomTo(15), 2000, null); - startAnim(); - } - }); - } - - private void startAnim() { - if (mMap != null) { - MapAnimator.getInstance().animateRoute(mMap, bangaloreRoute); - } else { - Toast.makeText(getApplicationContext(), "Map not ready", Toast.LENGTH_LONG).show(); + /** + * Manipulates the map once available. + * This callback is triggered when the map is ready to be used. + * This is where we can add markers or lines, add listeners or move the camera. In this case, + * we just add a marker near Sydney, Australia. + * If Google Play services is not installed on the device, the user will be prompted to install + * it inside the SupportMapFragment. This method will only be triggered once the user has + * installed Google Play services and returned to the app. + */ + @Override + public void onMapReady(GoogleMap map) { + mMap = map; + + mMap.setOnMapLoadedCallback(new GoogleMap.OnMapLoadedCallback() { + @Override + public void onMapLoaded() { + LatLngBounds.Builder builder = new LatLngBounds.Builder(); + builder.include(POINT_A); + builder.include(POINT_B); + LatLngBounds bounds = builder.build(); + CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, 200); + + mMap.moveCamera(cu); + mMap.animateCamera(CameraUpdateFactory.zoomTo(15), 2000, null); + + startAnim(); + } + }); } - } - public void resetAnimation(View view) { - startAnim(); - } + private void startAnim() { + if (mMap != null) { + MapAnimator.getInstance().animateRoute(mMap, bangaloreRoute); + } else { + Toast.makeText(getApplicationContext(), "Map not ready", Toast.LENGTH_LONG).show(); + } + } + + public void resetAnimation(View view) { + startAnim(); + } } diff --git a/app/src/main/java/com/amalbit/animationongooglemap/polylineBased/RouteEvaluator.java b/app/src/main/java/com/amalbit/animationongooglemap/polylineBased/RouteEvaluator.java index 0c320e1..2e980fe 100644 --- a/app/src/main/java/com/amalbit/animationongooglemap/polylineBased/RouteEvaluator.java +++ b/app/src/main/java/com/amalbit/animationongooglemap/polylineBased/RouteEvaluator.java @@ -1,7 +1,9 @@ package com.amalbit.animationongooglemap.polylineBased; import android.animation.TypeEvaluator; -import com.google.android.gms.maps.model.LatLng; + +import com.google.android.libraries.maps.model.LatLng; + /** * Created by amal.chandran on 22/12/16. @@ -9,10 +11,10 @@ public class RouteEvaluator implements TypeEvaluator { - @Override - public LatLng evaluate(float t, LatLng startPoint, LatLng endPoint) { - double lat = startPoint.latitude + t * (endPoint.latitude - startPoint.latitude); - double lng = startPoint.longitude + t * (endPoint.longitude - startPoint.longitude); - return new LatLng(lat, lng); - } + @Override + public LatLng evaluate(float t, LatLng startPoint, LatLng endPoint) { + double lat = startPoint.latitude + t * (endPoint.latitude - startPoint.latitude); + double lng = startPoint.longitude + t * (endPoint.longitude - startPoint.longitude); + return new LatLng(lat, lng); + } } diff --git a/app/src/main/java/com/amalbit/animationongooglemap/projectionBased/BaseActivity.java b/app/src/main/java/com/amalbit/animationongooglemap/projectionBased/BaseActivity.java index ef23af0..cb9c70e 100644 --- a/app/src/main/java/com/amalbit/animationongooglemap/projectionBased/BaseActivity.java +++ b/app/src/main/java/com/amalbit/animationongooglemap/projectionBased/BaseActivity.java @@ -2,74 +2,76 @@ import android.os.Build; import android.os.Bundle; -import android.support.annotation.Nullable; -import android.support.v7.app.AppCompatActivity; import android.view.Window; import android.view.WindowManager; -import com.google.android.gms.maps.CameraUpdateFactory; -import com.google.android.gms.maps.GoogleMap; -import com.google.android.gms.maps.model.LatLng; -import com.google.android.gms.maps.model.LatLngBounds; + +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; +import com.google.android.libraries.maps.CameraUpdateFactory; +import com.google.android.libraries.maps.GoogleMap; +import com.google.android.libraries.maps.model.LatLng; +import com.google.android.libraries.maps.model.LatLngBounds; + import java.util.ArrayList; import java.util.List; -public class BaseActivity extends AppCompatActivity { +abstract public class BaseActivity extends AppCompatActivity { - @Override - protected void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - Window w = getWindow(); - w.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + Window w = getWindow(); + w.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); + } } - } - public void setMapBounds(GoogleMap googleMap) { - List latLngs = new ArrayList<>(); - latLngs.add(new LatLng(12.9715002, 77.6374856));//NW - latLngs.add(new LatLng(12.9703733, 77.6372037));//NE - latLngs.add(new LatLng(12.9595674, 77.6366595));//SE - latLngs.add(new LatLng(12.9595672, 77.6519803));//SW - LatLngBounds.Builder boundsBuilder = new LatLngBounds.Builder(); - for (LatLng latLngPoint : latLngs) { - boundsBuilder.include(latLngPoint); + public void setMapBounds(GoogleMap googleMap) { + List latLngs = new ArrayList<>(); + latLngs.add(new LatLng(12.9715002, 77.6374856));//NW + latLngs.add(new LatLng(12.9703733, 77.6372037));//NE + latLngs.add(new LatLng(12.9595674, 77.6366595));//SE + latLngs.add(new LatLng(12.9595672, 77.6519803));//SW + LatLngBounds.Builder boundsBuilder = new LatLngBounds.Builder(); + for (LatLng latLngPoint : latLngs) { + boundsBuilder.include(latLngPoint); + } + LatLngBounds latLngBounds = boundsBuilder.build(); + googleMap.moveCamera(CameraUpdateFactory.newLatLngBounds(latLngBounds, 100)); } - LatLngBounds latLngBounds = boundsBuilder.build(); - googleMap.moveCamera(CameraUpdateFactory.newLatLngBounds(latLngBounds, 100)); - } - float getBearing(LatLng begin, LatLng end) { - double lat = Math.abs(begin.latitude - end.latitude); - double lng = Math.abs(begin.longitude - end.longitude); + float getBearing(LatLng begin, LatLng end) { + double lat = Math.abs(begin.latitude - end.latitude); + double lng = Math.abs(begin.longitude - end.longitude); - if (begin.latitude < end.latitude && begin.longitude < end.longitude) { - return (float) (Math.toDegrees(Math.atan(lng / lat))); - } else if (begin.latitude >= end.latitude && begin.longitude < end.longitude) { - return (float) ((90 - Math.toDegrees(Math.atan(lng / lat))) + 90); - } else if (begin.latitude >= end.latitude && begin.longitude >= end.longitude) { - return (float) (Math.toDegrees(Math.atan(lng / lat)) + 180); - } else if (begin.latitude < end.latitude && begin.longitude >= end.longitude) { - return (float) ((90 - Math.toDegrees(Math.atan(lng / lat))) + 270); + if (begin.latitude < end.latitude && begin.longitude < end.longitude) { + return (float) (Math.toDegrees(Math.atan(lng / lat))); + } else if (begin.latitude >= end.latitude && begin.longitude < end.longitude) { + return (float) ((90 - Math.toDegrees(Math.atan(lng / lat))) + 90); + } else if (begin.latitude >= end.latitude && begin.longitude >= end.longitude) { + return (float) (Math.toDegrees(Math.atan(lng / lat)) + 180); + } else if (begin.latitude < end.latitude && begin.longitude >= end.longitude) { + return (float) ((90 - Math.toDegrees(Math.atan(lng / lat))) + 270); + } + return -1; } - return -1; - } - public static final int STRAIGHT_ANGLE = 180; - public static final int FULL_ROTATION = 360; + public static final int STRAIGHT_ANGLE = 180; + public static final int FULL_ROTATION = 360; - float calcMinAngle(float markerCurrentRotation, float markerNextRotation) { - float angleDifference = (Math.abs(markerNextRotation - markerCurrentRotation)); - if (angleDifference > STRAIGHT_ANGLE) { - if (markerCurrentRotation < 0) { - markerNextRotation = (-FULL_ROTATION + angleDifference) + markerCurrentRotation; - } else { - markerNextRotation = (FULL_ROTATION - angleDifference) + markerCurrentRotation; - } + float calcMinAngle(float markerCurrentRotation, float markerNextRotation) { + float angleDifference = (Math.abs(markerNextRotation - markerCurrentRotation)); + if (angleDifference > STRAIGHT_ANGLE) { + if (markerCurrentRotation < 0) { + markerNextRotation = (-FULL_ROTATION + angleDifference) + markerCurrentRotation; + } else { + markerNextRotation = (FULL_ROTATION - angleDifference) + markerCurrentRotation; + } + } + return markerNextRotation > FULL_ROTATION + ? markerNextRotation - FULL_ROTATION + : markerNextRotation; } - return markerNextRotation > FULL_ROTATION - ? markerNextRotation - FULL_ROTATION - : markerNextRotation; - } } diff --git a/app/src/main/java/com/amalbit/animationongooglemap/projectionBased/FromToActivity.java b/app/src/main/java/com/amalbit/animationongooglemap/projectionBased/FromToActivity.java index 6217377..8ae167d 100644 --- a/app/src/main/java/com/amalbit/animationongooglemap/projectionBased/FromToActivity.java +++ b/app/src/main/java/com/amalbit/animationongooglemap/projectionBased/FromToActivity.java @@ -8,6 +8,7 @@ import android.os.Bundle; import android.view.animation.LinearInterpolator; import android.widget.ImageView; + import com.amalbit.animationongooglemap.R; import com.amalbit.animationongooglemap.U; import com.amalbit.animationongooglemap.data.CarData.Car; @@ -17,185 +18,186 @@ import com.amalbit.trail.marker.MarkerOverlayView; import com.amalbit.trail.marker.OverlayMarker; import com.amalbit.trail.marker.OverlayMarker.OnMarkerUpdate; -import com.google.android.gms.maps.GoogleMap; -import com.google.android.gms.maps.OnMapReadyCallback; -import com.google.android.gms.maps.SupportMapFragment; -import com.google.android.gms.maps.model.LatLng; +import com.google.android.libraries.maps.GoogleMap; +import com.google.android.libraries.maps.OnMapReadyCallback; +import com.google.android.libraries.maps.SupportMapFragment; +import com.google.android.libraries.maps.model.LatLng; + import java.util.ArrayList; import java.util.List; public class FromToActivity extends BaseActivity implements OnMapReadyCallback, OnMarkerUpdate { - private GoogleMap mMap; + private GoogleMap mMap; - private MarkerOverlayView markerOverlayView; + private MarkerOverlayView markerOverlayView; - private Bitmap markerIcon; + private Bitmap markerIcon; - private Repeat repeat; + private Repeat repeat; - private ImageView imgTest; + private ImageView imgTest; - private float lastBearing = 0; + private float lastBearing = 0; - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_from_to); - markerIcon = BitmapFactory.decodeResource(getResources(), R.drawable.car); + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_from_to); + markerIcon = BitmapFactory.decodeResource(getResources(), R.drawable.car); - imgTest = findViewById(R.id.imgTest); - imgTest.setOnClickListener(v -> { + imgTest = findViewById(R.id.imgTest); + imgTest.setOnClickListener(v -> { // imgTest.setImageBitmap( // rotateBitmap1(markerIcon, ) // ); - float bearing = 30;//ThreadLocalRandom.current().nextInt(0, 360 + 1); - ValueAnimator rotateValueAnimator = ValueAnimator.ofFloat(lastBearing, bearing); - rotateValueAnimator.addUpdateListener(animation -> { - float v1 = (float) animation.getAnimatedValue(); - U.log("rotation", "from " + lastBearing + "| to " + bearing + " || " + "fraction : " + v); - imgTest.setImageBitmap(rotateBitmap1(markerIcon, v1)); - }); + float bearing = 30;//ThreadLocalRandom.current().nextInt(0, 360 + 1); + ValueAnimator rotateValueAnimator = ValueAnimator.ofFloat(lastBearing, bearing); + rotateValueAnimator.addUpdateListener(animation -> { + float v1 = (float) animation.getAnimatedValue(); + U.log("rotation", "from " + lastBearing + "| to " + bearing + " || " + "fraction : " + v); + imgTest.setImageBitmap(rotateBitmap1(markerIcon, v1)); + }); // rotateValueAnimator.setFloatValues(0, 1); // Ignored. - rotateValueAnimator.setDuration(200); - rotateValueAnimator.start(); - }); - - markerOverlayView = findViewById(R.id.mapMarkerOverlayView); - SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() - .findFragmentById(R.id.map); - mapFragment.getMapAsync(this); - } - - @Override - public void onMapReady(GoogleMap map) { - mMap = map; - - mMap.setOnMapLoadedCallback(() -> { - mMap.setOnCameraMoveListener(() -> markerOverlayView.onCameraMove(mMap)); - - setMapBounds(map); - - ArrayList indiranagarRoutes = LatlngData.getIndiranagarRoutes(); - repeat = new Repeat(() -> addMarkerWithAnimation(indiranagarRoutes), 1000); - - markerOverlayView.post(() -> { - repeat.startUpdates(); - }); - }); - } - - public void addMarkerWithAnimation(List cars) { - U.log("doublemarker", "-------------------------------addMarkerWithAnimation----------------------------"); - U.log("doublemarker", "Cars count : " + cars.size()); - U.log("doublemarker", "Markers count : " + markerOverlayView.getMarkerCount()); - U.log("doublemarker", "---------------------------------------------------------------------------------"); - runOnUiThread(() -> { - for (Car car : cars) { - final OverlayMarker overlayMarker = markerOverlayView.findMarkerById(car.getCarId()); - if (overlayMarker == null) { - OverlayMarker overlayMarker1 = new OverlayMarker(); - overlayMarker1.setIcon(markerIcon.copy(markerIcon.getConfig(), true)); - overlayMarker1.setMarkerId(car.getCarId()); - overlayMarker1.setLatLng(car.getLatLng()); - overlayMarker1.setOnMarkerUpdate(FromToActivity.this); - - ValueAnimator translateValueAnimator = new ValueAnimator(); - translateValueAnimator.setInterpolator(new LinearInterpolator()); - overlayMarker1.setTranslateValueAnimator(translateValueAnimator); - - ValueAnimator rotateValueAnimator = new ValueAnimator(); - rotateValueAnimator.setInterpolator(new LinearInterpolator()); - overlayMarker1.setRotateValueAnimator(rotateValueAnimator); - - markerOverlayView.addMarker(overlayMarker1, mMap.getProjection()); - } else { - final LatLng startLatLng = overlayMarker.getLatLng(); - final LatLng endLatLng = car.getLatLng(); - float bearing = 0; + rotateValueAnimator.setDuration(200); + rotateValueAnimator.start(); + }); + + markerOverlayView = findViewById(R.id.mapMarkerOverlayView); + SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() + .findFragmentById(R.id.map); + mapFragment.getMapAsync(this); + } + + @Override + public void onMapReady(GoogleMap map) { + mMap = map; + + mMap.setOnMapLoadedCallback(() -> { + mMap.setOnCameraMoveListener(() -> markerOverlayView.onCameraMove(mMap)); + + setMapBounds(map); + + ArrayList indiranagarRoutes = LatlngData.getIndiranagarRoutes(); + repeat = new Repeat(() -> addMarkerWithAnimation(indiranagarRoutes), 1000); + + markerOverlayView.post(() -> { + repeat.startUpdates(); + }); + }); + } + + public void addMarkerWithAnimation(List cars) { + U.log("doublemarker", "-------------------------------addMarkerWithAnimation----------------------------"); + U.log("doublemarker", "Cars count : " + cars.size()); + U.log("doublemarker", "Markers count : " + markerOverlayView.getMarkerCount()); + U.log("doublemarker", "---------------------------------------------------------------------------------"); + runOnUiThread(() -> { + for (Car car : cars) { + final OverlayMarker overlayMarker = markerOverlayView.findMarkerById(car.getCarId()); + if (overlayMarker == null) { + OverlayMarker overlayMarker1 = new OverlayMarker(); + overlayMarker1.setIcon(markerIcon.copy(markerIcon.getConfig(), true)); + overlayMarker1.setMarkerId(car.getCarId()); + overlayMarker1.setLatLng(car.getLatLng()); + overlayMarker1.setOnMarkerUpdate(FromToActivity.this); + + ValueAnimator translateValueAnimator = new ValueAnimator(); + translateValueAnimator.setInterpolator(new LinearInterpolator()); + overlayMarker1.setTranslateValueAnimator(translateValueAnimator); + + ValueAnimator rotateValueAnimator = new ValueAnimator(); + rotateValueAnimator.setInterpolator(new LinearInterpolator()); + overlayMarker1.setRotateValueAnimator(rotateValueAnimator); + + markerOverlayView.addMarker(overlayMarker1, mMap.getProjection()); + } else { + final LatLng startLatLng = overlayMarker.getLatLng(); + final LatLng endLatLng = car.getLatLng(); + float bearing = 0; // overlayMarker.setIcon(markerIcon); - bearing = getBearing(startLatLng, endLatLng); - - ValueAnimator valueAnimator = overlayMarker.getTranslateValueAnimator(); - valueAnimator.removeAllUpdateListeners(); - valueAnimator.addUpdateListener(animation -> { - float v = animation.getAnimatedFraction(); - LatLng newPosition = new LatLngInterpolator.Linear().interpolate(v, startLatLng, endLatLng); - overlayMarker.setLatLng(newPosition); - markerOverlayView.updateMarker(overlayMarker, mMap.getProjection()); - }); - valueAnimator.setFloatValues(0, 1); // Ignored. - valueAnimator.setDuration(1000); - valueAnimator.start(); - - overlayMarker.setLatLng(endLatLng); - markerOverlayView.updateMarker(overlayMarker, mMap.getProjection()); - - float lastBearing = overlayMarker.getBearing(); - ValueAnimator rotateValueAnimator = overlayMarker.getRotateValueAnimator(); - rotateValueAnimator.removeAllUpdateListeners(); - rotateValueAnimator.cancel(); - - final float brearingFinal = bearing; - - rotateValueAnimator = ValueAnimator.ofFloat(lastBearing, calcMinAngle(lastBearing, bearing)); - rotateValueAnimator.addUpdateListener(animation -> { - float v = (float) animation.getAnimatedValue(); - overlayMarker.setBearing(v); - overlayMarker.rotateIcon(v); + bearing = getBearing(startLatLng, endLatLng); + + ValueAnimator valueAnimator = overlayMarker.getTranslateValueAnimator(); + valueAnimator.removeAllUpdateListeners(); + valueAnimator.addUpdateListener(animation -> { + float v = animation.getAnimatedFraction(); + LatLng newPosition = new LatLngInterpolator.Linear().interpolate(v, startLatLng, endLatLng); + overlayMarker.setLatLng(newPosition); + markerOverlayView.updateMarker(overlayMarker, mMap.getProjection()); + }); + valueAnimator.setFloatValues(0, 1); // Ignored. + valueAnimator.setDuration(1000); + valueAnimator.start(); + + overlayMarker.setLatLng(endLatLng); + markerOverlayView.updateMarker(overlayMarker, mMap.getProjection()); + + float lastBearing = overlayMarker.getBearing(); + ValueAnimator rotateValueAnimator = overlayMarker.getRotateValueAnimator(); + rotateValueAnimator.removeAllUpdateListeners(); + rotateValueAnimator.cancel(); + + final float brearingFinal = bearing; + + rotateValueAnimator = ValueAnimator.ofFloat(lastBearing, calcMinAngle(lastBearing, bearing)); + rotateValueAnimator.addUpdateListener(animation -> { + float v = (float) animation.getAnimatedValue(); + overlayMarker.setBearing(v); + overlayMarker.rotateIcon(v); // U.log("rotation", "from " + lastBearing + "| to " + brearingFinal + " || " + "fraction : " + v); - markerOverlayView.updateMarkerAngle(overlayMarker); - }); - rotateValueAnimator.setDuration(200); - rotateValueAnimator.start(); + markerOverlayView.updateMarkerAngle(overlayMarker); + }); + rotateValueAnimator.setDuration(200); + rotateValueAnimator.start(); - overlayMarker.setRotateValueAnimator(rotateValueAnimator); - } - } - }); - } + overlayMarker.setRotateValueAnimator(rotateValueAnimator); + } + } + }); + } - private Bitmap rotateBitmap(Bitmap original, float degrees) { - int width = original.getWidth(); - int height = original.getHeight(); + private Bitmap rotateBitmap(Bitmap original, float degrees) { + int width = original.getWidth(); + int height = original.getHeight(); - Matrix matrix = new Matrix(); - matrix.preRotate(degrees); + Matrix matrix = new Matrix(); + matrix.preRotate(degrees); - Bitmap workingBitmap = Bitmap.createBitmap(original); - Bitmap mutableBitmap = workingBitmap.copy(Bitmap.Config.ARGB_8888, true); + Bitmap workingBitmap = Bitmap.createBitmap(original); + Bitmap mutableBitmap = workingBitmap.copy(Bitmap.Config.ARGB_8888, true); - Bitmap rotatedBitmap = Bitmap.createBitmap(mutableBitmap, 0, 0, width, height, matrix, true); - Canvas canvas = new Canvas(rotatedBitmap); - canvas.drawBitmap(original, 5.0f, 0.0f, null); + Bitmap rotatedBitmap = Bitmap.createBitmap(mutableBitmap, 0, 0, width, height, matrix, true); + Canvas canvas = new Canvas(rotatedBitmap); + canvas.drawBitmap(original, 5.0f, 0.0f, null); - return rotatedBitmap; - } + return rotatedBitmap; + } - public Bitmap rotateBitmap1(Bitmap original, float degrees) { - int width = original.getWidth(); - int height = original.getHeight(); + public Bitmap rotateBitmap1(Bitmap original, float degrees) { + int width = original.getWidth(); + int height = original.getHeight(); - Matrix matrix = new Matrix(); + Matrix matrix = new Matrix(); - matrix.postRotate(degrees); + matrix.postRotate(degrees); - Bitmap scaledBitmap = Bitmap.createScaledBitmap(original, width, height, true); + Bitmap scaledBitmap = Bitmap.createScaledBitmap(original, width, height, true); // original.recycle(); - return Bitmap.createBitmap(scaledBitmap, 0, 0, scaledBitmap.getWidth(), scaledBitmap.getHeight(), matrix, true); - } + return Bitmap.createBitmap(scaledBitmap, 0, 0, scaledBitmap.getWidth(), scaledBitmap.getHeight(), matrix, true); + } - @Override - protected void onPause() { - super.onPause(); - repeat.stopUpdates(); - } + @Override + protected void onPause() { + super.onPause(); + repeat.stopUpdates(); + } - @Override - public void onMarkerUpdate() { - markerOverlayView.invalidate(); - } + @Override + public void onMarkerUpdate() { + markerOverlayView.invalidate(); + } } diff --git a/app/src/main/java/com/amalbit/animationongooglemap/projectionBased/OverlayRouteActivity.java b/app/src/main/java/com/amalbit/animationongooglemap/projectionBased/OverlayRouteActivity.java index 9faf8af..4fd3521 100644 --- a/app/src/main/java/com/amalbit/animationongooglemap/projectionBased/OverlayRouteActivity.java +++ b/app/src/main/java/com/amalbit/animationongooglemap/projectionBased/OverlayRouteActivity.java @@ -4,141 +4,140 @@ import android.os.Bundle; import android.view.View; import android.widget.ArrayAdapter; + import com.amalbit.animationongooglemap.R; import com.amalbit.animationongooglemap.data.LatlngData; import com.amalbit.trail.OverlayPolyline; import com.amalbit.trail.RouteOverlayView; import com.amalbit.trail.RouteOverlayView.RouteType; -import com.google.android.gms.maps.CameraUpdateFactory; -import com.google.android.gms.maps.GoogleMap; -import com.google.android.gms.maps.GoogleMap.CancelableCallback; -import com.google.android.gms.maps.OnMapReadyCallback; -import com.google.android.gms.maps.Projection; -import com.google.android.gms.maps.SupportMapFragment; -import com.google.android.gms.maps.model.CameraPosition; -import com.google.android.gms.maps.model.LatLng; -import com.google.android.gms.maps.model.LatLngBounds; -import com.google.android.gms.maps.model.MapStyleOptions; +import com.google.android.libraries.maps.CameraUpdateFactory; +import com.google.android.libraries.maps.GoogleMap; +import com.google.android.libraries.maps.OnMapReadyCallback; +import com.google.android.libraries.maps.SupportMapFragment; +import com.google.android.libraries.maps.model.LatLng; +import com.google.android.libraries.maps.model.LatLngBounds; +import com.google.android.libraries.maps.model.MapStyleOptions; + import java.util.List; public class OverlayRouteActivity extends BaseActivity implements OnMapReadyCallback { - private static String TAG = "OverlayRouteActivity"; + private static String TAG = "OverlayRouteActivity"; - private GoogleMap mMap; + private GoogleMap mMap; - private MapStyleOptions mapStyle; + private MapStyleOptions mapStyle; - private List mRoute; + private List mRoute; - private RouteOverlayView mRouteOverlayView; + private RouteOverlayView mRouteOverlayView; - private SupportMapFragment mapFragment; + private SupportMapFragment mapFragment; - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_projection_route); - initUI(); - mapFragment = (SupportMapFragment) getSupportFragmentManager() - .findFragmentById(R.id.map); - mapFragment.getMapAsync(this); - mRoute = LatlngData.getRoute(); - mapStyle = MapStyleOptions.loadRawResourceStyle(getApplicationContext(), R.raw.map_style); - } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_projection_route); + initUI(); + mapFragment = (SupportMapFragment) getSupportFragmentManager() + .findFragmentById(R.id.map); + mapFragment.getMapAsync(this); + mRoute = LatlngData.getRoute(); + mapStyle = MapStyleOptions.loadRawResourceStyle(getApplicationContext(), R.raw.map_style); + } - public void onClick1(View view) { - switch (view.getId()) { - case R.id.btnAdd: - mRouteOverlayView.removeRoutes(); - zoomRoute(mRoute); - break; - case R.id.btnRemove: - mRouteOverlayView.removeRoutes(); - break; + public void onClick1(View view) { + switch (view.getId()) { + case R.id.btnAdd: + mRouteOverlayView.removeRoutes(); + zoomRoute(mRoute); + break; + case R.id.btnRemove: + mRouteOverlayView.removeRoutes(); + break; + } } - } - - private void initUI() { - mRouteOverlayView = findViewById(R.id.mapOverlayView); - ArrayAdapter adapter = ArrayAdapter.createFromResource(this, - R.array.array_place, android.R.layout.simple_spinner_item); - adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); - } - - @Override - public void onMapReady(final GoogleMap map) { - mMap = map; - mMap.setMapStyle(mapStyle); - mMap.getUiSettings().setRotateGesturesEnabled(false); - mMap.getUiSettings().setTiltGesturesEnabled(false); - - mMap.setOnMapLoadedCallback(() -> { - mMap.setPadding(0, 0, 0, 250); - zoomRoute(mRoute); - drawRoutes(); - mMap.setOnCameraMoveListener(() -> { - mRouteOverlayView.onCameraMove(); - - } - ); - }); - } - - public void zoomRoute(List lstLatLngRoute) { - - if (mMap == null || lstLatLngRoute == null || lstLatLngRoute.isEmpty()) { - return; + + private void initUI() { + mRouteOverlayView = findViewById(R.id.mapOverlayView); + ArrayAdapter adapter = ArrayAdapter.createFromResource(this, + R.array.array_place, android.R.layout.simple_spinner_item); + adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); } - LatLngBounds.Builder boundsBuilder = new LatLngBounds.Builder(); - for (LatLng latLngPoint : lstLatLngRoute) { - boundsBuilder.include(latLngPoint); + + @Override + public void onMapReady(final GoogleMap map) { + mMap = map; + mMap.setMapStyle(mapStyle); + mMap.getUiSettings().setRotateGesturesEnabled(false); + mMap.getUiSettings().setTiltGesturesEnabled(false); + + mMap.setOnMapLoadedCallback(() -> { + mMap.setPadding(0, 0, 0, 250); + zoomRoute(mRoute); + drawRoutes(); + mMap.setOnCameraMoveListener(() -> { + mRouteOverlayView.onCameraMove(); + + } + ); + }); } - for (LatLng latLng : LatlngData.getRouteB()) { - boundsBuilder.include(latLng); + + public void zoomRoute(List lstLatLngRoute) { + + if (mMap == null || lstLatLngRoute == null || lstLatLngRoute.isEmpty()) { + return; + } + LatLngBounds.Builder boundsBuilder = new LatLngBounds.Builder(); + for (LatLng latLngPoint : lstLatLngRoute) { + boundsBuilder.include(latLngPoint); + } + for (LatLng latLng : LatlngData.getRouteB()) { + boundsBuilder.include(latLng); + } + + LatLngBounds latLngBounds = boundsBuilder.build(); + + mMap.animateCamera(CameraUpdateFactory.newLatLngBounds(latLngBounds, 100), 200, new GoogleMap.CancelableCallback() { + @Override + public void onFinish() { + drawRoutes(); + } + + @Override + public void onCancel() { + + } + }); } - LatLngBounds latLngBounds = boundsBuilder.build(); - - mMap.animateCamera(CameraUpdateFactory.newLatLngBounds(latLngBounds, 100), 200, new CancelableCallback() { - @Override - public void onFinish() { - drawRoutes(); - } - - @Override - public void onCancel() { - - } - }); - } - - private void drawRoutes() { - OverlayPolyline normalOverlayPolyline = new OverlayPolyline.Builder(mRouteOverlayView) - .setRouteType(RouteType.PATH) - .setCameraPosition(mMap.getCameraPosition()) - .setProjection(mMap.getProjection()) - .setLatLngs(mRoute) - .setBottomLayerColor(Color.YELLOW) - .setTopLayerColor(Color.RED) - .create(); - - OverlayPolyline dashOverlayPolyline = new OverlayPolyline.Builder(mRouteOverlayView) - .setRouteType(RouteType.DASH) - .setCameraPosition(mMap.getCameraPosition()) - .setProjection(mMap.getProjection()) - .setLatLngs(LatlngData.getRouteB()) - .setDashColor(Color.BLACK) - .create(); - - OverlayPolyline arcOverlayPolyline = new OverlayPolyline.Builder(mRouteOverlayView) - .setRouteType(RouteType.ARC) - .setCameraPosition(mMap.getCameraPosition()) - .setProjection(mMap.getProjection()) - .setLatLngs(LatlngData.getRouteB()) - .setBottomLayerColor(Color.GRAY) - .setTopLayerColor(Color.BLACK) - .setRouteShadowColor(Color.GRAY) - .create(); - } + private void drawRoutes() { + OverlayPolyline normalOverlayPolyline = new OverlayPolyline.Builder(mRouteOverlayView) + .setRouteType(RouteType.PATH) + .setCameraPosition(mMap.getCameraPosition()) + .setProjection(mMap.getProjection()) + .setLatLngs(mRoute) + .setBottomLayerColor(Color.YELLOW) + .setTopLayerColor(Color.RED) + .create(); + + OverlayPolyline dashOverlayPolyline = new OverlayPolyline.Builder(mRouteOverlayView) + .setRouteType(RouteType.DASH) + .setCameraPosition(mMap.getCameraPosition()) + .setProjection(mMap.getProjection()) + .setLatLngs(LatlngData.getRouteB()) + .setDashColor(Color.BLACK) + .create(); + + OverlayPolyline arcOverlayPolyline = new OverlayPolyline.Builder(mRouteOverlayView) + .setRouteType(RouteType.ARC) + .setCameraPosition(mMap.getCameraPosition()) + .setProjection(mMap.getProjection()) + .setLatLngs(LatlngData.getRouteB()) + .setBottomLayerColor(Color.GRAY) + .setTopLayerColor(Color.BLACK) + .setRouteShadowColor(Color.GRAY) + .create(); + } } diff --git a/app/src/main/java/com/amalbit/animationongooglemap/projectionBased/ViewOverlayActivity.java b/app/src/main/java/com/amalbit/animationongooglemap/projectionBased/ViewOverlayActivity.java index 80577c8..a40648f 100644 --- a/app/src/main/java/com/amalbit/animationongooglemap/projectionBased/ViewOverlayActivity.java +++ b/app/src/main/java/com/amalbit/animationongooglemap/projectionBased/ViewOverlayActivity.java @@ -9,6 +9,7 @@ import android.view.View; import android.view.View.OnClickListener; import android.view.animation.LinearInterpolator; + import com.amalbit.animationongooglemap.R; import com.amalbit.animationongooglemap.U; import com.amalbit.animationongooglemap.data.CarData.Car; @@ -22,422 +23,421 @@ import com.amalbit.trail.marker.OverlayMarkerOptim; import com.amalbit.trail.marker.OverlayMarkerOptim.OnMarkerUpdate; import com.amalbit.trail.marker.ViewOverlayView; -import com.google.android.gms.maps.CameraUpdateFactory; -import com.google.android.gms.maps.GoogleMap; -import com.google.android.gms.maps.OnMapReadyCallback; -import com.google.android.gms.maps.Projection; -import com.google.android.gms.maps.SupportMapFragment; -import com.google.android.gms.maps.model.CameraPosition; -import com.google.android.gms.maps.model.LatLng; -import com.google.android.gms.maps.model.LatLngBounds; -import com.google.android.gms.maps.model.MarkerOptions; +import com.google.android.libraries.maps.CameraUpdateFactory; +import com.google.android.libraries.maps.GoogleMap; +import com.google.android.libraries.maps.OnMapReadyCallback; +import com.google.android.libraries.maps.Projection; +import com.google.android.libraries.maps.SupportMapFragment; +import com.google.android.libraries.maps.model.CameraPosition; +import com.google.android.libraries.maps.model.LatLng; +import com.google.android.libraries.maps.model.LatLngBounds; +import com.google.android.libraries.maps.model.MarkerOptions; + import java.util.ArrayList; import java.util.List; public class ViewOverlayActivity extends BaseActivity implements OnMapReadyCallback, OnClickListener, OnMarkerUpdate { - private GoogleMap mMap; + private GoogleMap mMap; - private OverlayLayout overlayLayout; + private OverlayLayout overlayLayout; - private ViewOverlayView viewOverlayView; + private ViewOverlayView viewOverlayView; - private RouteOverlayView mRouteOverlayView; + private RouteOverlayView mRouteOverlayView; - private List route = LatlngData.getRoute(); + private List route = LatlngData.getRoute(); - private Bitmap dotBitmap; - private Bitmap yellowDotBitmap; - private Bitmap carBitmap; + private Bitmap dotBitmap; + private Bitmap yellowDotBitmap; + private Bitmap carBitmap; - private Repeat repeat; + private Repeat repeat; - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_view_overlay); + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_view_overlay); - dotBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_dot); - yellowDotBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_dot_yellow); - carBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.car); + dotBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_dot); + yellowDotBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_dot_yellow); + carBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.car); - overlayLayout = findViewById(R.id.viewOverLayView); - mRouteOverlayView = overlayLayout.getRouteOverlayView(); - viewOverlayView = overlayLayout.getViewOverlayView(); + overlayLayout = findViewById(R.id.viewOverLayView); + mRouteOverlayView = overlayLayout.getRouteOverlayView(); + viewOverlayView = overlayLayout.getViewOverlayView(); - findViewById(R.id.btnPlus).setOnClickListener(this); - findViewById(R.id.btnMinus).setOnClickListener(this); - findViewById(R.id.btnPrint).setOnClickListener(this); + findViewById(R.id.btnPlus).setOnClickListener(this); + findViewById(R.id.btnMinus).setOnClickListener(this); + findViewById(R.id.btnPrint).setOnClickListener(this); - SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() - .findFragmentById(R.id.map); - mapFragment.getMapAsync(this); - } + SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() + .findFragmentById(R.id.map); + mapFragment.getMapAsync(this); + } - @Override - public void onMapReady(GoogleMap map) { - mMap = map; + @Override + public void onMapReady(GoogleMap map) { + mMap = map; - mMap.setOnMapLoadedCallback(() -> { - overlayLayout.addGoogleMap(map); - initializeLatLngPerPixel(); - updatePixelPerZoom(); + mMap.setOnMapLoadedCallback(() -> { + overlayLayout.addGoogleMap(map); + initializeLatLngPerPixel(); + updatePixelPerZoom(); - mMap.setOnCameraMoveListener(this::onCameraMove); - setMapBoundsRow(map); - addCenterMarker(); - addSecondMarker(); - addNormalMarker(); + mMap.setOnCameraMoveListener(this::onCameraMove); + setMapBoundsRow(map); + addCenterMarker(); + addSecondMarker(); + addNormalMarker(); - mMap.setOnMapClickListener(this::moveToLatLngWithoutProjection); + mMap.setOnMapClickListener(this::moveToLatLngWithoutProjection); - ArrayList indiranagarRoutes = LatlngData.getIndiranagarRoutes(); - repeat = new Repeat(() -> addMarkerWithAnimation(indiranagarRoutes), 2000); + ArrayList indiranagarRoutes = LatlngData.getIndiranagarRoutes(); + repeat = new Repeat(() -> addMarkerWithAnimation(indiranagarRoutes), 2000); - viewOverlayView.post( - () -> repeat.startUpdates() - ); + viewOverlayView.post( + () -> repeat.startUpdates() + ); - OverlayPolyline normalOverlayPolyline = new OverlayPolyline.Builder(mRouteOverlayView) - .setRouteType(RouteType.PATH) - .setCameraPosition(mMap.getCameraPosition()) - .setProjection(mMap.getProjection()) - .setLatLngs(route) - .setBottomLayerColor(Color.YELLOW) - .setTopLayerColor(Color.RED) - .create(); + OverlayPolyline normalOverlayPolyline = new OverlayPolyline.Builder(mRouteOverlayView) + .setRouteType(RouteType.PATH) + .setCameraPosition(mMap.getCameraPosition()) + .setProjection(mMap.getProjection()) + .setLatLngs(route) + .setBottomLayerColor(Color.YELLOW) + .setTopLayerColor(Color.RED) + .create(); - }); - } + }); + } - @Override - protected void onPause() { - super.onPause(); - if (repeat!= null) { - repeat.stopUpdates(); + @Override + protected void onPause() { + super.onPause(); + if (repeat != null) { + repeat.stopUpdates(); + } } - } - @Override - protected void onResume() { - super.onResume(); - if (repeat!= null) { - repeat.startUpdates(); + @Override + protected void onResume() { + super.onResume(); + if (repeat != null) { + repeat.startUpdates(); + } } - } - private void onCameraMove() { - Projection projection = mMap.getProjection(); - CameraPosition cameraPosition = mMap.getCameraPosition(); + private void onCameraMove() { + Projection projection = mMap.getProjection(); + CameraPosition cameraPosition = mMap.getCameraPosition(); - zoomLevel = mMap.getCameraPosition().zoom; + zoomLevel = mMap.getCameraPosition().zoom; // viewOverlayView.onCameraMove(projection, cameraPosition); - updatePixelPerZoom(); - updateMarkerPointsOnScreen(); + updatePixelPerZoom(); + updateMarkerPointsOnScreen(); // mRouteOverlayView.onCameraMove(projection, cameraPosition); - overlayLayout.onCameraMoved(); - } - - public void addMarkerWithAnimation(List cars) { - U.log("doublemarker", "-------------------------------addMarkerWithAnimation----------------------------"); - U.log("doublemarker", "Cars count : " + cars.size()); - U.log("doublemarker", "Markers count : " + viewOverlayView.getOverLayMarkers().size()); - U.log("doublemarker", "---------------------------------------------------------------------------------"); - runOnUiThread(() -> { - for (Car car : cars) { - final OverlayMarkerOptim overlayMarker = viewOverlayView.findMarkerById(car.getCarId()); - if (overlayMarker == null) { - OverlayMarkerOptim overlayMarker1 = new OverlayMarkerOptim(); - overlayMarker1.setIcon(carBitmap.copy(carBitmap.getConfig(), true)); - overlayMarker1.setMarkerId(car.getCarId()); - overlayMarker1.setLatLng(car.getLatLng()); - overlayMarker1.setOnMarkerUpdate(ViewOverlayActivity.this); - - ValueAnimator translateValueAnimator = new ValueAnimator(); - translateValueAnimator.setInterpolator(new LinearInterpolator()); - overlayMarker1.setTranslateValueAnimator(translateValueAnimator); - - ValueAnimator rotateValueAnimator = new ValueAnimator(); - rotateValueAnimator.setInterpolator(new LinearInterpolator()); - overlayMarker1.setRotateValueAnimator(rotateValueAnimator); - - viewOverlayView.addOverlayMarker(overlayMarker1, mMap.getProjection()); - } - else { - final LatLng startLatLng = overlayMarker.getLatLng(); - final LatLng endLatLng = car.getLatLng(); - float bearing = 0; - bearing = getBearing(startLatLng, endLatLng); + overlayLayout.onCameraMoved(); + } + + public void addMarkerWithAnimation(List cars) { + U.log("doublemarker", "-------------------------------addMarkerWithAnimation----------------------------"); + U.log("doublemarker", "Cars count : " + cars.size()); + U.log("doublemarker", "Markers count : " + viewOverlayView.getOverLayMarkers().size()); + U.log("doublemarker", "---------------------------------------------------------------------------------"); + runOnUiThread(() -> { + for (Car car : cars) { + final OverlayMarkerOptim overlayMarker = viewOverlayView.findMarkerById(car.getCarId()); + if (overlayMarker == null) { + OverlayMarkerOptim overlayMarker1 = new OverlayMarkerOptim(); + overlayMarker1.setIcon(carBitmap.copy(carBitmap.getConfig(), true)); + overlayMarker1.setMarkerId(car.getCarId()); + overlayMarker1.setLatLng(car.getLatLng()); + overlayMarker1.setOnMarkerUpdate(ViewOverlayActivity.this); + + ValueAnimator translateValueAnimator = new ValueAnimator(); + translateValueAnimator.setInterpolator(new LinearInterpolator()); + overlayMarker1.setTranslateValueAnimator(translateValueAnimator); + + ValueAnimator rotateValueAnimator = new ValueAnimator(); + rotateValueAnimator.setInterpolator(new LinearInterpolator()); + overlayMarker1.setRotateValueAnimator(rotateValueAnimator); + + viewOverlayView.addOverlayMarker(overlayMarker1, mMap.getProjection()); + } else { + final LatLng startLatLng = overlayMarker.getLatLng(); + final LatLng endLatLng = car.getLatLng(); + float bearing = 0; + bearing = getBearing(startLatLng, endLatLng); // - ValueAnimator valueAnimator = overlayMarker.getTranslateValueAnimator(); - valueAnimator.removeAllUpdateListeners(); - valueAnimator.addUpdateListener(animation -> { - float v = animation.getAnimatedFraction(); - LatLng newPosition = new LatLngInterpolator.Linear().interpolate(v, startLatLng, endLatLng); - moveToLatLngWithoutProjection(newPosition, overlayMarker); - }); - valueAnimator.setFloatValues(0, 1); // Ignored. - valueAnimator.setDuration(2000); - valueAnimator.start(); + ValueAnimator valueAnimator = overlayMarker.getTranslateValueAnimator(); + valueAnimator.removeAllUpdateListeners(); + valueAnimator.addUpdateListener(animation -> { + float v = animation.getAnimatedFraction(); + LatLng newPosition = new LatLngInterpolator.Linear().interpolate(v, startLatLng, endLatLng); + moveToLatLngWithoutProjection(newPosition, overlayMarker); + }); + valueAnimator.setFloatValues(0, 1); // Ignored. + valueAnimator.setDuration(2000); + valueAnimator.start(); // - overlayMarker.setLatLng(endLatLng); - moveToLatLngWithoutProjection(endLatLng, overlayMarker); - - float lastBearing = overlayMarker.getBearing(); - ValueAnimator rotateValueAnimator = overlayMarker.getRotateValueAnimator(); - rotateValueAnimator.removeAllUpdateListeners(); - rotateValueAnimator.cancel(); - - rotateValueAnimator = ValueAnimator.ofFloat(lastBearing, calcMinAngle(lastBearing, bearing)); - rotateValueAnimator.addUpdateListener(animation -> { - float v = (float) animation.getAnimatedValue(); - overlayMarker.setBearing(v); - viewOverlayView.updateMarkerAngle(overlayMarker); - }); - rotateValueAnimator.setDuration(500); - rotateValueAnimator.start(); - - overlayMarker.setRotateValueAnimator(rotateValueAnimator); + overlayMarker.setLatLng(endLatLng); + moveToLatLngWithoutProjection(endLatLng, overlayMarker); + + float lastBearing = overlayMarker.getBearing(); + ValueAnimator rotateValueAnimator = overlayMarker.getRotateValueAnimator(); + rotateValueAnimator.removeAllUpdateListeners(); + rotateValueAnimator.cancel(); + + rotateValueAnimator = ValueAnimator.ofFloat(lastBearing, calcMinAngle(lastBearing, bearing)); + rotateValueAnimator.addUpdateListener(animation -> { + float v = (float) animation.getAnimatedValue(); + overlayMarker.setBearing(v); + viewOverlayView.updateMarkerAngle(overlayMarker); + }); + rotateValueAnimator.setDuration(500); + rotateValueAnimator.start(); + + overlayMarker.setRotateValueAnimator(rotateValueAnimator); + } + + } + }); + } + + private LatLng pointOne = new LatLng(12.9715002, 77.6344856); + private LatLng pointTwo = new LatLng(12.9715002, 77.6354856); + private LatLng pointThree = new LatLng(12.9715002, 77.6364856); + private LatLng pointFour = new LatLng(12.9715002, 77.6374856); + + private LatLng pointFive = new LatLng(12.9725002, 77.6344856); + private LatLng pointSix = new LatLng(12.9725002, 77.6354856); + private LatLng pointSeven = new LatLng(12.9725002, 77.6364856); + private LatLng pointEight = new LatLng(12.9725002, 77.6374856); + + private void setMapBoundsRow(GoogleMap googleMap) { + List latLngs = new ArrayList<>(); + latLngs.add(pointOne); + latLngs.add(pointTwo); + latLngs.add(pointThree); + latLngs.add(pointFour); + LatLngBounds.Builder boundsBuilder = new LatLngBounds.Builder(); + for (LatLng latLngPoint : latLngs) { + boundsBuilder.include(latLngPoint); } + LatLngBounds latLngBounds = boundsBuilder.build(); + googleMap.moveCamera(CameraUpdateFactory.newLatLngBounds(latLngBounds, 100)); + googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(pointTwo, zoomLevel)); + } + + private void addNormalMarker() { + mMap.addMarker(new MarkerOptions().position(pointOne)); + mMap.addMarker(new MarkerOptions().position(pointTwo)); + mMap.addMarker(new MarkerOptions().position(pointThree)); + mMap.addMarker(new MarkerOptions().position(pointFour)); + mMap.addMarker(new MarkerOptions().position(pointFive)); + mMap.addMarker(new MarkerOptions().position(pointSix)); + mMap.addMarker(new MarkerOptions().position(pointSeven)); + mMap.addMarker(new MarkerOptions().position(pointEight)); + } + + private void addCenterMarker() { + LatLng centerLatLng = mMap.getCameraPosition().target; - } - }); - } - - private LatLng pointOne = new LatLng(12.9715002, 77.6344856); - private LatLng pointTwo = new LatLng(12.9715002, 77.6354856); - private LatLng pointThree = new LatLng(12.9715002, 77.6364856); - private LatLng pointFour = new LatLng(12.9715002, 77.6374856); - - private LatLng pointFive = new LatLng(12.9725002, 77.6344856); - private LatLng pointSix = new LatLng(12.9725002, 77.6354856); - private LatLng pointSeven = new LatLng(12.9725002, 77.6364856); - private LatLng pointEight = new LatLng(12.9725002, 77.6374856); - - private void setMapBoundsRow(GoogleMap googleMap) { - List latLngs = new ArrayList<>(); - latLngs.add(pointOne); - latLngs.add(pointTwo); - latLngs.add(pointThree); - latLngs.add(pointFour); - LatLngBounds.Builder boundsBuilder = new LatLngBounds.Builder(); - for (LatLng latLngPoint : latLngs) { - boundsBuilder.include(latLngPoint); + OverlayMarkerOptim overlayMarker1 = new OverlayMarkerOptim(); + overlayMarker1.setIcon(yellowDotBitmap.copy(yellowDotBitmap.getConfig(), true)); + overlayMarker1.setMarkerId(2323); + overlayMarker1.setLatLng(centerLatLng); + overlayMarker1.setOnMarkerUpdate(ViewOverlayActivity.this); + + viewOverlayView.addCenterMarker(overlayMarker1, mMap.getProjection()); } - LatLngBounds latLngBounds = boundsBuilder.build(); - googleMap.moveCamera(CameraUpdateFactory.newLatLngBounds(latLngBounds, 100)); - googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(pointTwo, zoomLevel)); - } - - private void addNormalMarker() { - mMap.addMarker(new MarkerOptions().position(pointOne)); - mMap.addMarker(new MarkerOptions().position(pointTwo)); - mMap.addMarker(new MarkerOptions().position(pointThree)); - mMap.addMarker(new MarkerOptions().position(pointFour)); - mMap.addMarker(new MarkerOptions().position(pointFive)); - mMap.addMarker(new MarkerOptions().position(pointSix)); - mMap.addMarker(new MarkerOptions().position(pointSeven)); - mMap.addMarker(new MarkerOptions().position(pointEight)); - } - - private void addCenterMarker() { - LatLng centerLatLng = mMap.getCameraPosition().target; - - OverlayMarkerOptim overlayMarker1 = new OverlayMarkerOptim(); - overlayMarker1.setIcon(yellowDotBitmap.copy(yellowDotBitmap.getConfig(), true)); - overlayMarker1.setMarkerId(2323); - overlayMarker1.setLatLng(centerLatLng); - overlayMarker1.setOnMarkerUpdate(ViewOverlayActivity.this); - - viewOverlayView.addCenterMarker(overlayMarker1, mMap.getProjection()); - } - - private void addSecondMarker() { - LatLng centerLatLng = mMap.getCameraPosition().target; - - OverlayMarkerOptim overlayMarker1 = new OverlayMarkerOptim(); - overlayMarker1.setIcon(dotBitmap.copy(dotBitmap.getConfig(), true)); - overlayMarker1.setMarkerId(2324); - overlayMarker1.setLatLng(centerLatLng); - overlayMarker1.setOnMarkerUpdate(ViewOverlayActivity.this); - - viewOverlayView.addOverlayMarker(overlayMarker1, mMap.getProjection()); - } - - @Override - public void onMarkerUpdate() { - viewOverlayView.invalidate(); - } - - - private void initializeLatLngPerPixel() { - lastZoomLevel = mMap.getCameraPosition().zoom; - lngPerPixel = average1PixDistanceX(); - } - - private double lngPerPixel = 0.00001404902103; - private float lastZoomLevel = 18; - private float zoomLevel = 18; - - private void updatePixelPerZoom() { - //Pixel 2 xl phone - U.log("updatePixelPerZoom", "lastZoomLevel " + lastZoomLevel); - U.log("updatePixelPerZoom", "zoomLevel " + zoomLevel); - lngPerPixel = lngPerPixel * Math.pow(2, lastZoomLevel - zoomLevel); - U.log("updatePixelPerZoom", "lngPerPixel " + lngPerPixel); - lastZoomLevel = zoomLevel; - } - - private void updateMarkerPointsOnScreen() { - for (OverlayMarkerOptim overlayMarkerOptim : viewOverlayView.getOverLayMarkers()) { - int dx = (int) ((viewOverlayView.getAnchorMarker().getLatLng().longitude - overlayMarkerOptim - .getLatLng().longitude) / lngPerPixel); - int dy = (int) ((viewOverlayView.getAnchorMarker().getLatLng().latitude - overlayMarkerOptim - .getLatLng().latitude) / lngPerPixel); - - U.log("updateMarkerPointsOnScreen", "dx, dy : " + dx + ", " + dy); - U.log("updateMarkerPointsOnScreen", "zoom,latPerPixel :" + zoomLevel + ", " + lngPerPixel); - Point predictedPointOnScreen = new Point( - viewOverlayView.getAnchorMarker().getScreenPoint().x - dx, - viewOverlayView.getAnchorMarker().getScreenPoint().y + dy); - overlayMarkerOptim.setScreenPoint(predictedPointOnScreen); - overlayMarkerOptim.setLatLng(overlayMarkerOptim.getLatLng()); + + private void addSecondMarker() { + LatLng centerLatLng = mMap.getCameraPosition().target; + + OverlayMarkerOptim overlayMarker1 = new OverlayMarkerOptim(); + overlayMarker1.setIcon(dotBitmap.copy(dotBitmap.getConfig(), true)); + overlayMarker1.setMarkerId(2324); + overlayMarker1.setLatLng(centerLatLng); + overlayMarker1.setOnMarkerUpdate(ViewOverlayActivity.this); + + viewOverlayView.addOverlayMarker(overlayMarker1, mMap.getProjection()); } - viewOverlayView.invalidate(); - } - - private void moveToLatLngWithoutProjection(final LatLng latLng, OverlayMarkerOptim overlayMarker1) { - overlayMarker1.setLatLng(latLng); - - //(Difference between longs / 0.00001252926886 ) - int dx = (int) ((viewOverlayView.getAnchorMarker().getLatLng().longitude - latLng.longitude) / lngPerPixel); - //(Difference between lats / 0.00001252926886 ) - int dy = (int) ((viewOverlayView.getAnchorMarker().getLatLng().latitude - latLng.latitude) / lngPerPixel); - - Point predictedPointOnScreen = new Point( - viewOverlayView.getAnchorMarker().getScreenPoint().x - dx, - viewOverlayView.getAnchorMarker().getScreenPoint().y + dy); - overlayMarker1.setScreenPoint(predictedPointOnScreen); - - viewOverlayView.invalidate(); - - U.log("updateMarkerPointsOnScreen", "dx, dy : " + dx + ", " + dy); - U.log("updateMarkerPointsOnScreen", "zoom,latPerPixel :" + zoomLevel + ", " + lngPerPixel); - } - - private void moveToLatLngWithoutProjection(final LatLng latLng) { - - OverlayMarkerOptim overlayMarker1 = new OverlayMarkerOptim(); - overlayMarker1.setIcon(dotBitmap.copy(dotBitmap.getConfig(), true)); - overlayMarker1.setMarkerId(123123); - overlayMarker1.setLatLng(latLng); - overlayMarker1.setOnMarkerUpdate(ViewOverlayActivity.this); - - //(Difference between longs / 0.00001252926886 ) - int dx = (int) ((viewOverlayView.getAnchorMarker().getLatLng().longitude - latLng.longitude) / lngPerPixel); - //(Difference between lats / 0.00001252926886 ) - int dy = (int) ((viewOverlayView.getAnchorMarker().getLatLng().latitude - latLng.latitude) / lngPerPixel); - - Point predictedPointOnScreen = new Point( - viewOverlayView.getAnchorMarker().getScreenPoint().x - dx, - viewOverlayView.getAnchorMarker().getScreenPoint().y + dy); - overlayMarker1.setScreenPoint(predictedPointOnScreen); - - viewOverlayView.addOverlayMarker(overlayMarker1, mMap.getProjection()); - viewOverlayView.invalidate(); - - U.log("updateMarkerPointsOnScreen", "dx, dy : " + dx + ", " + dy); - U.log("updateMarkerPointsOnScreen", "zoom,latPerPixel :" + zoomLevel + ", " + lngPerPixel); - } - - @Override - public void onClick(View v) { - switch (v.getId()) { - case R.id.btnPlus: - zoomLevel += 1; - mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(pointTwo, zoomLevel)); - updatePixelPerZoom(); - updateMarkerPointsOnScreen(); - break; - case R.id.btnMinus: - zoomLevel -= 1; - mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(pointTwo, zoomLevel)); - updatePixelPerZoom(); - updateMarkerPointsOnScreen(); - break; - case R.id.btnPrint: - printAverage1PixDistance(); - break; + + @Override + public void onMarkerUpdate() { + viewOverlayView.invalidate(); + } + + + private void initializeLatLngPerPixel() { + lastZoomLevel = mMap.getCameraPosition().zoom; + lngPerPixel = average1PixDistanceX(); + } + + private double lngPerPixel = 0.00001404902103; + private float lastZoomLevel = 18; + private float zoomLevel = 18; + + private void updatePixelPerZoom() { + //Pixel 2 xl phone + U.log("updatePixelPerZoom", "lastZoomLevel " + lastZoomLevel); + U.log("updatePixelPerZoom", "zoomLevel " + zoomLevel); + lngPerPixel = lngPerPixel * Math.pow(2, lastZoomLevel - zoomLevel); + U.log("updatePixelPerZoom", "lngPerPixel " + lngPerPixel); + lastZoomLevel = zoomLevel; + } + + private void updateMarkerPointsOnScreen() { + for (OverlayMarkerOptim overlayMarkerOptim : viewOverlayView.getOverLayMarkers()) { + int dx = (int) ((viewOverlayView.getAnchorMarker().getLatLng().longitude - overlayMarkerOptim + .getLatLng().longitude) / lngPerPixel); + int dy = (int) ((viewOverlayView.getAnchorMarker().getLatLng().latitude - overlayMarkerOptim + .getLatLng().latitude) / lngPerPixel); + + U.log("updateMarkerPointsOnScreen", "dx, dy : " + dx + ", " + dy); + U.log("updateMarkerPointsOnScreen", "zoom,latPerPixel :" + zoomLevel + ", " + lngPerPixel); + Point predictedPointOnScreen = new Point( + viewOverlayView.getAnchorMarker().getScreenPoint().x - dx, + viewOverlayView.getAnchorMarker().getScreenPoint().y + dy); + overlayMarkerOptim.setScreenPoint(predictedPointOnScreen); + overlayMarkerOptim.setLatLng(overlayMarkerOptim.getLatLng()); + } + viewOverlayView.invalidate(); + } + + private void moveToLatLngWithoutProjection(final LatLng latLng, OverlayMarkerOptim overlayMarker1) { + overlayMarker1.setLatLng(latLng); + + //(Difference between longs / 0.00001252926886 ) + int dx = (int) ((viewOverlayView.getAnchorMarker().getLatLng().longitude - latLng.longitude) / lngPerPixel); + //(Difference between lats / 0.00001252926886 ) + int dy = (int) ((viewOverlayView.getAnchorMarker().getLatLng().latitude - latLng.latitude) / lngPerPixel); + + Point predictedPointOnScreen = new Point( + viewOverlayView.getAnchorMarker().getScreenPoint().x - dx, + viewOverlayView.getAnchorMarker().getScreenPoint().y + dy); + overlayMarker1.setScreenPoint(predictedPointOnScreen); + + viewOverlayView.invalidate(); + + U.log("updateMarkerPointsOnScreen", "dx, dy : " + dx + ", " + dy); + U.log("updateMarkerPointsOnScreen", "zoom,latPerPixel :" + zoomLevel + ", " + lngPerPixel); + } + + private void moveToLatLngWithoutProjection(final LatLng latLng) { + + OverlayMarkerOptim overlayMarker1 = new OverlayMarkerOptim(); + overlayMarker1.setIcon(dotBitmap.copy(dotBitmap.getConfig(), true)); + overlayMarker1.setMarkerId(123123); + overlayMarker1.setLatLng(latLng); + overlayMarker1.setOnMarkerUpdate(ViewOverlayActivity.this); + + //(Difference between longs / 0.00001252926886 ) + int dx = (int) ((viewOverlayView.getAnchorMarker().getLatLng().longitude - latLng.longitude) / lngPerPixel); + //(Difference between lats / 0.00001252926886 ) + int dy = (int) ((viewOverlayView.getAnchorMarker().getLatLng().latitude - latLng.latitude) / lngPerPixel); + + Point predictedPointOnScreen = new Point( + viewOverlayView.getAnchorMarker().getScreenPoint().x - dx, + viewOverlayView.getAnchorMarker().getScreenPoint().y + dy); + overlayMarker1.setScreenPoint(predictedPointOnScreen); + + viewOverlayView.addOverlayMarker(overlayMarker1, mMap.getProjection()); + viewOverlayView.invalidate(); + + U.log("updateMarkerPointsOnScreen", "dx, dy : " + dx + ", " + dy); + U.log("updateMarkerPointsOnScreen", "zoom,latPerPixel :" + zoomLevel + ", " + lngPerPixel); + } + + @Override + public void onClick(View v) { + switch (v.getId()) { + case R.id.btnPlus: + zoomLevel += 1; + mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(pointTwo, zoomLevel)); + updatePixelPerZoom(); + updateMarkerPointsOnScreen(); + break; + case R.id.btnMinus: + zoomLevel -= 1; + mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(pointTwo, zoomLevel)); + updatePixelPerZoom(); + updateMarkerPointsOnScreen(); + break; + case R.id.btnPrint: + printAverage1PixDistance(); + break; + } } - } - private double average1PixDistanceX() { - U.log("average1PixDistanceX", "-------------------------------------------------------------------------"); + private double average1PixDistanceX() { + U.log("average1PixDistanceX", "-------------------------------------------------------------------------"); // double average1pixDistanceY = 0; - double average1pixDistanceX = 0; - for ( int i = 0; i < 100; i++) { + double average1pixDistanceX = 0; + for (int i = 0; i < 100; i++) { - LatLng centerLatlng = mMap.getCameraPosition().target; - Point centerPoint = mMap.getProjection().toScreenLocation(centerLatlng); - U.log("average1PixDistanceX", "centerPoint: " + centerPoint); - centerPoint.x = centerPoint.x + 1; - U.log("average1PixDistanceX", "next centerPoint: " + centerPoint); - LatLng nextCenterLatLng = mMap.getProjection().fromScreenLocation(centerPoint); + LatLng centerLatlng = mMap.getCameraPosition().target; + Point centerPoint = mMap.getProjection().toScreenLocation(centerLatlng); + U.log("average1PixDistanceX", "centerPoint: " + centerPoint); + centerPoint.x = centerPoint.x + 1; + U.log("average1PixDistanceX", "next centerPoint: " + centerPoint); + LatLng nextCenterLatLng = mMap.getProjection().fromScreenLocation(centerPoint); // average1pixDistanceY += nextCenterLatLng.latitude - centerLatlng.latitude; - average1pixDistanceX += nextCenterLatLng.longitude - centerLatlng.longitude; - } + average1pixDistanceX += nextCenterLatLng.longitude - centerLatlng.longitude; + } // U.log("average1PixDistanceX", "average1pixDistanceY" + (average1pixDistanceY / 100)); - U.log("average1PixDistanceX", "average1pixDistanceX" + (average1pixDistanceX / 100)); - - - U.log("average1PixDistanceX", "zoomlevel" + zoomLevel); - - U.log("average1PixDistanceX", "-------------------------------------------------------------------------"); - return Math.abs(average1pixDistanceX/100); - } - - /** - * 1. Find latlng per pixel(LPP) in a particular zoomlevel(ZL). - * 2. Add an invisible anchor marker. Keep listening to get - * projection and update its screen co ordinate on each map movement. - * 3. For each new marker to be added, use this - * formula to find the co-ordinate on screen. (anchorLatLng - newLatlng) / LPP - * 4. For finding LPP. Take two screen points one pixel apart, using projection get the corresponding latLngs and find their difference. This gives us the LPP. - * P1(x, y) = LatLng(lat, lng) - * P2(P1.x+1, P1.y) = LatLng1(lat, lng) - * 1Xpix = LatLng.lat - LatLng1.lat; - * 1Ypix = LatLng.lng - LatLng1.lng; - * - **/ - private void printAverage1PixDistance() { - U.log("printAverage1PixDistance", "-------------------------------------------------------------------------"); + U.log("average1PixDistanceX", "average1pixDistanceX" + (average1pixDistanceX / 100)); + + + U.log("average1PixDistanceX", "zoomlevel" + zoomLevel); + + U.log("average1PixDistanceX", "-------------------------------------------------------------------------"); + return Math.abs(average1pixDistanceX / 100); + } + + /** + * 1. Find latlng per pixel(LPP) in a particular zoomlevel(ZL). + * 2. Add an invisible anchor marker. Keep listening to get + * projection and update its screen co ordinate on each map movement. + * 3. For each new marker to be added, use this + * formula to find the co-ordinate on screen. (anchorLatLng - newLatlng) / LPP + * 4. For finding LPP. Take two screen points one pixel apart, using projection get the corresponding latLngs and find their difference. This gives us the LPP. + * P1(x, y) = LatLng(lat, lng) + * P2(P1.x+1, P1.y) = LatLng1(lat, lng) + * 1Xpix = LatLng.lat - LatLng1.lat; + * 1Ypix = LatLng.lng - LatLng1.lng; + **/ + private void printAverage1PixDistance() { + U.log("printAverage1PixDistance", "-------------------------------------------------------------------------"); // double average1pixDistanceX = 0; - double average1pixDistanceY = 0; - for (int i = 0; i < 100; i++) { - LatLng centerLatlng = mMap.getCameraPosition().target; - Point centerPoint = mMap.getProjection().toScreenLocation(centerLatlng); - U.log("printAverage1PixDistance", "centerPoint: " + centerPoint); + double average1pixDistanceY = 0; + for (int i = 0; i < 100; i++) { + LatLng centerLatlng = mMap.getCameraPosition().target; + Point centerPoint = mMap.getProjection().toScreenLocation(centerLatlng); + U.log("printAverage1PixDistance", "centerPoint: " + centerPoint); // centerPoint.x = centerPoint.x + 1; - centerPoint.y = centerPoint.y + 1; + centerPoint.y = centerPoint.y + 1; // centerPoint.y = centerPoint.y + 1; - U.log("printAverage1PixDistance", "next centerPoint: " + centerPoint); - LatLng nextCenterLatLng = mMap.getProjection().fromScreenLocation(centerPoint); - U.log("printAverage1PixDistance", "1pixDistanceY" + (average1pixDistanceY)); - mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(nextCenterLatLng, zoomLevel)); + U.log("printAverage1PixDistance", "next centerPoint: " + centerPoint); + LatLng nextCenterLatLng = mMap.getProjection().fromScreenLocation(centerPoint); + U.log("printAverage1PixDistance", "1pixDistanceY" + (average1pixDistanceY)); + mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(nextCenterLatLng, zoomLevel)); // average1pixDistanceX += nextCenterLatLng.longitude - centerLatlng.longitude; - average1pixDistanceY += nextCenterLatLng.latitude - centerLatlng.latitude; - } + average1pixDistanceY += nextCenterLatLng.latitude - centerLatlng.latitude; + } // U.log("point", "average1pixDistanceX" + (average1pixDistanceX / 100)); - U.log("printAverage1PixDistance", "average1pixDistanceY" + (average1pixDistanceY / 100)); - U.log("printAverage1PixDistance", "zoomlevel" + zoomLevel); + U.log("printAverage1PixDistance", "average1pixDistanceY" + (average1pixDistanceY / 100)); + U.log("printAverage1PixDistance", "zoomlevel" + zoomLevel); - U.log("printAverage1PixDistance", "-------------------------------------------------------------------------"); - } + U.log("printAverage1PixDistance", "-------------------------------------------------------------------------"); + } // private void findScreenPointForFirstLatLng() { // //Find distance between current center and first point. diff --git a/app/src/main/res/drawable/bg_rect.xml b/app/src/main/res/drawable/bg_rect.xml index d641c47..f59c484 100644 --- a/app/src/main/res/drawable/bg_rect.xml +++ b/app/src/main/res/drawable/bg_rect.xml @@ -1,6 +1,14 @@ - - - - - + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_from_to.xml b/app/src/main/res/layout/activity_from_to.xml index 812e827..3d8336a 100644 --- a/app/src/main/res/layout/activity_from_to.xml +++ b/app/src/main/res/layout/activity_from_to.xml @@ -1,28 +1,31 @@ - - - - - \ No newline at end of file + tools:context=".projectionBased.FromToActivity"> + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_home.xml b/app/src/main/res/layout/activity_home.xml index ca9327c..1d5630a 100644 --- a/app/src/main/res/layout/activity_home.xml +++ b/app/src/main/res/layout/activity_home.xml @@ -1,62 +1,66 @@ - + - - - - -