diff --git a/app/build.gradle b/app/build.gradle index 36ce9319..de30a08e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -128,7 +128,7 @@ gradle.startParameter.getTaskNames().each { task -> dependencies { compile 'com.android.support:appcompat-v7:23.4.0' compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - compile 'com.mapzen:mapzen-android-sdk:1.0.5' + compile 'com.mapzen:mapzen-android-sdk:1.0.6' compile('com.mapzen.android:pelias-android-sdk:0.7.1') { exclude group: 'javax.annotation:javax', module: 'javax.annotation-api' } diff --git a/app/src/main/kotlin/com/mapzen/erasermap/controller/MainActivity.kt b/app/src/main/kotlin/com/mapzen/erasermap/controller/MainActivity.kt index 861094c3..a8ba7148 100644 --- a/app/src/main/kotlin/com/mapzen/erasermap/controller/MainActivity.kt +++ b/app/src/main/kotlin/com/mapzen/erasermap/controller/MainActivity.kt @@ -7,6 +7,7 @@ import android.content.Intent import android.content.SharedPreferences import android.content.pm.PackageManager import android.graphics.Point +import android.graphics.PointF import android.graphics.drawable.Drawable import android.os.Bundle import android.os.Handler @@ -29,6 +30,7 @@ import android.widget.Toast import com.mapzen.android.MapView import com.mapzen.android.MapzenMap import com.mapzen.android.lost.api.LocationServices +import com.mapzen.android.model.CameraType import com.mapzen.erasermap.CrashReportService import com.mapzen.erasermap.EraserMapApplication import com.mapzen.erasermap.R @@ -91,9 +93,6 @@ class MainActivity : AppCompatActivity(), MainViewController, @JvmStatic val MAP_DATA_PROP_NAME = "name" @JvmStatic val DIRECTION_LIST_ANIMATION_DURATION = 300L @JvmStatic val PERMISSIONS_REQUEST: Int = 1 - @JvmStatic val SCENE_CAMERA = "cameras" - @JvmStatic val SCENE_CAMERA_ISOMETRIC = "{isometric: {type: isometric}}" - @JvmStatic val SCENE_CAMERA_PERSPECTIVE = "{perspective: {type: perspective}}" } @Inject lateinit var savedSearch: SavedSearch @@ -264,7 +263,7 @@ class MainActivity : AppCompatActivity(), MainViewController, override fun onSingleTapUp(x: Float, y: Float): Boolean = false override fun onSingleTapConfirmed(x: Float, y: Float): Boolean { confidenceHandler.longPressed = false - val coords = mapzenMap?.coordinatesAtScreenPosition(x.toDouble(), y.toDouble()) + val coords = mapzenMap?.screenPositionToLngLat(PointF(x.toFloat(), y.toFloat())) presenter.reverseGeoLngLat = coords poiTapPoint = floatArrayOf(x, y) return true @@ -272,7 +271,7 @@ class MainActivity : AppCompatActivity(), MainViewController, } mapzenMap?.setDoubleTapResponder({ x, y -> confidenceHandler.longPressed = false - val tappedPos = mapzenMap?.coordinatesAtScreenPosition(x.toDouble(), y.toDouble()) + val tappedPos = mapzenMap?.screenPositionToLngLat(PointF(x.toFloat(), y.toFloat())) val currentPos = mapzenMap?.position if (tappedPos != null && currentPos != null) { mapzenMap?.setZoom((mapzenMap?.zoom as Float) + 1.0f, 500) @@ -663,9 +662,9 @@ class MainActivity : AppCompatActivity(), MainViewController, val lngLat: LngLat? if (poiTapPoint != null) { - val x = poiTapPoint!![0].toDouble() - val y = poiTapPoint!![1].toDouble() - lngLat = mapzenMap?.coordinatesAtScreenPosition(x, y) + val x = poiTapPoint!![0].toFloat() + val y = poiTapPoint!![1].toFloat() + lngLat = mapzenMap?.screenPositionToLngLat(PointF(x, y)) // Fallback for a failed Pelias Place Callback overridePlaceFeature(features.get(0)) @@ -686,10 +685,10 @@ class MainActivity : AppCompatActivity(), MainViewController, var lngLat: LngLat? = null - val pointX = poiTapPoint?.get(0)?.toDouble() - val pointY = poiTapPoint?.get(1)?.toDouble() + val pointX = poiTapPoint?.get(0)?.toFloat() + val pointY = poiTapPoint?.get(1)?.toFloat() if (pointX != null && pointY != null) { - lngLat = mapzenMap?.coordinatesAtScreenPosition(pointX, pointY) + lngLat = mapzenMap?.screenPositionToLngLat(PointF(pointX, pointY)) } mapzenMap?.clearDroppedPins() @@ -756,7 +755,7 @@ class MainActivity : AppCompatActivity(), MainViewController, override fun reverseGeolocate(screenX: Float, screenY: Float) { pelias.setLocationProvider(presenter.getPeliasLocationProvider()) - val coords = mapzenMap?.coordinatesAtScreenPosition(screenX.toDouble(), screenY.toDouble()) + val coords = mapzenMap?.screenPositionToLngLat(PointF(screenX.toFloat(), screenY.toFloat())) presenter.reverseGeoLngLat = coords presenter.currentFeature = getGenericLocationFeature(coords?.latitude as Double, coords?.longitude as Double) @@ -878,8 +877,8 @@ class MainActivity : AppCompatActivity(), MainViewController, val screen = Point() windowManager.defaultDisplay.getSize(screen) // Take half of the y dimension to allow space for other UI elements - val viewMin = mapzenMap?.coordinatesAtScreenPosition(0.0, screen.y.toDouble() * 0.25) ?: LngLat() - val viewMax = mapzenMap?.coordinatesAtScreenPosition(screen.x.toDouble(), screen.y.toDouble() * 0.75) ?: LngLat() + val viewMin = mapzenMap?.screenPositionToLngLat(PointF(0.0f, screen.y.toFloat() * 0.25f)) ?: LngLat() + val viewMax = mapzenMap?.screenPositionToLngLat(PointF(screen.x.toFloat(), screen.y.toFloat() * 0.75f)) ?: LngLat() // Determine the amount of re-scaling needed to view the route val scaleX = routeBounds.width / Math.abs(viewMax.longitude - viewMin.longitude) @@ -1075,14 +1074,12 @@ class MainActivity : AppCompatActivity(), MainViewController, private fun setRoutingCamera() { if (routeModeView.isResumeButtonHidden()) { - mapzenMap?.queueSceneUpdate(SCENE_CAMERA, SCENE_CAMERA_PERSPECTIVE) - mapzenMap?.applySceneUpdates() + mapzenMap?.cameraType = CameraType.PERSPECTIVE } } private fun setDefaultCamera() { - mapzenMap?.queueSceneUpdate(SCENE_CAMERA, SCENE_CAMERA_ISOMETRIC) - mapzenMap?.applySceneUpdates() + mapzenMap?.cameraType = CameraType.ISOMETRIC } private fun showRoutingMode(feature: Feature) { @@ -1115,10 +1112,10 @@ class MainActivity : AppCompatActivity(), MainViewController, if (poiTapPoint != null) { val geometry = Geometry() val coordinates = ArrayList() - val pointX = poiTapPoint?.get(0)?.toDouble() - val pointY = poiTapPoint?.get(1)?.toDouble() + val pointX = poiTapPoint?.get(0)?.toFloat() + val pointY = poiTapPoint?.get(1)?.toFloat() if (pointX != null && pointY != null) { - val coords = mapzenMap?.coordinatesAtScreenPosition(pointX, pointY) + val coords = mapzenMap?.screenPositionToLngLat(PointF(pointX, pointY)) val lng = coords?.longitude val lat = coords?.latitude if (lng != null && lat!= null) { diff --git a/app/src/main/kotlin/com/mapzen/erasermap/model/MapzenLocationImpl.kt b/app/src/main/kotlin/com/mapzen/erasermap/model/MapzenLocationImpl.kt index ef8b6e68..7e72fcad 100644 --- a/app/src/main/kotlin/com/mapzen/erasermap/model/MapzenLocationImpl.kt +++ b/app/src/main/kotlin/com/mapzen/erasermap/model/MapzenLocationImpl.kt @@ -1,6 +1,7 @@ package com.mapzen.erasermap.model import android.content.Context +import android.graphics.PointF import android.location.Location import android.util.Log import android.view.WindowManager @@ -99,8 +100,8 @@ public class MapzenLocationImpl(val locationClient: LostApiClient, override fun getLat(): Double { val windowManager = application.getSystemService(Context.WINDOW_SERVICE) as WindowManager val display = windowManager.defaultDisplay - val midLatLon = mapzenMap?.coordinatesAtScreenPosition(display.width.toDouble()/2, - display.height.toDouble()/2) + val midLatLon = mapzenMap?.screenPositionToLngLat(PointF(display.width.toFloat() / 2, + display.height.toFloat() / 2)) if (midLatLon?.latitude == null) { return 0.0 } @@ -110,8 +111,8 @@ public class MapzenLocationImpl(val locationClient: LostApiClient, override fun getLon(): Double { val windowManager = application.getSystemService(Context.WINDOW_SERVICE) as WindowManager val display = windowManager.defaultDisplay - val midLatLon = mapzenMap?.coordinatesAtScreenPosition(display.width.toDouble()/2, - display.height.toDouble()/2) + val midLatLon = mapzenMap?.screenPositionToLngLat(PointF(display.width.toFloat()/2, + display.height.toFloat()/2)) if (midLatLon?.longitude == null) { return 0.0 } @@ -121,8 +122,8 @@ public class MapzenLocationImpl(val locationClient: LostApiClient, override fun getBoundingBox(): BoundingBox? { val windowManager = application.getSystemService(Context.WINDOW_SERVICE) as WindowManager val display = windowManager.defaultDisplay - val minLatLon = mapzenMap?.coordinatesAtScreenPosition(0.0, display.height.toDouble()) - val maxLatLon = mapzenMap?.coordinatesAtScreenPosition(display.width.toDouble(), 0.0) + val minLatLon = mapzenMap?.screenPositionToLngLat(PointF(0.0f, display.height.toFloat())) + val maxLatLon = mapzenMap?.screenPositionToLngLat(PointF(display.width.toFloat(), 0.0f)) val boundingBox: BoundingBox = BoundingBox( minLatLon?.latitude as Double, minLatLon?.longitude as Double, diff --git a/app/src/main/kotlin/com/mapzen/erasermap/view/RouteModeView.kt b/app/src/main/kotlin/com/mapzen/erasermap/view/RouteModeView.kt index a301a440..50114ebc 100644 --- a/app/src/main/kotlin/com/mapzen/erasermap/view/RouteModeView.kt +++ b/app/src/main/kotlin/com/mapzen/erasermap/view/RouteModeView.kt @@ -2,6 +2,7 @@ package com.mapzen.erasermap.view import android.content.Context import android.graphics.Point +import android.graphics.PointF import android.location.Location import android.os.Handler import android.support.v4.view.PagerAdapter @@ -283,13 +284,13 @@ class RouteModeView : LinearLayout, RouteViewController, ViewPager.OnPageChangeL val display = windowManager.defaultDisplay val point = Point() display.getSize(point) - val screenWidth = point.x.toDouble() - val screenHeight = point.y.toDouble() + val screenWidth = point.x.toFloat() + val screenHeight = point.y.toFloat() // Find the view that will place the current location marker in the lower quarter // of the window. - val nextPosition = mapzenMap?.coordinatesAtScreenPosition(screenWidth/2, - screenHeight/3.5) ?: LngLat() + val nextPosition = mapzenMap?.screenPositionToLngLat(PointF(screenWidth / 2, + screenHeight / 3.5f)) ?: LngLat() val nextRotation = getBearingInRadians(location) // Return to our initial view to prepare for easing to the next view