Skip to content

Commit

Permalink
correct default value
Browse files Browse the repository at this point in the history
  • Loading branch information
tobrun committed Feb 24, 2019
1 parent fee1109 commit d5a664c
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 13 deletions.
13 changes: 12 additions & 1 deletion android/src/main/java/com/mapbox/mapboxgl/Convert.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
import com.mapbox.mapboxsdk.log.Logger;
import com.mapbox.mapboxsdk.maps.MapboxMap;

import java.util.Arrays;
Expand All @@ -25,7 +26,7 @@
*/
class Convert {

private final static String TAG = "tvn";
private final static String TAG = "Convert";

// private static BitmapDescriptor toBitmapDescriptor(Object o) {
// final List<?> data = toList(o);
Expand Down Expand Up @@ -236,26 +237,32 @@ static void interpretSymbolOptions(Object o, SymbolOptionsSink sink) {
final Map<?, ?> data = toMap(o);
final Object iconSize = data.get("iconSize");
if (iconSize != null) {
Logger.e(TAG, "setIconSize" + iconSize);
sink.setIconSize(toFloat(iconSize));
}
final Object iconImage = data.get("iconImage");
if (iconImage != null) {
Logger.e(TAG, "setIconImage" + iconImage);
sink.setIconImage(toString(iconImage));
}
final Object iconRotate = data.get("iconRotate");
if (iconRotate != null) {
Logger.e(TAG, "SetIconRotate" + iconRotate);
sink.setIconRotate(toFloat(iconRotate));
}
final Object iconOffset = data.get("iconOffset");
if (iconOffset != null) {
Logger.e(TAG, "SetIconOffset" + iconOffset);
sink.setIconOffset(new float[] {toFloat(toList(iconOffset).get(0)), toFloat(toList(iconOffset).get(1))});
}
final Object iconAnchor = data.get("iconAnchor");
if (iconAnchor != null) {
Logger.e(TAG, "SetIconAnchor" + iconAnchor);
sink.setIconAnchor(toString(iconAnchor));
}
final Object textField = data.get("textField");
if (textField != null) {
Logger.e(TAG, "SetTextField" + textField);
sink.setTextField(toString(textField));
}
final Object textSize = data.get("textSize");
Expand Down Expand Up @@ -292,6 +299,7 @@ static void interpretSymbolOptions(Object o, SymbolOptionsSink sink) {
}
final Object iconOpacity = data.get("iconOpacity");
if (iconOpacity != null) {
Logger.e(TAG, "SetIconOpactiy" + iconOpacity);
sink.setIconOpacity(toFloat(iconOpacity));
}
final Object iconColor = data.get("iconColor");
Expand Down Expand Up @@ -332,14 +340,17 @@ static void interpretSymbolOptions(Object o, SymbolOptionsSink sink) {
}
final Object geometry = data.get("geometry");
if (geometry != null) {
Logger.e(TAG, "SetGeometry");
sink.setGeometry(toLatLng(geometry));
}
final Object zIndex = data.get("zIndex");
if (zIndex != null) {
Logger.e(TAG, "SetZIndex");
sink.setZIndex(toInt(zIndex));
}
final Object draggable = data.get("draggable");
if (draggable != null) {
Logger.e(TAG, "SetDraggable");
sink.setDraggable(toBoolean(draggable));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,8 @@ private SymbolBuilder newSymbolBuilder() {
}

private void removeSymbol(String symbolId) {
Log.v("FLTTR", "REMOVE SYMBOLID");
final SymbolController symbolController = symbols.remove(symbolId);
if (symbolController != null) {
Log.v("FLTTR", "REMOVE SYMBOLID2");
symbolController.remove(symbolManager);
}
}
Expand Down
41 changes: 35 additions & 6 deletions example/lib/place_symbol.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,40 +104,69 @@ class PlaceSymbolBodyState extends State<PlaceSymbolBody> {
}

void _changeAnchor() {
final Offset currentAnchor = _selectedSymbol.options.iconOffset;
Offset currentAnchor = _selectedSymbol.options.iconOffset;
if (currentAnchor == null) {
// default value
currentAnchor = Offset(0.0, 0.0);
}
final Offset newAnchor = Offset(1.0 - currentAnchor.dy, currentAnchor.dx);
_updateSelectedSymbol(SymbolOptions(iconOffset: newAnchor));
}

Future<void> _toggleDraggable() async {
_updateSelectedSymbol(
SymbolOptions(draggable: !_selectedSymbol.options.draggable),
bool draggable = _selectedSymbol.options.draggable;
if (draggable == null) {
// default value
draggable = false;
}

_updateSelectedSymbol(
SymbolOptions(draggable: !draggable),
);
}

Future<void> _changeAlpha() async {
final double current = _selectedSymbol.options.iconOpacity;
double current = _selectedSymbol.options.iconOpacity;
if (current == null) {
// default value
current = 1.0;
}

_updateSelectedSymbol(
SymbolOptions(iconOpacity: current < 0.1 ? 1.0 : current * 0.75),
);
}

Future<void> _changeRotation() async {
double current = _selectedSymbol.options.iconRotate;
if (current == null) {
// default value
current = 0;
}
_updateSelectedSymbol(
SymbolOptions(iconRotate: current == 330.0 ? 0.0 : current + 30.0),
);
}

Future<void> _toggleVisible() async {
double current = _selectedSymbol.options.iconOpacity;
if (current == null) {
// default value
current = 1.0;
}

_updateSelectedSymbol(
SymbolOptions(
iconOpacity: _selectedSymbol.options.iconOpacity == 0.0 ? 0.0 : 1.0),
iconOpacity: current == 0.0 ? 1.0 : 0.0),
);
}

Future<void> _changeZIndex() async {
final int current = _selectedSymbol.options.zIndex;
int current = _selectedSymbol.options.zIndex;
if (current == null) {
// default value
current = 0;
}
_updateSelectedSymbol(
SymbolOptions(zIndex: current == 12 ? 0 : current + 1),
);
Expand Down
8 changes: 4 additions & 4 deletions lib/src/symbol.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ class SymbolOptions {
const SymbolOptions({
this.iconSize,
this.iconImage,
this.iconRotate = 0,
this.iconOffset = const Offset(0,0),
this.iconRotate,
this.iconOffset,
this.iconAnchor,
this.textField,
this.textSize,
Expand All @@ -57,8 +57,8 @@ class SymbolOptions {
this.textAnchor,
this.textRotate,
this.textTransform,
this.textOffset = const Offset(0, 0),
this.iconOpacity = 1.0,
this.textOffset,
this.iconOpacity,
this.iconColor,
this.iconHaloColor,
this.iconHaloWidth,
Expand Down

0 comments on commit d5a664c

Please sign in to comment.