@@ -7,6 +7,7 @@ import android.content.Intent
77import android.content.SharedPreferences
88import android.content.pm.PackageManager
99import android.graphics.Point
10+ import android.graphics.PointF
1011import android.graphics.drawable.Drawable
1112import android.os.Bundle
1213import android.os.Handler
@@ -29,6 +30,7 @@ import android.widget.Toast
2930import com.mapzen.android.MapView
3031import com.mapzen.android.MapzenMap
3132import com.mapzen.android.lost.api.LocationServices
33+ import com.mapzen.android.model.CameraType
3234import com.mapzen.erasermap.CrashReportService
3335import com.mapzen.erasermap.EraserMapApplication
3436import com.mapzen.erasermap.R
@@ -91,9 +93,6 @@ class MainActivity : AppCompatActivity(), MainViewController,
9193 @JvmStatic val MAP_DATA_PROP_NAME = " name"
9294 @JvmStatic val DIRECTION_LIST_ANIMATION_DURATION = 300L
9395 @JvmStatic val PERMISSIONS_REQUEST : Int = 1
94- @JvmStatic val SCENE_CAMERA = " cameras"
95- @JvmStatic val SCENE_CAMERA_ISOMETRIC = " {isometric: {type: isometric}}"
96- @JvmStatic val SCENE_CAMERA_PERSPECTIVE = " {perspective: {type: perspective}}"
9796 }
9897
9998 @Inject lateinit var savedSearch: SavedSearch
@@ -264,15 +263,15 @@ class MainActivity : AppCompatActivity(), MainViewController,
264263 override fun onSingleTapUp (x : Float , y : Float ): Boolean = false
265264 override fun onSingleTapConfirmed (x : Float , y : Float ): Boolean {
266265 confidenceHandler.longPressed = false
267- val coords = mapzenMap?.coordinatesAtScreenPosition(x.toDouble (), y.toDouble( ))
266+ val coords = mapzenMap?.screenPositionToLngLat( PointF (x.toFloat (), y.toFloat() ))
268267 presenter.reverseGeoLngLat = coords
269268 poiTapPoint = floatArrayOf(x, y)
270269 return true
271270 }
272271 }
273272 mapzenMap?.setDoubleTapResponder({ x, y ->
274273 confidenceHandler.longPressed = false
275- val tappedPos = mapzenMap?.coordinatesAtScreenPosition(x.toDouble (), y.toDouble( ))
274+ val tappedPos = mapzenMap?.screenPositionToLngLat( PointF (x.toFloat (), y.toFloat() ))
276275 val currentPos = mapzenMap?.position
277276 if (tappedPos != null && currentPos != null ) {
278277 mapzenMap?.setZoom((mapzenMap?.zoom as Float ) + 1.0f , 500 )
@@ -663,9 +662,9 @@ class MainActivity : AppCompatActivity(), MainViewController,
663662
664663 val lngLat: LngLat ?
665664 if (poiTapPoint != null ) {
666- val x = poiTapPoint!! [0 ].toDouble ()
667- val y = poiTapPoint!! [1 ].toDouble ()
668- lngLat = mapzenMap?.coordinatesAtScreenPosition( x, y)
665+ val x = poiTapPoint!! [0 ].toFloat ()
666+ val y = poiTapPoint!! [1 ].toFloat ()
667+ lngLat = mapzenMap?.screenPositionToLngLat( PointF ( x, y) )
669668
670669 // Fallback for a failed Pelias Place Callback
671670 overridePlaceFeature(features.get(0 ))
@@ -686,10 +685,10 @@ class MainActivity : AppCompatActivity(), MainViewController,
686685
687686 var lngLat: LngLat ? = null
688687
689- val pointX = poiTapPoint?.get(0 )?.toDouble ()
690- val pointY = poiTapPoint?.get(1 )?.toDouble ()
688+ val pointX = poiTapPoint?.get(0 )?.toFloat ()
689+ val pointY = poiTapPoint?.get(1 )?.toFloat ()
691690 if (pointX != null && pointY != null ) {
692- lngLat = mapzenMap?.coordinatesAtScreenPosition( pointX, pointY)
691+ lngLat = mapzenMap?.screenPositionToLngLat( PointF ( pointX, pointY) )
693692 }
694693
695694 mapzenMap?.clearDroppedPins()
@@ -756,7 +755,7 @@ class MainActivity : AppCompatActivity(), MainViewController,
756755
757756 override fun reverseGeolocate (screenX : Float , screenY : Float ) {
758757 pelias.setLocationProvider(presenter.getPeliasLocationProvider())
759- val coords = mapzenMap?.coordinatesAtScreenPosition( screenX.toDouble (), screenY.toDouble( ))
758+ val coords = mapzenMap?.screenPositionToLngLat( PointF ( screenX.toFloat (), screenY.toFloat() ))
760759 presenter.reverseGeoLngLat = coords
761760 presenter.currentFeature = getGenericLocationFeature(coords?.latitude as Double ,
762761 coords?.longitude as Double )
@@ -878,8 +877,8 @@ class MainActivity : AppCompatActivity(), MainViewController,
878877 val screen = Point ()
879878 windowManager.defaultDisplay.getSize(screen)
880879 // Take half of the y dimension to allow space for other UI elements
881- val viewMin = mapzenMap?.coordinatesAtScreenPosition( 0.0 , screen.y.toDouble () * 0.25 ) ? : LngLat ()
882- val viewMax = mapzenMap?.coordinatesAtScreenPosition( screen.x.toDouble (), screen.y.toDouble () * 0.75 ) ? : LngLat ()
880+ val viewMin = mapzenMap?.screenPositionToLngLat( PointF ( 0.0f , screen.y.toFloat () * 0.25f ) ) ? : LngLat ()
881+ val viewMax = mapzenMap?.screenPositionToLngLat( PointF ( screen.x.toFloat (), screen.y.toFloat () * 0.75f ) ) ? : LngLat ()
883882
884883 // Determine the amount of re-scaling needed to view the route
885884 val scaleX = routeBounds.width / Math .abs(viewMax.longitude - viewMin.longitude)
@@ -1075,14 +1074,12 @@ class MainActivity : AppCompatActivity(), MainViewController,
10751074
10761075 private fun setRoutingCamera () {
10771076 if (routeModeView.isResumeButtonHidden()) {
1078- mapzenMap?.queueSceneUpdate(SCENE_CAMERA , SCENE_CAMERA_PERSPECTIVE )
1079- mapzenMap?.applySceneUpdates()
1077+ mapzenMap?.cameraType = CameraType .PERSPECTIVE
10801078 }
10811079 }
10821080
10831081 private fun setDefaultCamera () {
1084- mapzenMap?.queueSceneUpdate(SCENE_CAMERA , SCENE_CAMERA_ISOMETRIC )
1085- mapzenMap?.applySceneUpdates()
1082+ mapzenMap?.cameraType = CameraType .ISOMETRIC
10861083 }
10871084
10881085 private fun showRoutingMode (feature : Feature ) {
@@ -1115,10 +1112,10 @@ class MainActivity : AppCompatActivity(), MainViewController,
11151112 if (poiTapPoint != null ) {
11161113 val geometry = Geometry ()
11171114 val coordinates = ArrayList <Double >()
1118- val pointX = poiTapPoint?.get(0 )?.toDouble ()
1119- val pointY = poiTapPoint?.get(1 )?.toDouble ()
1115+ val pointX = poiTapPoint?.get(0 )?.toFloat ()
1116+ val pointY = poiTapPoint?.get(1 )?.toFloat ()
11201117 if (pointX != null && pointY != null ) {
1121- val coords = mapzenMap?.coordinatesAtScreenPosition( pointX, pointY)
1118+ val coords = mapzenMap?.screenPositionToLngLat( PointF ( pointX, pointY) )
11221119 val lng = coords?.longitude
11231120 val lat = coords?.latitude
11241121 if (lng != null && lat!= null ) {
0 commit comments