Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;

import io.flutter.plugin.common.BinaryMessenger;
import io.flutter.plugin.common.MethodCall;
Expand Down Expand Up @@ -439,6 +440,25 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result
result.success(null);
break;
}
case "map#setViewpointScaleAsync": {
final Map<?, ?> data = call.arguments();
if (mapView != null && data != null) {
double scale = (double) data.get("scale");
ListenableFuture<Boolean> future = mapView.setViewpointScaleAsync(scale);
future.addDoneListener(() -> {
boolean scaled = false;
try {
scaled = future.get();
result.success(scaled);
} catch (ExecutionException | InterruptedException e) {
result.success(false);
}
});
} else {
result.success(false);
}
break;
}
default:
result.notImplemented();
break;
Expand Down
10 changes: 10 additions & 0 deletions ios/Classes/Map/ArcgisMapController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,16 @@ public class ArcgisMapController: NSObject, FlutterPlatformView {
layersController.setTimeOffset(arguments: call.arguments)
result(nil)
break
case "map#setViewpointScaleAsync":
if let data = call.arguments as? Dictionary<String, Any> {
let scale = data["scale"] as! Double
mapView.setViewpointScale(scale, completion: { finished in
result(finished)
})
} else {
result(false)
}
break
default:
result(FlutterMethodNotImplemented)
break
Expand Down
12 changes: 12 additions & 0 deletions lib/src/mapping/view/map/arcgis_map_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,18 @@ class ArcgisMapController {
.setViewpointRotation(mapId, angleDegrees);
}

/// Asynchronously zooms the map, with animation, to the given scale.
/// The map center point does not change.
/// The map scale is the number of map units per unit of physical device size.
/// It expresses the relationship between a distance in the MapView and the corresponding distance on the ground.
/// A smaller value will zoom the map in and produce a larger map display area (features appear larger).
/// A larger value will zoom the map out and produce a smaller map display area (features appear smaller).
Future<bool> setViewpointScale(double scale) async {
assert(scale >= 0);
return await ArcgisMapsFlutterPlatform.instance
.setViewpointScale(mapId, scale);
}

Future<Viewpoint?> getCurrentViewpoint(ViewpointType type) {
return ArcgisMapsFlutterPlatform.instance.getCurrentViewpoint(mapId, type);
}
Expand Down
5 changes: 5 additions & 0 deletions lib/src/method_channel/map/arcgis_maps_flutter_platform.dart
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ abstract class ArcgisMapsFlutterPlatform extends PlatformInterface {
'onViewpointChangedListener() has not been implemented.');
}

Future<bool> setViewpointScale(int mapId, double scale) {
throw UnimplementedError(
'setViewpointScale() has not been implemented.');
}

Future<Offset?> locationToScreen(int mapId, AGSPoint mapPoint) {
throw UnimplementedError('locationToScreen() has not been implemented.');
}
Expand Down
10 changes: 10 additions & 0 deletions lib/src/method_channel/map/method_channel_arcgis_maps_flutter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,16 @@ class MethodChannelArcgisMapsFlutter extends ArcgisMapsFlutterPlatform {
.invokeMethod<void>("map#setViewpointRotation", angleDegrees);
}

@override
Future<bool> setViewpointScale(int mapId, double scale) async{
final result = await channel(mapId).invokeMethod<bool>(
'map#setViewpointScaleAsync',
{
'scale': scale,
},
);
return result ?? false;
}
@override
Future<Offset?> locationToScreen(int mapId, AGSPoint mapPoint) async {
final result = await channel(mapId)
Expand Down