diff --git a/arcgis_map_sdk/lib/src/arcgis_map_controller.dart b/arcgis_map_sdk/lib/src/arcgis_map_controller.dart index 7c0b870b..4cb7b60e 100644 --- a/arcgis_map_sdk/lib/src/arcgis_map_controller.dart +++ b/arcgis_map_sdk/lib/src/arcgis_map_controller.dart @@ -32,6 +32,11 @@ class ArcgisLocationDisplay { return ArcgisMapPlatform.instance .setLocationDisplayPingAnimationSymbol(mapId, symbol); } + + Future setUseCourseSymbolOnMovement(bool useCourseSymbol) { + return ArcgisMapPlatform.instance + .setUseCourseSymbolOnMovement(mapId, useCourseSymbol); + } } class ArcgisMapController { diff --git a/arcgis_map_sdk_ios/ios/Classes/ArcgisMapView.swift b/arcgis_map_sdk_ios/ios/Classes/ArcgisMapView.swift index 07953e73..99f4a790 100644 --- a/arcgis_map_sdk_ios/ios/Classes/ArcgisMapView.swift +++ b/arcgis_map_sdk_ios/ios/Classes/ArcgisMapView.swift @@ -125,6 +125,7 @@ class ArcgisMapView: NSObject, FlutterPlatformView { case "location_display_set_default_symbol": onSetLocationDisplayDefaultSymbol(call, result) case "location_display_set_accuracy_symbol": onSetLocationDisplayAccuracySymbol(call, result) case "location_display_set_ping_animation_symbol" : onSetLocationDisplayPingAnimationSymbol(call, result) + case "location_display_set_use_course_symbol_on_move" : onSetLocationDisplayUseCourseSymbolOnMove(call, result) default: result(FlutterError(code: "Unimplemented", message: "No method matching the name\(call.method)", details: nil)) } @@ -320,28 +321,41 @@ class ArcgisMapView: NSObject, FlutterPlatformView { } private func onSetLocationDisplayDefaultSymbol(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) { + operationWithSymbol(call, result) { mapView.locationDisplay.defaultSymbol = $0 } + } + + private func onSetLocationDisplayAccuracySymbol(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) { + operationWithSymbol(call, result) { mapView.locationDisplay.accuracySymbol = $0 } + } + + private func onSetLocationDisplayPingAnimationSymbol(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) { + operationWithSymbol(call, result) { mapView.locationDisplay.pingAnimationSymbol = $0 } + } + + + private func onSetLocationDisplayUseCourseSymbolOnMove(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) { + guard let active = call.arguments as? Bool else { + result(FlutterError(code: "missing_data", message: "Invalid arguments.", details: nil)) + return + } + + mapView.locationDisplay.useCourseSymbolOnMovement = active + result(true) + } + + private func operationWithSymbol(_ call: FlutterMethodCall, _ result: @escaping FlutterResult, handler: (AGSSymbol) -> Void) { do { guard let args = call.arguments as? [String: Any] else { result(FlutterError(code: "missing_data", message: "Invalid arguments", details: nil)) return } let symbol = try GraphicsParser().parseSymbol(args) - mapView.locationDisplay.defaultSymbol = symbol + handler(symbol) result(true) } catch { result(FlutterError(code: "unknown_error", message: "Error while adding graphic. \(error)", details: nil)) - return } - result(true) - } - - private func onSetLocationDisplayAccuracySymbol(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) { - result(true) - } - - private func onSetLocationDisplayPingAnimationSymbol(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) { - result(true) } } diff --git a/arcgis_map_sdk_method_channel/lib/src/method_channel_arcgis_map_plugin.dart b/arcgis_map_sdk_method_channel/lib/src/method_channel_arcgis_map_plugin.dart index 5f865484..01b42ac4 100644 --- a/arcgis_map_sdk_method_channel/lib/src/method_channel_arcgis_map_plugin.dart +++ b/arcgis_map_sdk_method_channel/lib/src/method_channel_arcgis_map_plugin.dart @@ -255,4 +255,12 @@ class MethodChannelArcgisMapPlugin extends ArcgisMapPlatform { symbol.toJson(), ); } + + @override + Future setUseCourseSymbolOnMovement(int mapId, bool useCourseSymbol) { + return _methodChannelBuilder(mapId).invokeMethod( + "location_display_set_use_course_symbol_on_move", + useCourseSymbol, + ); + } } diff --git a/arcgis_map_sdk_platform_interface/lib/src/arcgis_map_sdk_platform_interface.dart b/arcgis_map_sdk_platform_interface/lib/src/arcgis_map_sdk_platform_interface.dart index 9f41b766..5c40144b 100644 --- a/arcgis_map_sdk_platform_interface/lib/src/arcgis_map_sdk_platform_interface.dart +++ b/arcgis_map_sdk_platform_interface/lib/src/arcgis_map_sdk_platform_interface.dart @@ -241,4 +241,10 @@ class ArcgisMapPlatform extends PlatformInterface { 'setLocationDisplayPingAnimationSymbol() has not been implemented.', ); } + + Future setUseCourseSymbolOnMovement(int mapId, bool useCourseSymbol) { + throw UnimplementedError( + 'setUseCourseSymbolOnMovement() has not been implemented.', + ); + } } diff --git a/example/lib/location_indicator_example_page.dart b/example/lib/location_indicator_example_page.dart index 6751c41e..60f4f70a 100644 --- a/example/lib/location_indicator_example_page.dart +++ b/example/lib/location_indicator_example_page.dart @@ -16,6 +16,7 @@ class _LocationIndicatorExamplePageState final _snackBarKey = GlobalKey(); ArcgisMapController? _controller; bool _isStarted = false; + bool _useCourseSymbolForMovement = false; @override Widget build(BuildContext context) { @@ -41,17 +42,48 @@ class _LocationIndicatorExamplePageState setState(() => _isStarted = !_isStarted); }, ), - body: ArcgisMap( - apiKey: arcGisApiKey, - initialCenter: const LatLng(51.16, 10.45), - zoom: 13, - basemap: BaseMap.arcgisNavigationNight, - mapStyle: MapStyle.twoD, - onMapCreated: (controller) { - _controller = controller; - _requestLocationPermission(); - _configureLocationDisplay(); - }, + body: Column( + children: [ + Expanded( + child: ArcgisMap( + apiKey: arcGisApiKey, + initialCenter: const LatLng(51.16, 10.45), + zoom: 13, + basemap: BaseMap.arcgisNavigationNight, + mapStyle: MapStyle.twoD, + onMapCreated: (controller) { + _controller = controller; + _requestLocationPermission(); + _configureLocationDisplay(Colors.blue); + }, + ), + ), + const SizedBox(height: 16), + ElevatedButton( + onPressed: () => _configureLocationDisplay(Colors.green), + child: Text("tint indicator green"), + ), + const SizedBox(width: 8), + ElevatedButton( + onPressed: () => _configureLocationDisplay(Colors.red), + child: Text("tint indicator red"), + ), + ElevatedButton( + onPressed: () { + setState( + () => + _useCourseSymbolForMovement = !_useCourseSymbolForMovement, + ); + _configureLocationDisplay(Colors.red); + }, + child: Text( + _useCourseSymbolForMovement + ? "Disable course indicator" + : "Enable course indicator", + ), + ), + SizedBox(height: MediaQuery.paddingOf(context).bottom), + ], ), ); } @@ -63,28 +95,29 @@ class _LocationIndicatorExamplePageState await _controller!.moveCamera( point: LatLng(location.latitude, location.longitude), - zoomLevel: 12, + zoomLevel: 16, ); } - Future _configureLocationDisplay() async { + Future _configureLocationDisplay(MaterialColor color) async { + await _controller!.locationDisplay.setUseCourseSymbolOnMovement( + _useCourseSymbolForMovement, + ); await _controller!.locationDisplay.setDefaultSymbol( SimpleMarkerSymbol( - color: Colors.pink, - outlineColor: Colors.amberAccent, + color: color.shade100, + outlineColor: color.shade500, + radius: 24, ), ); await _controller!.locationDisplay.setPingAnimationSymbol( SimpleMarkerSymbol( - color: Colors.blueAccent, - outlineColor: Colors.blue.withOpacity(0.5), + color: color.shade50, + outlineColor: color.shade900, ), ); await _controller!.locationDisplay.setAccuracySymbol( - SimpleMarkerSymbol( - color: Colors.deepPurple, - outlineColor: Colors.deepPurple, - ), + SimpleLineSymbol(color: color.shade800, width: 3), ); } }