Skip to content

Commit

Permalink
round result of toScreenLocation()
Browse files Browse the repository at this point in the history
  • Loading branch information
m0nac0 committed Aug 14, 2020
1 parent 5367985 commit 838726a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/src/controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<Point> toScreenLocation(LatLng latLng) async{
Future<Point<int>> toScreenLocation(LatLng latLng) async{
return MapboxGlPlatform.getInstance(_id).toScreenLocation(latLng);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ abstract class MapboxGlPlatform {
'setSymbolTextIgnorePlacement() has not been implemented.');
}

Future<Point> toScreenLocation(LatLng latLng) async{
Future<Point<int>> toScreenLocation(LatLng latLng) async{
throw UnimplementedError(
'toScreenLocation() has not been implemented.');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -454,14 +454,14 @@ class MethodChannelMapboxGl extends MapboxGlPlatform {
}

@override
Future<Point> toScreenLocation(LatLng latLng) async {
Future<Point<int>> toScreenLocation(LatLng latLng) async {
try {
var screenPosMap = await _channel
.invokeMethod('map#toScreenLocation', <String, dynamic>{
'latitude': latLng.latitude,
'longitude':latLng.longitude,
});
return Point(screenPosMap['x'], screenPosMap['y']);
return Point<int>((screenPosMap['x'] as num).round(), (screenPosMap['y'] as num).round());
} on PlatformException catch (e) {
return new Future.error(e);
}
Expand Down
4 changes: 2 additions & 2 deletions mapbox_gl_web/lib/src/mapbox_map_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -613,9 +613,9 @@ class MapboxMapController extends MapboxGlPlatform
}

@override
Future<Point> toScreenLocation(LatLng latLng) async {
Future<Point<int>> toScreenLocation(LatLng latLng) async {
var screenPosition = _map.project(LngLat(latLng.longitude, latLng.latitude));
return Point(screenPosition.x.round(), screenPosition.y.round());
return Point<int>(screenPosition.x.round(), screenPosition.y.round());
}

@override
Expand Down

0 comments on commit 838726a

Please sign in to comment.