diff --git a/lib/src/controller.dart b/lib/src/controller.dart index 64a201cad..bb48b1597 100644 --- a/lib/src/controller.dart +++ b/lib/src/controller.dart @@ -673,7 +673,7 @@ class MapboxMapController extends ChangeNotifier { /// Returns the point on the screen that corresponds to a geographical coordinate ([latLng]). The screen location is in screen pixels (not display pixels) relative to the top left of the map (not of the whole screen) /// Returns null if [latLng] is not currently visible on the map. - Future toScreenLocation(LatLng latLng) async{ + Future> toScreenLocation(LatLng latLng) async{ return MapboxGlPlatform.getInstance(_id).toScreenLocation(latLng); } diff --git a/mapbox_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart b/mapbox_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart index b53873293..f87633628 100644 --- a/mapbox_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart +++ b/mapbox_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart @@ -211,7 +211,7 @@ abstract class MapboxGlPlatform { 'setSymbolTextIgnorePlacement() has not been implemented.'); } - Future toScreenLocation(LatLng latLng) async{ + Future> toScreenLocation(LatLng latLng) async{ throw UnimplementedError( 'toScreenLocation() has not been implemented.'); } diff --git a/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart b/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart index 1f512e27c..94bb99aad 100644 --- a/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart +++ b/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart @@ -454,14 +454,14 @@ class MethodChannelMapboxGl extends MapboxGlPlatform { } @override - Future toScreenLocation(LatLng latLng) async { + Future> toScreenLocation(LatLng latLng) async { try { var screenPosMap = await _channel .invokeMethod('map#toScreenLocation', { 'latitude': latLng.latitude, 'longitude':latLng.longitude, }); - return Point(screenPosMap['x'], screenPosMap['y']); + return Point((screenPosMap['x'] as num).round(), (screenPosMap['y'] as num).round()); } on PlatformException catch (e) { return new Future.error(e); } diff --git a/mapbox_gl_web/lib/src/mapbox_map_controller.dart b/mapbox_gl_web/lib/src/mapbox_map_controller.dart index 1bae399ca..0960c4fe4 100644 --- a/mapbox_gl_web/lib/src/mapbox_map_controller.dart +++ b/mapbox_gl_web/lib/src/mapbox_map_controller.dart @@ -613,9 +613,9 @@ class MapboxMapController extends MapboxGlPlatform } @override - Future toScreenLocation(LatLng latLng) async { + Future> toScreenLocation(LatLng latLng) async { var screenPosition = _map.project(LngLat(latLng.longitude, latLng.latitude)); - return Point(screenPosition.x.round(), screenPosition.y.round()); + return Point(screenPosition.x.round(), screenPosition.y.round()); } @override