Skip to content

Commit

Permalink
add option to have no annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
felix-ht committed Dec 16, 2021
1 parent 8c904f4 commit f50097a
Show file tree
Hide file tree
Showing 5 changed files with 162 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
class MapboxMapBuilder implements MapboxMapOptionsSink {
public final String TAG = getClass().getSimpleName();
private final MapboxMapOptions options = new MapboxMapOptions()
.textureMode(true)
.attributionEnabled(true);
private boolean trackCameraPosition = false;
private boolean myLocationEnabled = false;
Expand Down
105 changes: 105 additions & 0 deletions android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,11 @@ private Feature firstFeatureOnLayers(RectF in) {

@Override
public void onMethodCall(MethodCall call, MethodChannel.Result result) {
String annotationManagerNotCreatedErrorCode = "NO ANNOTATION MANAGER";
String annotationManagerNotCreatedErrorMessage = "To use %ss please add it to the annotation list";



switch (call.method) {
case "map#waitForMap":
if (mapboxMap != null) {
Expand Down Expand Up @@ -756,6 +761,10 @@ public void onError(@NonNull String message) {
break;
}
case "symbols#addAll": {
if(symbolManager == null){
result.error(annotationManagerNotCreatedErrorCode, String.format(annotationManagerNotCreatedErrorCode, "symbol"), null);
return;
}
List<String> newSymbolIds = new ArrayList<String>();
final List<Object> options = call.argument("options");
List<SymbolOptions> symbolOptionsList = new ArrayList<SymbolOptions>();
Expand All @@ -780,6 +789,10 @@ public void onError(@NonNull String message) {
break;
}
case "symbols#removeAll": {
if(symbolManager == null){
result.error(annotationManagerNotCreatedErrorCode, String.format(annotationManagerNotCreatedErrorCode, "symbol"), null);
return;
}
final ArrayList<String> symbolIds = call.argument("ids");
SymbolController symbolController;

Expand All @@ -797,6 +810,10 @@ public void onError(@NonNull String message) {
break;
}
case "symbol#update": {
if(symbolManager == null){
result.error(annotationManagerNotCreatedErrorCode, String.format(annotationManagerNotCreatedErrorCode, "symbol"), null);
return;
}
final String symbolId = call.argument("symbol");
final SymbolController symbol = symbol(symbolId);
Convert.interpretSymbolOptions(call.argument("options"), symbol);
Expand All @@ -805,6 +822,10 @@ public void onError(@NonNull String message) {
break;
}
case "symbol#getGeometry": {
if(symbolManager == null){
result.error(annotationManagerNotCreatedErrorCode, String.format(annotationManagerNotCreatedErrorCode, "symbol"), null);
return;
}
final String symbolId = call.argument("symbol");
final SymbolController symbol = symbol(symbolId);
final LatLng symbolLatLng = symbol.getGeometry();
Expand All @@ -814,30 +835,50 @@ public void onError(@NonNull String message) {
result.success(hashMapLatLng);
}
case "symbolManager#iconAllowOverlap": {
if(symbolManager == null){
result.error(annotationManagerNotCreatedErrorCode, String.format(annotationManagerNotCreatedErrorCode, "symbol"), null);
return;
}
final Boolean value = call.argument("iconAllowOverlap");
symbolManager.setIconAllowOverlap(value);
result.success(null);
break;
}
case "symbolManager#iconIgnorePlacement": {
if(symbolManager == null){
result.error(annotationManagerNotCreatedErrorCode, String.format(annotationManagerNotCreatedErrorCode, "symbol"), null);
return;
}
final Boolean value = call.argument("iconIgnorePlacement");
symbolManager.setIconIgnorePlacement(value);
result.success(null);
break;
}
case "symbolManager#textAllowOverlap": {
if(symbolManager == null){
result.error(annotationManagerNotCreatedErrorCode, String.format(annotationManagerNotCreatedErrorCode, "symbol"), null);
return;
}
final Boolean value = call.argument("textAllowOverlap");
symbolManager.setTextAllowOverlap(value);
result.success(null);
break;
}
case "symbolManager#textIgnorePlacement": {
if(symbolManager == null){
result.error(annotationManagerNotCreatedErrorCode, String.format(annotationManagerNotCreatedErrorCode, "symbol"), null);
return;
}
final Boolean iconAllowOverlap = call.argument("textIgnorePlacement");
symbolManager.setTextIgnorePlacement(iconAllowOverlap);
result.success(null);
break;
}
case "line#add": {
if(lineManager == null){
result.error(annotationManagerNotCreatedErrorCode, String.format(annotationManagerNotCreatedErrorCode, "line"), null);
return;
}
final LineBuilder lineBuilder = newLineBuilder();
Convert.interpretLineOptions(call.argument("options"), lineBuilder);
final Line line = lineBuilder.build();
Expand All @@ -847,12 +888,20 @@ public void onError(@NonNull String message) {
break;
}
case "line#remove": {
if(lineManager == null){
result.error(annotationManagerNotCreatedErrorCode, String.format(annotationManagerNotCreatedErrorCode, "line"), null);
return;
}
final String lineId = call.argument("line");
removeLine(lineId);
result.success(null);
break;
}
case "line#addAll": {
if(lineManager == null){
result.error(annotationManagerNotCreatedErrorCode, String.format(annotationManagerNotCreatedErrorCode, "line"), null);
return;
}
List<String> newIds = new ArrayList<String>();
final List<Object> options = call.argument("options");
List<LineOptions> optionList = new ArrayList<LineOptions>();
Expand All @@ -877,6 +926,10 @@ public void onError(@NonNull String message) {
break;
}
case "line#removeAll": {
if(lineManager == null){
result.error(annotationManagerNotCreatedErrorCode, String.format(annotationManagerNotCreatedErrorCode, "line"), null);
return;
}
final ArrayList<String> ids = call.argument("ids");
LineController lineController;

Expand All @@ -894,6 +947,10 @@ public void onError(@NonNull String message) {
break;
}
case "line#update": {
if(lineManager == null){
result.error(annotationManagerNotCreatedErrorCode, String.format(annotationManagerNotCreatedErrorCode, "line"), null);
return;
}
final String lineId = call.argument("line");
final LineController line = line(lineId);
Convert.interpretLineOptions(call.argument("options"), line);
Expand All @@ -902,6 +959,10 @@ public void onError(@NonNull String message) {
break;
}
case "line#getGeometry": {
if(lineManager == null){
result.error(annotationManagerNotCreatedErrorCode, String.format(annotationManagerNotCreatedErrorCode, "line"), null);
return;
}
final String lineId = call.argument("line");
final LineController line = line(lineId);
final List<LatLng> lineLatLngs = line.getGeometry();
Expand All @@ -916,6 +977,10 @@ public void onError(@NonNull String message) {
break;
}
case "circle#add": {
if(circleManager == null){
result.error(annotationManagerNotCreatedErrorCode, String.format(annotationManagerNotCreatedErrorCode, "circle"), null);
return;
}
final CircleBuilder circleBuilder = newCircleBuilder();
Convert.interpretCircleOptions(call.argument("options"), circleBuilder);
final Circle circle = circleBuilder.build();
Expand All @@ -925,6 +990,10 @@ public void onError(@NonNull String message) {
break;
}
case "circle#addAll": {
if(circleManager == null){
result.error(annotationManagerNotCreatedErrorCode, String.format(annotationManagerNotCreatedErrorCode, "circle"), null);
return;
}
List<String> newIds = new ArrayList<String>();
final List<Object> options = call.argument("options");
List<CircleOptions> optionList = new ArrayList<CircleOptions>();
Expand All @@ -949,6 +1018,10 @@ public void onError(@NonNull String message) {
break;
}
case "circle#removeAll": {
if(circleManager == null){
result.error(annotationManagerNotCreatedErrorCode, String.format(annotationManagerNotCreatedErrorCode, "circle"), null);
return;
}
final ArrayList<String> ids = call.argument("ids");
CircleController circleController;

Expand All @@ -966,12 +1039,20 @@ public void onError(@NonNull String message) {
break;
}
case "circle#remove": {
if(circleManager == null){
result.error(annotationManagerNotCreatedErrorCode, String.format(annotationManagerNotCreatedErrorCode, "circle"), null);
return;
}
final String circleId = call.argument("circle");
removeCircle(circleId);
result.success(null);
break;
}
case "circle#update": {
if(circleManager == null){
result.error(annotationManagerNotCreatedErrorCode, String.format(annotationManagerNotCreatedErrorCode, "circle"), null);
return;
}
Log.e(TAG, "update circle");
final String circleId = call.argument("circle");
final CircleController circle = circle(circleId);
Expand All @@ -981,6 +1062,10 @@ public void onError(@NonNull String message) {
break;
}
case "circle#getGeometry": {
if(circleManager == null){
result.error(annotationManagerNotCreatedErrorCode, String.format(annotationManagerNotCreatedErrorCode, "circle"), null);
return;
}
final String circleId = call.argument("circle");
final CircleController circle = circle(circleId);
final LatLng circleLatLng = circle.getGeometry();
Expand All @@ -991,6 +1076,10 @@ public void onError(@NonNull String message) {
break;
}
case "fill#add": {
if(fillManager == null){
result.error(annotationManagerNotCreatedErrorCode, String.format(annotationManagerNotCreatedErrorCode, "fill"), null);
return;
}
final FillBuilder fillBuilder = newFillBuilder();
Convert.interpretFillOptions(call.argument("options"), fillBuilder);
final Fill fill = fillBuilder.build();
Expand All @@ -1001,6 +1090,10 @@ public void onError(@NonNull String message) {
}

case "fill#addAll": {
if(fillManager == null){
result.error(annotationManagerNotCreatedErrorCode, String.format(annotationManagerNotCreatedErrorCode, "fill"), null);
return;
}
List<String> newIds = new ArrayList<String>();
final List<Object> options = call.argument("options");
List<FillOptions> optionList = new ArrayList<FillOptions>();
Expand All @@ -1025,6 +1118,10 @@ public void onError(@NonNull String message) {
break;
}
case "fill#removeAll": {
if(fillManager == null){
result.error(annotationManagerNotCreatedErrorCode, String.format(annotationManagerNotCreatedErrorCode, "fill"), null);
return;
}
final ArrayList<String> ids = call.argument("ids");
FillController fillController;

Expand All @@ -1042,12 +1139,20 @@ public void onError(@NonNull String message) {
break;
}
case "fill#remove": {
if(fillManager == null){
result.error(annotationManagerNotCreatedErrorCode, String.format(annotationManagerNotCreatedErrorCode, "fill"), null);
return;
}
final String fillId = call.argument("fill");
removeFill(fillId);
result.success(null);
break;
}
case "fill#update": {
if(fillManager == null){
result.error(annotationManagerNotCreatedErrorCode, String.format(annotationManagerNotCreatedErrorCode, "fill"), null);
return;
}
final String fillId = call.argument("fill");
final FillController fill = fill(fillId);
Convert.interpretFillOptions(call.argument("options"), fill);
Expand Down
21 changes: 12 additions & 9 deletions example/lib/layer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,18 @@ class LayerState extends State {

@override
Widget build(BuildContext context) {
return MapboxMap(
accessToken: MapsDemo.ACCESS_TOKEN,
onMapCreated: _onMapCreated,
onMapClick: (point, latLong) =>
print(point.toString() + latLong.toString()),
onStyleLoadedCallback: _onStyleLoadedCallback,
initialCameraPosition: CameraPosition(
target: center,
zoom: 11.0,
return Container(
child: MapboxMap(
accessToken: MapsDemo.ACCESS_TOKEN,
onMapCreated: _onMapCreated,
onMapClick: (point, latLong) =>
print(point.toString() + latLong.toString()),
onStyleLoadedCallback: _onStyleLoadedCallback,
initialCameraPosition: CameraPosition(
target: center,
zoom: 11.0,
),
annotationOrder: const [],
),
);
}
Expand Down
Loading

0 comments on commit f50097a

Please sign in to comment.