Skip to content

Commit

Permalink
Revert "Symbol drag listener fix for flutter-mapbox-gl#339"
Browse files Browse the repository at this point in the history
This reverts commit 94f77a0
  • Loading branch information
GULERTOLGA committed May 12, 2021
1 parent 94f77a0 commit 4d0c74c
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 232 deletions.
35 changes: 0 additions & 35 deletions android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<String, Object> 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<String, Object> 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<String, Object> 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);

}
});
}
}

Expand Down
2 changes: 0 additions & 2 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -39,7 +38,6 @@ final List<ExamplePage> _allPages = <ExamplePage>[
OfflineRegionsPage(),
AnnotationOrderPage(),
CustomMarkerPage(),
SymbolDragPage(),
];

class MapsDemo extends StatelessWidget {
Expand Down
113 changes: 0 additions & 113 deletions example/lib/symbol_drag.dart

This file was deleted.

49 changes: 0 additions & 49 deletions lib/src/controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -243,9 +197,6 @@ class MapboxMapController extends ChangeNotifier {
/// Callbacks to receive tap events for symbols placed on this map.
final ArgumentCallbacks<Symbol> onSymbolTapped = ArgumentCallbacks<Symbol>();

/// Callbacks to receive tap events for symbols dragged on this map.
final ArgumentCallbacks<SymbolDragEventArgs> onSymbolDragged = ArgumentCallbacks<SymbolDragEventArgs>();

/// Callbacks to receive tap events for symbols placed on this map.
final ArgumentCallbacks<Circle> onCircleTapped = ArgumentCallbacks<Circle>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ abstract class MapboxGlPlatform {
final ArgumentCallbacks<String> onSymbolTappedPlatform =
ArgumentCallbacks<String>();

final ArgumentCallbacks<Map<String, dynamic>> onSymbolDraggedPlatform =
ArgumentCallbacks<Map<String, dynamic>>();

final ArgumentCallbacks<String> onLineTappedPlatform =
ArgumentCallbacks<String>();

Expand Down
27 changes: 0 additions & 27 deletions mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down
4 changes: 3 additions & 1 deletion mapbox_gl_web/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 6 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 4d0c74c

Please sign in to comment.