Skip to content

Commit ae8afa1

Browse files
authored
fix add icon/text allow overlap (#303)
1 parent e0dffc9 commit ae8afa1

4 files changed

Lines changed: 114 additions & 28 deletions

File tree

lib/src/controller.dart

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -371,34 +371,6 @@ class MapboxMapController extends ChangeNotifier {
371371
_symbols.remove(id);
372372
}
373373

374-
/// For more information on what this does, see https://docs.mapbox.com/help/troubleshooting/optimize-map-label-placement/#label-collision
375-
Future<void> setSymbolIconAllowOverlap(bool enable) async {
376-
await _channel.invokeMethod('symbolManager#iconAllowOverlap', <String, dynamic>{
377-
'iconAllowOverlap': enable,
378-
});
379-
}
380-
381-
/// For more information on what this does, see https://docs.mapbox.com/help/troubleshooting/optimize-map-label-placement/#label-collision
382-
Future<void> setSymbolIconIgnorePlacement(bool enable) async {
383-
await _channel.invokeMethod('symbolManager#iconIgnorePlacement', <String, dynamic>{
384-
'iconIgnorePlacement': enable,
385-
});
386-
}
387-
388-
/// For more information on what this does, see https://docs.mapbox.com/help/troubleshooting/optimize-map-label-placement/#label-collision
389-
Future<void> setSymbolTextAllowOverlap(bool enable) async {
390-
await _channel.invokeMethod('symbolManager#textAllowOverlap', <String, dynamic>{
391-
'textAllowOverlap': enable,
392-
});
393-
}
394-
395-
/// For more information on what this does, see https://docs.mapbox.com/help/troubleshooting/optimize-map-label-placement/#label-collision
396-
Future<void> setSymbolTextIgnorePlacement(bool enable) async {
397-
await _channel.invokeMethod('symbolManager#textIgnorePlacement', <String, dynamic>{
398-
'textIgnorePlacement': enable,
399-
});
400-
}
401-
402374
/// Adds a line to the map, configured using the specified custom [options].
403375
///
404376
/// Change listeners are notified once the line has been added on the
@@ -620,4 +592,24 @@ class MapboxMapController extends ChangeNotifier {
620592
Future<void> addImage(String name, Uint8List bytes, [bool sdf = false]) {
621593
return MapboxGlPlatform.instance.addImage(name, bytes, sdf);
622594
}
595+
596+
/// For more information on what this does, see https://docs.mapbox.com/help/troubleshooting/optimize-map-label-placement/#label-collision
597+
Future<void> setSymbolIconAllowOverlap(bool enable) async {
598+
await MapboxGlPlatform.instance.setSymbolIconAllowOverlap(enable);
599+
}
600+
601+
/// For more information on what this does, see https://docs.mapbox.com/help/troubleshooting/optimize-map-label-placement/#label-collision
602+
Future<void> setSymbolIconIgnorePlacement(bool enable) async {
603+
await MapboxGlPlatform.instance.setSymbolIconIgnorePlacement(enable);
604+
}
605+
606+
/// For more information on what this does, see https://docs.mapbox.com/help/troubleshooting/optimize-map-label-placement/#label-collision
607+
Future<void> setSymbolTextAllowOverlap(bool enable) async {
608+
await MapboxGlPlatform.instance.setSymbolTextAllowOverlap(enable);
609+
}
610+
611+
/// For more information on what this does, see https://docs.mapbox.com/help/troubleshooting/optimize-map-label-placement/#label-collision
612+
Future<void> setSymbolTextIgnorePlacement(bool enable) async {
613+
await MapboxGlPlatform.instance.setSymbolTextIgnorePlacement(enable);
614+
}
623615
}

mapbox_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,4 +176,24 @@ abstract class MapboxGlPlatform {
176176
[bool sdf = false]) async {
177177
throw UnimplementedError('addImage() has not been implemented.');
178178
}
179+
180+
Future<void> setSymbolIconAllowOverlap(bool enable) async {
181+
throw UnimplementedError(
182+
'setSymbolIconAllowOverlap() has not been implemented.');
183+
}
184+
185+
Future<void> setSymbolIconIgnorePlacement(bool enable) async {
186+
throw UnimplementedError(
187+
'setSymbolIconIgnorePlacement() has not been implemented.');
188+
}
189+
190+
Future<void> setSymbolTextAllowOverlap(bool enable) async {
191+
throw UnimplementedError(
192+
'setSymbolTextAllowOverlap() has not been implemented.');
193+
}
194+
195+
Future<void> setSymbolTextIgnorePlacement(bool enable) async {
196+
throw UnimplementedError(
197+
'setSymbolTextIgnorePlacement() has not been implemented.');
198+
}
179199
}

mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ class MethodChannelMapboxGl extends MapboxGlPlatform {
356356
}
357357
}
358358

359+
@override
359360
Future<void> addImage(String name, Uint8List bytes,
360361
[bool sdf = false]) async {
361362
try {
@@ -369,4 +370,52 @@ class MethodChannelMapboxGl extends MapboxGlPlatform {
369370
return new Future.error(e);
370371
}
371372
}
373+
374+
@override
375+
Future<void> setSymbolIconAllowOverlap(bool enable) async {
376+
try {
377+
await _channel
378+
.invokeMethod('symbolManager#iconAllowOverlap', <String, dynamic>{
379+
'iconAllowOverlap': enable,
380+
});
381+
} on PlatformException catch (e) {
382+
return new Future.error(e);
383+
}
384+
}
385+
386+
@override
387+
Future<void> setSymbolIconIgnorePlacement(bool enable) async {
388+
try {
389+
await _channel
390+
.invokeMethod('symbolManager#iconIgnorePlacement', <String, dynamic>{
391+
'iconIgnorePlacement': enable,
392+
});
393+
} on PlatformException catch (e) {
394+
return new Future.error(e);
395+
}
396+
}
397+
398+
@override
399+
Future<void> setSymbolTextAllowOverlap(bool enable) async {
400+
try {
401+
await _channel
402+
.invokeMethod('symbolManager#textAllowOverlap', <String, dynamic>{
403+
'textAllowOverlap': enable,
404+
});
405+
} on PlatformException catch (e) {
406+
return new Future.error(e);
407+
}
408+
}
409+
410+
@override
411+
Future<void> setSymbolTextIgnorePlacement(bool enable) async {
412+
try {
413+
await _channel
414+
.invokeMethod('symbolManager#textIgnorePlacement', <String, dynamic>{
415+
'textIgnorePlacement': enable,
416+
});
417+
} on PlatformException catch (e) {
418+
return new Future.error(e);
419+
}
420+
}
372421
}

mapbox_gl_web/lib/src/mapbox_map_controller.dart

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ class MapboxMapController extends MapboxGlPlatform
259259
);
260260
}
261261

262+
@override
262263
Future<void> addImage(String name, Uint8List bytes,
263264
[bool sdf = false]) async {
264265
final photo = decodeImage(bytes);
@@ -275,6 +276,30 @@ class MapboxMapController extends MapboxGlPlatform
275276
}
276277
}
277278

279+
@override
280+
Future<void> setSymbolIconAllowOverlap(bool enable) async {
281+
//TODO: to implement
282+
print('setSymbolIconAllowOverlap not implemented yet');
283+
}
284+
285+
@override
286+
Future<void> setSymbolIconIgnorePlacement(bool enable) async {
287+
//TODO: to implement
288+
print('setSymbolIconIgnorePlacement not implemented yet');
289+
}
290+
291+
@override
292+
Future<void> setSymbolTextAllowOverlap(bool enable) async {
293+
//TODO: to implement
294+
print('setSymbolTextAllowOverlap not implemented yet');
295+
}
296+
297+
@override
298+
Future<void> setSymbolTextIgnorePlacement(bool enable) async {
299+
//TODO: to implement
300+
print('setSymbolTextIgnorePlacement not implemented yet');
301+
}
302+
278303
CameraPosition _getCameraPosition() {
279304
if (_trackCameraPosition) {
280305
final center = _map.getCenter();

0 commit comments

Comments
 (0)