diff --git a/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java b/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java index f1a6a19ab..75360311f 100644 --- a/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java +++ b/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java @@ -60,7 +60,6 @@ import com.mapbox.mapboxsdk.plugins.annotation.Line; import com.mapbox.mapboxsdk.plugins.annotation.LineManager; import com.mapbox.mapboxsdk.plugins.annotation.OnAnnotationClickListener; -import com.mapbox.mapboxsdk.plugins.annotation.OnSymbolDragListener; import com.mapbox.mapboxsdk.plugins.annotation.Symbol; import com.mapbox.mapboxsdk.plugins.annotation.SymbolManager; import com.mapbox.mapboxsdk.plugins.annotation.SymbolOptions; @@ -380,40 +379,6 @@ private void enableSymbolManager(@NonNull Style style) { symbolManager.setTextAllowOverlap(true); symbolManager.setTextIgnorePlacement(true); symbolManager.addClickListener(MapboxMapController.this::onAnnotationClick); - symbolManager.addDragListener(new OnSymbolDragListener() { - @Override - public void onAnnotationDragStarted(Symbol annotation) { - - final Map arguments = new HashMap<>(3); - arguments.put("lat",annotation.getLatLng().getLatitude()); - arguments.put("lng",annotation.getLatLng().getLongitude()); - arguments.put("symbol",String.valueOf(annotation.getId())); - methodChannel.invokeMethod("map#onAnnotationDragStarted",arguments); - Log.e(TAG, "onAnnotationDragStarted"); - } - - @Override - public void onAnnotationDrag(Symbol annotation) { - - final Map arguments = new HashMap<>(3); - arguments.put("lat",annotation.getLatLng().getLatitude()); - arguments.put("lng",annotation.getLatLng().getLongitude()); - arguments.put("symbol",String.valueOf(annotation.getId())); - methodChannel.invokeMethod("map#onAnnotationDrag",arguments); - } - - @Override - public void onAnnotationDragFinished(Symbol annotation) { - - Log.e(TAG, "onAnnotationDragFinished"); - final Map arguments = new HashMap<>(3); - arguments.put("lat",annotation.getLatLng().getLatitude()); - arguments.put("lng",annotation.getLatLng().getLongitude()); - arguments.put("symbol",String.valueOf(annotation.getId())); - methodChannel.invokeMethod("map#onAnnotationDragFinished",arguments); - - } - }); } } diff --git a/example/lib/main.dart b/example/lib/main.dart index 6c9337761..bb424a402 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -8,7 +8,6 @@ import 'package:location/location.dart'; import 'package:mapbox_gl_example/custom_marker.dart'; import 'package:mapbox_gl_example/full_map.dart'; import 'package:mapbox_gl_example/offline_regions.dart'; -import 'package:mapbox_gl_example/symbol_drag.dart'; import 'animate_camera.dart'; import 'annotation_order_maps.dart'; @@ -39,7 +38,6 @@ final List _allPages = [ OfflineRegionsPage(), AnnotationOrderPage(), CustomMarkerPage(), - SymbolDragPage(), ]; class MapsDemo extends StatelessWidget { diff --git a/example/lib/symbol_drag.dart b/example/lib/symbol_drag.dart deleted file mode 100644 index 3c66530b3..000000000 --- a/example/lib/symbol_drag.dart +++ /dev/null @@ -1,113 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:mapbox_gl/mapbox_gl.dart'; - -import 'main.dart'; -import 'page.dart'; - -class SymbolDragPage extends ExamplePage { - SymbolDragPage() : super(const Icon(Icons.map), 'Symbol Drag Events'); - - @override - Widget build(BuildContext context) { - return const SymbolDrag(); - } -} - -class SymbolDrag extends StatefulWidget { - const SymbolDrag(); - - @override - State createState() => SymbolDragState(); -} - -class SymbolDragState extends State { - MapboxMapController mapController; - - DragEventType type = DragEventType.none; - - LatLng latLng = new LatLng(0,0); - LatLng prevLatLng = new LatLng(0,0); - - void _onMapCreated(MapboxMapController controller) { - mapController = controller; - - controller.onSymbolDragged.add((argument) { - - setState(() { - type = argument.eventType; - latLng = argument.currentLatLng; - prevLatLng = argument.previousLatLng; - - }); - switch(argument.eventType) - { - case DragEventType.start: - // TODO: Handle this case. - break; - case DragEventType.drag: - // TODO: Handle this case. - break; - case DragEventType.end: - - break; - case DragEventType.none: - // TODO: Handle this case. - break; - } - - }); - } - - @override - Widget build(BuildContext context) { - return new Scaffold( - - - body: Column( - mainAxisSize: MainAxisSize.max, - children: [ - Padding( - padding: const EdgeInsets.all(8.0), - child: Container( height: 70.0, - child: Column(children: [ - Text("Event type :$type", style: TextStyle(fontSize: 11),), - SizedBox(height: 10,), - Text("Current :$latLng", style: TextStyle(fontSize: 11),), - SizedBox(height: 10,), - Text("Previous :$prevLatLng", style: TextStyle(fontSize: 11),), - - ],), - ), - ), - Expanded( - child: MapboxMap( - accessToken: MapsDemo.ACCESS_TOKEN, - onMapCreated: _onMapCreated, - initialCameraPosition: const CameraPosition(target: LatLng(0.0, 0.0)), - onStyleLoadedCallback: onStyleLoadedCallback, - ), - ), - ], - )); - } - - void onStyleLoadedCallback() { - - mapController.addSymbol(SymbolOptions( - geometry: LatLng(0,0), - iconImage: "airport-15", - iconSize: 2.0, - draggable: true, - )); - - - } - - @override - void dispose() { - - mapController.dispose(); - - super.dispose(); - } -} diff --git a/lib/src/controller.dart b/lib/src/controller.dart index e9dd15a10..b98803bf9 100644 --- a/lib/src/controller.dart +++ b/lib/src/controller.dart @@ -18,27 +18,6 @@ typedef void OnCameraIdleCallback(); typedef void OnMapIdleCallback(); - -enum DragEventType -{ - start, - drag, - end, - none, -} - - -class SymbolDragEventArgs -{ - final Symbol symbol; - final LatLng currentLatLng; - final LatLng previousLatLng; - final DragEventType eventType; - - SymbolDragEventArgs({@required this.symbol, @required this.currentLatLng, this.previousLatLng, @required this.eventType}); - -} - /// Controller for a single MapboxMap instance running on the host platform. /// /// Change listeners are notified upon changes to any of @@ -83,31 +62,6 @@ class MapboxMapController extends ChangeNotifier { } }); - MapboxGlPlatform.getInstance(_id).onSymbolDraggedPlatform.add((args) { - final Symbol symbol = _symbols[args['symbol']]; - final LatLng latLng = args["latLng"]; - - DragEventType type = DragEventType.values.firstWhere((e) => e.toString() == "DragEventType.${args['type']}"); - SymbolDragEventArgs eventArg = new SymbolDragEventArgs( - symbol: symbol, - eventType: type, - currentLatLng: latLng, - previousLatLng: new LatLng(symbol.options.geometry.latitude, symbol.options.geometry.longitude) - ); - - if(type == DragEventType.end) { - this.updateSymbol(symbol, SymbolOptions(geometry: latLng)).then(( - value) { - if (symbol != null) { - onSymbolDragged(eventArg); - } - }); - } - else - onSymbolDragged(eventArg); - - }); - MapboxGlPlatform.getInstance(_id).onLineTappedPlatform.add((lineId) { final Line line = _lines[lineId]; if (line != null) { @@ -243,9 +197,6 @@ class MapboxMapController extends ChangeNotifier { /// Callbacks to receive tap events for symbols placed on this map. final ArgumentCallbacks onSymbolTapped = ArgumentCallbacks(); - /// Callbacks to receive tap events for symbols dragged on this map. - final ArgumentCallbacks onSymbolDragged = ArgumentCallbacks(); - /// Callbacks to receive tap events for symbols placed on this map. final ArgumentCallbacks onCircleTapped = ArgumentCallbacks(); 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 f312b16e8..85b93307b 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 @@ -28,9 +28,6 @@ abstract class MapboxGlPlatform { final ArgumentCallbacks onSymbolTappedPlatform = ArgumentCallbacks(); - final ArgumentCallbacks> onSymbolDraggedPlatform = - ArgumentCallbacks>(); - final ArgumentCallbacks onLineTappedPlatform = ArgumentCallbacks(); 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 963201fbc..0f5e02873 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 @@ -78,33 +78,6 @@ class MethodChannelMapboxGl extends MapboxGlPlatform { case 'map#onIdle': onMapIdlePlatform(null); break; - case 'map#onAnnotationDragFinished': - final double lng = call.arguments['lng']; - final double lat = call.arguments['lat']; - final String symbol = call.arguments['symbol']; - onSymbolDraggedPlatform( - {'latLng': LatLng(lat, lng), 'symbol' : symbol, 'type': "end"}); - - break; - - case 'map#onAnnotationDrag': - final double lng = call.arguments['lng']; - final double lat = call.arguments['lat']; - final String symbol = call.arguments['symbol']; - onSymbolDraggedPlatform( - {'latLng': LatLng(lat, lng), 'symbol' : symbol,'type': "drag"}); - - break; - - case 'map#onAnnotationDragStarted': - final double lng = call.arguments['lng']; - final double lat = call.arguments['lat']; - final String symbol = call.arguments['symbol']; - onSymbolDraggedPlatform( - {'latLng': LatLng(lat, lng), 'symbol' : symbol,'type':"start"}); - - break; - case 'map#onUserLocationUpdated': final dynamic userLocation = call.arguments['userLocation']; final dynamic heading = call.arguments['heading']; diff --git a/mapbox_gl_web/pubspec.yaml b/mapbox_gl_web/pubspec.yaml index 1cbfefe67..e8991ed2c 100644 --- a/mapbox_gl_web/pubspec.yaml +++ b/mapbox_gl_web/pubspec.yaml @@ -17,7 +17,9 @@ dependencies: sdk: flutter meta: ^1.1.7 mapbox_gl_platform_interface: - path: ../mapbox_gl_platform_interface + git: + url: https://github.com/tobrun/flutter-mapbox-gl.git + path: mapbox_gl_platform_interface mapbox_gl_dart: ^0.1.5 image: ^2.1.12 diff --git a/pubspec.yaml b/pubspec.yaml index 843ebb339..5f23bbf8a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -7,9 +7,13 @@ dependencies: flutter: sdk: flutter mapbox_gl_platform_interface: - path: mapbox_gl_platform_interface + git: + url: https://github.com/tobrun/flutter-mapbox-gl.git + path: mapbox_gl_platform_interface mapbox_gl_web: - path: mapbox_gl_web + git: + url: https://github.com/tobrun/flutter-mapbox-gl.git + path: mapbox_gl_web flutter: plugin: