Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add symbol API #25

Merged
merged 1 commit into from
Mar 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions android/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@
.DS_Store
/build
/captures
gradlew
gradlew.bat
9 changes: 7 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ rootProject.allprojects {
apply plugin: 'com.android.library'

android {
compileSdkVersion 27
compileSdkVersion 28

defaultConfig {
minSdkVersion 16
Expand All @@ -37,6 +37,11 @@ android {
targetCompatibility JavaVersion.VERSION_1_8
}
dependencies {
implementation "com.mapbox.mapboxsdk:mapbox-android-sdk:7.1.1"
implementation "com.mapbox.mapboxsdk:mapbox-android-sdk:7.1.2"
implementation "com.mapbox.mapboxsdk:mapbox-android-plugin-annotation-v7:0.5.0"
}
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}
189 changes: 132 additions & 57 deletions android/src/main/java/com/mapbox/mapboxgl/Convert.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,28 @@

import android.graphics.Point;

import android.util.Log;

import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.camera.CameraUpdate;
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;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/** Conversions between JSON-like values and MapboxMaps data types. */
/**
* Conversions between JSON-like values and MapboxMaps data types.
*/
class Convert {

private final static String TAG = "Convert";

// private static BitmapDescriptor toBitmapDescriptor(Object o) {
// final List<?> data = toList(o);
// switch (toString(data.get(0))) {
Expand Down Expand Up @@ -56,7 +64,7 @@ static CameraPosition toCameraPosition(Object o) {
return builder.build();
}

static boolean isScrollByCameraUpdate(Object o){
static boolean isScrollByCameraUpdate(Object o) {
return toString(toList(o).get(0)).equals("scrollBy");
}

Expand Down Expand Up @@ -141,7 +149,7 @@ private static LatLngBounds toLatLngBounds(Object o) {
return null;
}
final List<?> data = toList(o);
LatLng[] boundsArray = new LatLng[]{toLatLng(data.get(0)), toLatLng(data.get(1))};
LatLng[] boundsArray = new LatLng[] {toLatLng(data.get(0)), toLatLng(data.get(1))};
List<LatLng> bounds = Arrays.asList(boundsArray);
LatLngBounds.Builder builder = new LatLngBounds.Builder();
builder.includes(bounds);
Expand Down Expand Up @@ -229,58 +237,125 @@ static void interpretMapboxMapOptions(Object o, MapboxMapOptionsSink sink) {
}
}

// static void interpretMarkerOptions(Object o, MarkerOptionsSink sink) {
// final Map<?, ?> data = toMap(o);
// final Object alpha = data.get("alpha");
// if (alpha != null) {
// sink.setAlpha(toFloat(alpha));
// }
// final Object anchor = data.get("anchor");
// if (anchor != null) {
// final List<?> anchorData = toList(anchor);
// sink.setAnchor(toFloat(anchorData.get(0)), toFloat(anchorData.get(1)));
// }
// final Object consumesTapEvents = data.get("consumesTapEvents");
// if (consumesTapEvents != null) {
// sink.setConsumeTapEvents(toBoolean(consumesTapEvents));
// }
// final Object draggable = data.get("draggable");
// if (draggable != null) {
// sink.setDraggable(toBoolean(draggable));
// }
// final Object flat = data.get("flat");
// if (flat != null) {
// sink.setFlat(toBoolean(flat));
// }
// final Object icon = data.get("icon");
// if (icon != null) {
// sink.setIcon(toBitmapDescriptor(icon));
// }
// final Object infoWindowAnchor = data.get("infoWindowAnchor");
// if (infoWindowAnchor != null) {
// final List<?> anchorData = toList(infoWindowAnchor);
// sink.setInfoWindowAnchor(toFloat(anchorData.get(0)), toFloat(anchorData.get(1)));
// }
// final Object infoWindowText = data.get("infoWindowText");
// if (infoWindowText != null) {
// final List<?> textData = toList(infoWindowText);
// sink.setInfoWindowText(toString(textData.get(0)), toString(textData.get(1)));
// }
// final Object position = data.get("position");
// if (position != null) {
// sink.setPosition(toLatLng(position));
// }
// final Object rotation = data.get("rotation");
// if (rotation != null) {
// sink.setRotation(toFloat(rotation));
// }
// final Object visible = data.get("visible");
// if (visible != null) {
// sink.setVisible(toBoolean(visible));
// }
// final Object zIndex = data.get("zIndex");
// if (zIndex != null) {
// sink.setZIndex(toFloat(zIndex));
// }
// }
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");
if (textSize != null) {
sink.setTextSize(toFloat(textSize));
}
final Object textMaxWidth = data.get("textMaxWidth");
if (textMaxWidth != null) {
sink.setTextMaxWidth(toFloat(textMaxWidth));
}
final Object textLetterSpacing = data.get("textLetterSpacing");
if (textLetterSpacing != null) {
sink.setTextLetterSpacing(toFloat(textLetterSpacing));
}
final Object textJustify = data.get("textJustify");
if (textJustify != null) {
sink.setTextJustify(toString(textJustify));
}
final Object textAnchor = data.get("textAnchor");
if (textAnchor != null) {
sink.setTextAnchor(toString(textAnchor));
}
final Object textRotate = data.get("textRotate");
if (textRotate != null) {
sink.setTextRotate(toFloat(textRotate));
}
final Object textTransform = data.get("textTransform");
if (textTransform != null) {
sink.setTextTransform(toString(textTransform));
}
final Object textOffset = data.get("textOffset");
if (textOffset != null) {
sink.setTextOffset(new float[] {toFloat(toList(textOffset).get(0)), toFloat(toList(textOffset).get(1))});
}
final Object iconOpacity = data.get("iconOpacity");
if (iconOpacity != null) {
Logger.e(TAG, "SetIconOpactiy" + iconOpacity);
sink.setIconOpacity(toFloat(iconOpacity));
}
final Object iconColor = data.get("iconColor");
if (iconColor != null) {
sink.setIconColor(toString(iconColor));
}
final Object iconHaloColor = data.get("iconHaloColor");
if (iconHaloColor != null) {
sink.setIconHaloColor(toString(iconHaloColor));
}
final Object iconHaloWidth = data.get("iconHaloWidth");
if (iconHaloWidth != null) {
sink.setIconHaloWidth(toFloat(iconHaloWidth));
}
final Object iconHaloBlur = data.get("iconHaloBlur");
if (iconHaloBlur != null) {
sink.setIconHaloBlur(toFloat(iconHaloBlur));
}
final Object textOpacity = data.get("textOpacity");
if (textOpacity != null) {
sink.setTextOpacity(toFloat(textOpacity));
}
final Object textColor = data.get("textColor");
if (textColor != null) {
sink.setTextColor(toString(textColor));
}
final Object textHaloColor = data.get("textHaloColor");
if (textHaloColor != null) {
sink.setTextHaloColor(toString(textHaloColor));
}
final Object textHaloWidth = data.get("textHaloWidth");
if (textHaloWidth != null) {
sink.setTextHaloWidth(toFloat(textHaloWidth));
}
final Object textHaloBlur = data.get("textHaloBlur");
if (textHaloBlur != null) {
sink.setTextHaloBlur(toFloat(textHaloBlur));
}
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));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.mapbox.mapboxsdk.maps.Style;

import io.flutter.plugin.common.PluginRegistry;

import java.util.concurrent.atomic.AtomicInteger;


Expand All @@ -27,9 +28,9 @@ class MapboxMapBuilder implements MapboxMapOptionsSink {
private String styleString = Style.MAPBOX_STREETS;

MapboxMapController build(
int id, Context context, AtomicInteger state, PluginRegistry.Registrar registrar) {
int id, Context context, AtomicInteger state, PluginRegistry.Registrar registrar) {
final MapboxMapController controller =
new MapboxMapController(id, context, state, registrar, options, styleString);
new MapboxMapController(id, context, state, registrar, options, styleString);
controller.init();
controller.setMyLocationEnabled(myLocationEnabled);
controller.setMyLocationTrackingMode(myLocationTrackingMode);
Expand All @@ -48,7 +49,7 @@ public void setCompassEnabled(boolean compassEnabled) {

@Override
public void setCameraTargetBounds(LatLngBounds bounds) {
Log.e(TAG,"setCameraTargetBounds is supported only after map initiated.");
Log.e(TAG, "setCameraTargetBounds is supported only after map initiated.");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not implemented yet.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes correct, delete for now?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should keep it, but I though you may think differently and wanted to point it out.

//throw new UnsupportedOperationException("setCameraTargetBounds is supported only after map initiated.");
//options.latLngBoundsForCameraTarget(bounds);
}
Expand Down Expand Up @@ -103,5 +104,5 @@ public void setMyLocationEnabled(boolean myLocationEnabled) {
public void setMyLocationTrackingMode(int myLocationTrackingMode) {
this.myLocationTrackingMode = myLocationTrackingMode;
}

}
Loading