11package com.mapbox.maps.mapbox_maps
22
3+ import android.content.Context
34import com.mapbox.maps.MapboxMap
45import com.mapbox.maps.pigeons.FLTMapInterfaces
56import com.mapbox.maps.plugin.animation.*
67
7- class CameraController (private val mapboxMap : MapboxMap ) : FLTMapInterfaces._CameraManager {
8+ class CameraController (private val mapboxMap : MapboxMap , private val context : Context ) : FLTMapInterfaces._CameraManager {
89 override fun cameraForCoordinateBounds (
910 bounds : FLTMapInterfaces .CoordinateBounds ,
1011 padding : FLTMapInterfaces .MbxEdgeInsets ,
@@ -13,11 +14,11 @@ class CameraController(private val mapboxMap: MapboxMap) : FLTMapInterfaces._Cam
1314 ): FLTMapInterfaces .CameraOptions {
1415 val cameraOptions = mapboxMap.cameraForCoordinateBounds(
1516 bounds.toCoordinateBounds(),
16- padding.toEdgeInsets(),
17+ padding.toEdgeInsets(context ),
1718 bearing,
1819 pitch
1920 )
20- return cameraOptions.toFLTCameraOptions()
21+ return cameraOptions.toFLTCameraOptions(context )
2122 }
2223
2324 override fun cameraForCoordinates (
@@ -28,11 +29,11 @@ class CameraController(private val mapboxMap: MapboxMap) : FLTMapInterfaces._Cam
2829 ): FLTMapInterfaces .CameraOptions {
2930 val cameraOptions = mapboxMap.cameraForCoordinates(
3031 coordinates.map { it.toPoint() },
31- padding.toEdgeInsets(),
32+ padding.toEdgeInsets(context ),
3233 bearing,
3334 pitch
3435 )
35- return cameraOptions.toFLTCameraOptions()
36+ return cameraOptions.toFLTCameraOptions(context )
3637 }
3738
3839 override fun cameraForCoordinatesCameraOptions (
@@ -42,10 +43,10 @@ class CameraController(private val mapboxMap: MapboxMap) : FLTMapInterfaces._Cam
4243 ): FLTMapInterfaces .CameraOptions {
4344 val cameraOptions = mapboxMap.cameraForCoordinates(
4445 coordinates.map { it.toPoint() },
45- camera.toCameraOptions(),
46- box.toScreenBox()
46+ camera.toCameraOptions(context ),
47+ box.toScreenBox(context )
4748 )
48- return cameraOptions.toFLTCameraOptions()
49+ return cameraOptions.toFLTCameraOptions(context )
4950 }
5051
5152 override fun cameraForGeometry (
@@ -56,61 +57,61 @@ class CameraController(private val mapboxMap: MapboxMap) : FLTMapInterfaces._Cam
5657 ): FLTMapInterfaces .CameraOptions {
5758 val cameraOptions = mapboxMap.cameraForGeometry(
5859 geometry.toGeometry(),
59- padding.toEdgeInsets(),
60+ padding.toEdgeInsets(context ),
6061 bearing,
6162 pitch
6263 )
63- return cameraOptions.toFLTCameraOptions()
64+ return cameraOptions.toFLTCameraOptions(context )
6465 }
6566
6667 override fun coordinateBoundsForCamera (camera : FLTMapInterfaces .CameraOptions ): FLTMapInterfaces .CoordinateBounds {
67- val coordinateBounds = mapboxMap.coordinateBoundsForCamera(camera.toCameraOptions())
68+ val coordinateBounds = mapboxMap.coordinateBoundsForCamera(camera.toCameraOptions(context ))
6869 return coordinateBounds.toFLTCoordinateBounds()
6970 }
7071
7172 override fun coordinateBoundsForCameraUnwrapped (camera : FLTMapInterfaces .CameraOptions ): FLTMapInterfaces .CoordinateBounds {
7273 val coordinateBounds =
73- mapboxMap.coordinateBoundsForCameraUnwrapped(camera.toCameraOptions())
74+ mapboxMap.coordinateBoundsForCameraUnwrapped(camera.toCameraOptions(context ))
7475 return coordinateBounds.toFLTCoordinateBounds()
7576 }
7677
7778 override fun coordinateBoundsZoomForCamera (camera : FLTMapInterfaces .CameraOptions ): FLTMapInterfaces .CoordinateBoundsZoom {
78- val coordinateBoundsZoom = mapboxMap.coordinateBoundsZoomForCamera(camera.toCameraOptions())
79+ val coordinateBoundsZoom = mapboxMap.coordinateBoundsZoomForCamera(camera.toCameraOptions(context ))
7980 return coordinateBoundsZoom.toFLTCoordinateBoundsZoom()
8081 }
8182
8283 override fun coordinateBoundsZoomForCameraUnwrapped (camera : FLTMapInterfaces .CameraOptions ): FLTMapInterfaces .CoordinateBoundsZoom {
8384 val coordinateBoundsZoom =
84- mapboxMap.coordinateBoundsZoomForCameraUnwrapped(camera.toCameraOptions())
85+ mapboxMap.coordinateBoundsZoomForCameraUnwrapped(camera.toCameraOptions(context ))
8586 return coordinateBoundsZoom.toFLTCoordinateBoundsZoom()
8687 }
8788
8889 override fun pixelForCoordinate (coordinate : MutableMap <String , Any >): FLTMapInterfaces .ScreenCoordinate {
8990 val screenCoordinate = mapboxMap.pixelForCoordinate(coordinate.toPoint())
90- return screenCoordinate.toFLTScreenCoordinate()
91+ return screenCoordinate.toFLTScreenCoordinate(context )
9192 }
9293
9394 override fun coordinateForPixel (pixel : FLTMapInterfaces .ScreenCoordinate ): MutableMap <String , Any > {
94- val screenCoordinate = mapboxMap.coordinateForPixel(pixel.toScreenCoordinate())
95+ val screenCoordinate = mapboxMap.coordinateForPixel(pixel.toScreenCoordinate(context ))
9596 return screenCoordinate.toMap() as MutableMap <String , Any >
9697 }
9798
9899 override fun pixelsForCoordinates (coordinates : MutableList <MutableMap <String , Any >>): MutableList <FLTMapInterfaces .ScreenCoordinate > {
99100 val screenCoordinates = mapboxMap.pixelsForCoordinates(coordinates.map { it.toPoint() })
100- return screenCoordinates.map { it.toFLTScreenCoordinate() }.toMutableList()
101+ return screenCoordinates.map { it.toFLTScreenCoordinate(context ) }.toMutableList()
101102 }
102103
103104 override fun coordinatesForPixels (pixels : MutableList <FLTMapInterfaces .ScreenCoordinate >): MutableList <MutableMap <String , Any >> {
104- val points = mapboxMap.coordinatesForPixels(pixels.map { it.toScreenCoordinate() })
105+ val points = mapboxMap.coordinatesForPixels(pixels.map { it.toScreenCoordinate(context ) })
105106 return points.map { it.toMap().toMutableMap() }.toMutableList()
106107 }
107108
108109 override fun setCamera (cameraOptions : FLTMapInterfaces .CameraOptions ) {
109- mapboxMap.setCamera(cameraOptions.toCameraOptions())
110+ mapboxMap.setCamera(cameraOptions.toCameraOptions(context ))
110111 }
111112
112113 override fun getCameraState (): FLTMapInterfaces .CameraState {
113- return mapboxMap.cameraState.toCameraState()
114+ return mapboxMap.cameraState.toCameraState(context )
114115 }
115116
116117 override fun setBounds (options : FLTMapInterfaces .CameraBoundsOptions ) {
@@ -122,17 +123,17 @@ class CameraController(private val mapboxMap: MapboxMap) : FLTMapInterfaces._Cam
122123 }
123124
124125 override fun dragStart (point : FLTMapInterfaces .ScreenCoordinate ) {
125- mapboxMap.dragStart(point.toScreenCoordinate())
126+ mapboxMap.dragStart(point.toScreenCoordinate(context ))
126127 }
127128
128129 override fun getDragCameraOptions (
129130 fromPoint : FLTMapInterfaces .ScreenCoordinate ,
130131 toPoint : FLTMapInterfaces .ScreenCoordinate
131132 ): FLTMapInterfaces .CameraOptions {
132133 return mapboxMap.getDragCameraOptions(
133- fromPoint.toScreenCoordinate(),
134- toPoint.toScreenCoordinate()
135- ).toFLTCameraOptions()
134+ fromPoint.toScreenCoordinate(context ),
135+ toPoint.toScreenCoordinate(context )
136+ ).toFLTCameraOptions(context )
136137 }
137138
138139 override fun dragEnd () {
0 commit comments