Skip to content
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## 7.0.0

### removed:

* isTelemeryEnbaled from android [#1](https://github.com/mfazekas/maps/pull/1)

2 changes: 1 addition & 1 deletion android/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Include project, so gradle knows where to find the project

```
include ':mapbox-react-native-mapbox-gl'
project(':mapbox-react-native-mapbox-gl').projectDir = new File(rootProject.projectDir, '../node_modules/@mapbox/react-native-mapbox-gl/android/rctmgl')
project(':mapbox-react-native-mapbox-gl').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-mapbox/maps/android/rctmgl')
```

### MainApplication.java
Expand Down
9 changes: 5 additions & 4 deletions android/rctmgl/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ dependencies {
compileOnly "com.facebook.react:react-native:+"

// Mapbox SDK
implementation 'com.mapbox.mapboxsdk:mapbox-android-services:2.2.9'
implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:5.5.3@aar'

implementation 'com.mapbox.mapboxsdk:mapbox-sdk-services:4.6.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:7.3.0'

// Dependencies
implementation "com.android.support:support-vector-drawable:${safeExtGet('supportLibVersion', '28.0.0')}"
Expand All @@ -40,6 +41,6 @@ dependencies {
implementation "com.squareup.okhttp3:okhttp:${safeExtGet('okhttpVersion', '3.12.1')}"

// Mapbox plugins
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-localization:0.1.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-locationlayer:0.3.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-localization-v7:0.9.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-markerview-v7:0.2.0'
}
1 change: 0 additions & 1 deletion android/rctmgl/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.mapbox.rctmgl">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import com.mapbox.rctmgl.components.annotation.RCTMGLCalloutManager;
import com.mapbox.rctmgl.components.annotation.RCTMGLPointAnnotationManager;
import com.mapbox.rctmgl.components.camera.RCTMGLCameraManager;
import com.mapbox.rctmgl.components.mapview.RCTMGLMapViewManager;
import com.mapbox.rctmgl.components.mapview.RCTMGLAndroidTextureMapViewManager;
import com.mapbox.rctmgl.components.styles.layers.RCTMGLBackgroundLayerManager;
Expand All @@ -26,6 +27,7 @@
import com.mapbox.rctmgl.components.styles.sources.RCTMGLRasterSourceManager;
import com.mapbox.rctmgl.components.styles.sources.RCTMGLShapeSourceManager;
import com.mapbox.rctmgl.components.styles.sources.RCTMGLVectorSourceManager;
import com.mapbox.rctmgl.modules.RCTMGLLocationModule;
import com.mapbox.rctmgl.modules.RCTMGLModule;
import com.mapbox.rctmgl.modules.RCTMGLOfflineModule;
import com.mapbox.rctmgl.modules.RCTMGLSnapshotModule;
Expand All @@ -43,6 +45,7 @@ public List<NativeModule> createNativeModules(ReactApplicationContext reactAppli
modules.add(new RCTMGLModule(reactApplicationContext));
modules.add(new RCTMGLOfflineModule(reactApplicationContext));
modules.add(new RCTMGLSnapshotModule(reactApplicationContext));
modules.add(new RCTMGLLocationModule(reactApplicationContext));

return modules;
}
Expand All @@ -57,6 +60,7 @@ public List<ViewManager> createViewManagers(ReactApplicationContext reactApplica
List<ViewManager> managers = new ArrayList<>();

// components
managers.add(new RCTMGLCameraManager(reactApplicationContext));
managers.add(new RCTMGLMapViewManager(reactApplicationContext));
managers.add(new RCTMGLAndroidTextureMapViewManager(reactApplicationContext));
managers.add(new RCTMGLLightManager());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@

import android.view.ViewGroup;

import com.facebook.react.ReactApplication;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.common.MapBuilder;
import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.ViewGroupManager;
import com.facebook.react.uimanager.events.RCTEventEmitter;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Nullable;

import com.facebook.react.uimanager.events.EventDispatcher;
import com.mapbox.rctmgl.events.EventEmitter;
import com.mapbox.rctmgl.events.IEvent;

/**
Expand All @@ -24,9 +27,11 @@ abstract public class AbstractEventEmitter<T extends ViewGroup> extends ViewGrou
private static final double BRIDGE_TIMEOUT_MS = 10;
private Map<String, Long> mRateLimitedEvents;
private EventDispatcher mEventDispatcher;
private ReactApplicationContext mRCTAppContext;

public AbstractEventEmitter(ReactApplicationContext reactApplicationContext) {
mRateLimitedEvents = new HashMap<>();
mRCTAppContext = reactApplicationContext;
}

public void handleEvent(IEvent event) {
Expand All @@ -39,6 +44,11 @@ public void handleEvent(IEvent event) {

mRateLimitedEvents.put(eventCacheKey, System.currentTimeMillis());
mEventDispatcher.dispatchEvent(new AbstractEvent(event.getID(), event.getKey(), event.toJSON()));

RCTEventEmitter emitter = EventEmitter.getViewEmitter(mRCTAppContext);
if (emitter != null) {
emitter.receiveEvent(event.getID(), event.getKey(), event.toJSON());
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,17 @@
import android.view.MotionEvent;
import android.view.View;

import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.uimanager.UIManagerModule;
import com.mapbox.mapboxsdk.annotations.MarkerView;
import com.mapbox.geojson.Point;
import com.mapbox.mapboxsdk.annotations.Marker;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.plugins.markerview.MarkerView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.rctmgl.components.AbstractMapFeature;
import com.mapbox.rctmgl.components.mapview.RCTMGLMapView;
import com.mapbox.rctmgl.events.PointAnnotationClickEvent;
import com.mapbox.rctmgl.events.constants.EventTypes;
import com.mapbox.rctmgl.utils.GeoJSONUtils;
import com.mapbox.services.commons.geojson.Point;

import java.util.Arrays;
import java.util.List;
Expand All @@ -28,7 +26,7 @@

public class RCTMGLPointAnnotation extends AbstractMapFeature {
private RCTMGLPointAnnotationManager mManager;
private MarkerView mAnnotation;
private Marker mAnnotation;
private MapboxMap mMap;
private RCTMGLMapView mMapView;

Expand Down Expand Up @@ -141,7 +139,9 @@ public void setAnchor(float x, float y) {
mAnchor = Arrays.asList(x, y);

if (mAnnotation != null) {
mAnnotation.setAnchor(x, y);
mAnnotation.setRightOffsetPixels((int)x);
mAnnotation.setTopOffsetPixels((int)y);
/* FMTODO mAnnotation.setAnchor(x, y); */
}
}

Expand All @@ -157,7 +157,7 @@ public void setReactSelected(boolean isSelected) {
}
}

public MarkerView getMarker() {
public Marker getMarker() {
return mAnnotation;
}

Expand All @@ -179,7 +179,10 @@ public void makeMarker() {
mAnnotation = mMap.addMarker(buildOptions());

if (mAnchor != null && mAnchor.size() == 2) {
mAnnotation.setAnchor(mAnchor.get(0), mAnchor.get(1));

//mAnnotation.setAnchor(mAnchor.get(0), mAnchor.get(1));
mAnnotation.setRightOffsetPixels((int)mAnchor.get(0).floatValue());
mAnnotation.setTopOffsetPixels((int)mAnchor.get(1).floatValue());
}

final RCTMGLPointAnnotation self = this;
Expand All @@ -188,6 +191,7 @@ public void makeMarker() {
}
}


private RCTMGLPointAnnotationOptions buildOptions() {
RCTMGLPointAnnotationOptions options = new RCTMGLPointAnnotationOptions();
options.annotationID(mID);
Expand All @@ -212,6 +216,25 @@ private PointF getScreenPosition() {
return new PointF((float) loc[0], (float) loc[1]);
}

public static class CustomMarker extends Marker {
private String mAnnotationID;
private RCTMGLPointAnnotationOptions mOptions;

public CustomMarker(String annotationID, RCTMGLPointAnnotationOptions options) {
super(options);
mOptions = options;
mAnnotationID = annotationID;
}

public String getAnnotationID() {
return mAnnotationID;
}

public boolean isDefaultIcon() {
return !mOptions.getHasChildren();
}
}
/*
public static class CustomView extends MarkerView {
private String mAnnotationID;
private RCTMGLPointAnnotationOptions mOptions;
Expand All @@ -229,5 +252,5 @@ public String getAnnotationID() {
public boolean isDefaultIcon() {
return !mOptions.getHasChildren();
}
}
} */
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,20 @@
* Created by nickitaliano on 9/27/17.
*/

public class RCTMGLPointAnnotationAdapter extends MapboxMap.MarkerViewAdapter<RCTMGLPointAnnotation.CustomView> {
public class RCTMGLPointAnnotationAdapter /* extends MapboxMap.MarkerViewAdapter<RCTMGLPointAnnotation.CustomView> */ {
/*
private RCTMGLMapView mMapView;
private LayoutInflater mInflater;

public RCTMGLPointAnnotationAdapter(RCTMGLMapView mapView, Context context) {
super(context);
super(context, RCTMGLPointAnnotation.CustomMarker.class);
mMapView = mapView;
mInflater = LayoutInflater.from(context);
}

@Nullable
@Override
public View getView(@NonNull RCTMGLPointAnnotation.CustomView customAnnotationView, @Nullable View convertView, @NonNull ViewGroup parent) {
public View getView(@NonNull RCTMGLPointAnnotation.CustomMarker customAnnotationView, @Nullable View convertView, @NonNull ViewGroup parent) {
final RCTMGLPointAnnotation pointAnnotation = mMapView.getPointAnnotationByID(customAnnotationView.getAnnotationID());

if (pointAnnotation == null) {
Expand Down Expand Up @@ -97,5 +98,5 @@ private float getZIndex(RCTMGLPointAnnotation pointAnnotation) {
private static class ViewHolder {
ImageView imageView;
LinearLayout customLayout;
}
}*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import android.os.Parcel;
import android.os.Parcelable;

import com.mapbox.mapboxsdk.annotations.BaseMarkerViewOptions;
// import com.mapbox.mapboxsdk.annotations.BaseMarkerViewOptions;
import com.mapbox.mapboxsdk.annotations.BaseMarkerOptions;
import com.mapbox.mapboxsdk.annotations.Icon;
import com.mapbox.mapboxsdk.annotations.IconFactory;
import com.mapbox.mapboxsdk.geometry.LatLng;
Expand All @@ -13,7 +14,7 @@
* Created by nickitaliano on 9/27/17.
*/

public class RCTMGLPointAnnotationOptions extends BaseMarkerViewOptions<RCTMGLPointAnnotation.CustomView, RCTMGLPointAnnotationOptions> {
public class RCTMGLPointAnnotationOptions extends BaseMarkerOptions<RCTMGLPointAnnotation.CustomMarker, RCTMGLPointAnnotationOptions> {
private String mAnnotationID;
private boolean mHasChildren;

Expand All @@ -23,12 +24,12 @@ protected RCTMGLPointAnnotationOptions(Parcel in) {
position((LatLng) in.readParcelable(LatLng.class.getClassLoader()));
snippet(in.readString());
title(in.readString());
flat(in.readByte() != 0);
/* flat(in.readByte() != 0); */
anchor(in.readFloat(), in.readFloat());
infoWindowAnchor(in.readFloat(), in.readFloat());
/* infoWindowAnchor(in.readFloat(), in.readFloat());
rotation(in.readFloat());
visible(in.readByte() != 0);
alpha(in.readFloat());
alpha(in.readFloat()); */
if (in.readByte() != 0) {
// this means we have an icon
String iconId = in.readString();
Expand All @@ -46,8 +47,8 @@ public RCTMGLPointAnnotationOptions getThis() {
}

@Override
public RCTMGLPointAnnotation.CustomView getMarker() {
return new RCTMGLPointAnnotation.CustomView(getAnnotationID(), this);
public RCTMGLPointAnnotation.CustomMarker getMarker() {
return new RCTMGLPointAnnotation.CustomMarker(getAnnotationID(), this);
}

@Override
Expand All @@ -57,22 +58,29 @@ public int describeContents() {

@Override
public void writeToParcel(Parcel out, int flags) {
out.writeParcelable(getPosition(), flags);
out.writeString(getSnippet());
out.writeString(getTitle());
out.writeParcelable(position, flags);
out.writeString(snippet);
out.writeString(title);
/*
out.writeByte((byte) (isFlat() ? 1 : 0));
*/
/*
out.writeFloat(getAnchorU());
out.writeFloat(getAnchorV());

out.writeFloat(getInfoWindowAnchorU());
out.writeFloat(getInfoWindowAnchorV());
out.writeFloat(getRotation());
*/
/*
out.writeByte((byte) (isVisible() ? 1 : 0));
out.writeFloat(alpha);
Icon icon = getIcon();
*/
Icon icon = this.icon;
out.writeByte((byte) (icon != null ? 1 : 0));
if (icon != null) {
out.writeString(getIcon().getId());
out.writeParcelable(getIcon().getBitmap(), flags);
out.writeString(this.icon.getId());
out.writeParcelable(this.icon.getBitmap(), flags);
}
out.writeString(getAnnotationID());
out.writeByte((byte) (getHasChildren() ? 1 : 0));
Expand All @@ -96,6 +104,11 @@ public boolean getHasChildren() {
return mHasChildren;
}

public RCTMGLPointAnnotationOptions anchor(float x, float y) {
// TODO
return this;
}

public static final Parcelable.Creator<RCTMGLPointAnnotationOptions> CREATOR =
new Parcelable.Creator<RCTMGLPointAnnotationOptions>() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import android.util.DisplayMetrics;

import com.facebook.react.bridge.ReadableMap;
import com.mapbox.geojson.FeatureCollection;
import com.mapbox.geojson.Point;
import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.camera.CameraUpdate;
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
Expand All @@ -13,8 +15,6 @@
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.rctmgl.components.camera.constants.CameraMode;
import com.mapbox.rctmgl.utils.GeoJSONUtils;
import com.mapbox.services.commons.geojson.FeatureCollection;
import com.mapbox.services.commons.geojson.Point;

/**
* Created by nickitaliano on 9/5/17.
Expand Down Expand Up @@ -74,11 +74,11 @@ public void setMode(@CameraMode.Mode int mode) {
mMode = mode;
}

public CameraUpdateItem toCameraUpdate() {
public CameraUpdateItem toCameraUpdate(MapboxMap map) {
if (mBounds != null) {
CameraUpdate update = CameraUpdateFactory.newLatLngBounds(mBounds, mBoundsPaddingLeft,
mBooundsPaddingTop, mBoundsPaddingRight, mBoundsPaddingBottom);
return new CameraUpdateItem(update, mDuration, mCallback, CameraMode.FLIGHT);
return new CameraUpdateItem(map, update, mDuration, mCallback, CameraMode.FLIGHT);
}

CameraPosition.Builder builder = new CameraPosition.Builder();
Expand All @@ -99,7 +99,7 @@ public CameraUpdateItem toCameraUpdate() {
builder.target(mLatLng);
}

return new CameraUpdateItem(CameraUpdateFactory.newCameraPosition(builder.build()), mDuration, mCallback, mMode);
return new CameraUpdateItem(map, CameraUpdateFactory.newCameraPosition(builder.build()), mDuration, mCallback, mMode);
}

public static CameraStop fromReadableMap(Context context, @NonNull ReadableMap readableMap, MapboxMap.CancelableCallback callback) {
Expand Down
Loading