From 49b301363dbe4e425c78c8fb0ca16cb1c5aeb303 Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 17 Aug 2017 11:25:51 -0700 Subject: [PATCH] Removed old android and ios projects --- android/build.gradle | 28 - android/install.md | 93 -- android/src/main/AndroidManifest.xml | 7 - .../RNMGLAnnotationOptions.java | 8 - .../RNMGLAnnotationOptionsFactory.java | 244 ----- .../RNMGLAnnotationView.java | 77 -- .../RNMGLAnnotationViewManager.java | 61 -- .../RNMGLCustomMarkerView.java | 18 - .../RNMGLCustomMarkerViewOptions.java | 90 -- .../ReactNativeMapboxGLEventTypes.java | 23 - .../ReactNativeMapboxGLManager.java | 489 ---------- .../ReactNativeMapboxGLView.java | 835 ------------------ .../SizeReportingShadowNode.java | 21 - ios/RCTMapboxGL.podspec | 19 - ios/RCTMapboxGL.xcodeproj/project.pbxproj | 449 ---------- ios/RCTMapboxGL/MGLPolygon+RCTAdditions.h | 10 - ios/RCTMapboxGL/MGLPolygon+RCTAdditions.m | 31 - ios/RCTMapboxGL/MGLPolyline+RCTAdditions.h | 10 - ios/RCTMapboxGL/MGLPolyline+RCTAdditions.m | 20 - ios/RCTMapboxGL/RCTMapboxAnnotation.h | 50 -- ios/RCTMapboxGL/RCTMapboxAnnotation.m | 30 - ios/RCTMapboxGL/RCTMapboxAnnotationManager.h | 14 - ios/RCTMapboxGL/RCTMapboxAnnotationManager.m | 41 - ios/RCTMapboxGL/RCTMapboxGL.h | 121 --- ios/RCTMapboxGL/RCTMapboxGLConversions.h | 13 - ios/RCTMapboxGL/RCTMapboxGLConversions.m | 231 ----- ios/RCTMapboxGL/RCTMapboxGLManager.h | 20 - ios/RCTMapboxGLTests/Info.plist | 24 - ios/install-cocoapods.md | 55 -- ios/install.md | 65 -- 30 files changed, 3197 deletions(-) delete mode 100644 android/build.gradle delete mode 100644 android/install.md delete mode 100644 android/src/main/AndroidManifest.xml delete mode 100644 android/src/main/java/com/mapbox/reactnativemapboxgl/RNMGLAnnotationOptions.java delete mode 100644 android/src/main/java/com/mapbox/reactnativemapboxgl/RNMGLAnnotationOptionsFactory.java delete mode 100644 android/src/main/java/com/mapbox/reactnativemapboxgl/RNMGLAnnotationView.java delete mode 100644 android/src/main/java/com/mapbox/reactnativemapboxgl/RNMGLAnnotationViewManager.java delete mode 100644 android/src/main/java/com/mapbox/reactnativemapboxgl/RNMGLCustomMarkerView.java delete mode 100644 android/src/main/java/com/mapbox/reactnativemapboxgl/RNMGLCustomMarkerViewOptions.java delete mode 100644 android/src/main/java/com/mapbox/reactnativemapboxgl/ReactNativeMapboxGLEventTypes.java delete mode 100644 android/src/main/java/com/mapbox/reactnativemapboxgl/ReactNativeMapboxGLManager.java delete mode 100644 android/src/main/java/com/mapbox/reactnativemapboxgl/ReactNativeMapboxGLView.java delete mode 100644 android/src/main/java/com/mapbox/reactnativemapboxgl/SizeReportingShadowNode.java delete mode 100644 ios/RCTMapboxGL.podspec delete mode 100644 ios/RCTMapboxGL.xcodeproj/project.pbxproj delete mode 100644 ios/RCTMapboxGL/MGLPolygon+RCTAdditions.h delete mode 100644 ios/RCTMapboxGL/MGLPolygon+RCTAdditions.m delete mode 100644 ios/RCTMapboxGL/MGLPolyline+RCTAdditions.h delete mode 100644 ios/RCTMapboxGL/MGLPolyline+RCTAdditions.m delete mode 100644 ios/RCTMapboxGL/RCTMapboxAnnotation.h delete mode 100644 ios/RCTMapboxGL/RCTMapboxAnnotation.m delete mode 100644 ios/RCTMapboxGL/RCTMapboxAnnotationManager.h delete mode 100644 ios/RCTMapboxGL/RCTMapboxAnnotationManager.m delete mode 100644 ios/RCTMapboxGL/RCTMapboxGL.h delete mode 100644 ios/RCTMapboxGL/RCTMapboxGLConversions.h delete mode 100644 ios/RCTMapboxGL/RCTMapboxGLConversions.m delete mode 100644 ios/RCTMapboxGL/RCTMapboxGLManager.h delete mode 100644 ios/RCTMapboxGLTests/Info.plist delete mode 100644 ios/install-cocoapods.md delete mode 100644 ios/install.md diff --git a/android/build.gradle b/android/build.gradle deleted file mode 100644 index 2583266..0000000 --- a/android/build.gradle +++ /dev/null @@ -1,28 +0,0 @@ -apply plugin: 'com.android.library' - -android { - compileSdkVersion 24 - buildToolsVersion "24.0.2" - - defaultConfig { - minSdkVersion 16 - targetSdkVersion 24 - versionCode 1 - versionName "1.0" - } - lintOptions { - abortOnError false - } -} - -repositories { - mavenCentral() -} - -dependencies { - compile 'com.facebook.react:react-native:+' - compile 'com.mapbox.mapboxsdk:mapbox-android-telemetry:2.1.0@aar' - compile('com.mapbox.mapboxsdk:mapbox-android-sdk:5.0.2@aar') { - transitive = true - } -} diff --git a/android/install.md b/android/install.md deleted file mode 100644 index 957492e..0000000 --- a/android/install.md +++ /dev/null @@ -1,93 +0,0 @@ -#### Note - -If you were using react-native-mapbox-gl before we moved it into the mapbox npm org. -You will need to unlink react-native-mapbox-gl and link @mapbox/react-native-mapbox-gl - -#### Step 1 - NPM Install - -Run with ```--ignore-scripts``` if you don't want to download the iOS SDK, as well. - -```shell -npm install --save @mapbox/react-native-mapbox-gl --ignore-scripts -``` - -#### Step 2 - Use with Gradle - -##### Option A - Automatically - -```shell -react-native link @mapbox/react-native-mapbox-gl -``` - -##### Option B - Manually - -Edit the following files: - -```gradle -// file: android/settings.gradle -... - -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') -``` - -```gradle -// file: android/app/build.gradle -... - -dependencies { - ... - compile project(':@mapbox/react-native-mapbox-gl') -} -``` - -```java -// file: android/app/src/main/java/com/yourcompany/yourapp/MainApplication.java -import com.mapbox.reactnativemapboxgl.ReactNativeMapboxGLPackage; // <-- import -... -/** - * A list of packages used by the app. If the app uses additional views - * or modules besides the default ones, add more packages here. - */ - @Override - protected List getPackages() { - return Arrays.asList( - new MainReactPackage(), - new ReactNativeMapboxGLPackage()); // <-- Register package here - } -``` - -#### Step 3 - Add Mapbox to AndroidManifest.xml - -Add the following permissions to the `` root node of your `AndroidManifest.xml`: - -```xml - - - - -``` - -Also, add the Mapbox analytics service to the `` node: - -```xml - -``` - -#### Step 4 - Add to project, [see example](../example.js) - -#### Troubleshoot - -You may get `com.android.dex.DexException: Multiple dex files define Lokhttp3/internal/ws/WebSocketReader$FrameCallback` -error when building the android app. You can solve it by adding this. -```gradle -// file: android/app/build.gradle -... - -configurations.all { - resolutionStrategy { - force "com.squareup.okhttp3:okhttp:3.4.2" - force "com.squareup.okhttp3:okhttp-ws:3.4.2" - } -} -``` diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml deleted file mode 100644 index 9fd8743..0000000 --- a/android/src/main/AndroidManifest.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/android/src/main/java/com/mapbox/reactnativemapboxgl/RNMGLAnnotationOptions.java b/android/src/main/java/com/mapbox/reactnativemapboxgl/RNMGLAnnotationOptions.java deleted file mode 100644 index 1d273cc..0000000 --- a/android/src/main/java/com/mapbox/reactnativemapboxgl/RNMGLAnnotationOptions.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.mapbox.reactnativemapboxgl; - -import com.mapbox.mapboxsdk.annotations.Annotation; -import com.mapbox.mapboxsdk.maps.MapboxMap; - -public interface RNMGLAnnotationOptions { - public abstract Annotation addToMap(MapboxMap map); -} \ No newline at end of file diff --git a/android/src/main/java/com/mapbox/reactnativemapboxgl/RNMGLAnnotationOptionsFactory.java b/android/src/main/java/com/mapbox/reactnativemapboxgl/RNMGLAnnotationOptionsFactory.java deleted file mode 100644 index f2ee1cd..0000000 --- a/android/src/main/java/com/mapbox/reactnativemapboxgl/RNMGLAnnotationOptionsFactory.java +++ /dev/null @@ -1,244 +0,0 @@ -package com.mapbox.reactnativemapboxgl; - -import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.drawable.BitmapDrawable; -import android.graphics.drawable.Drawable; -import android.support.v4.content.ContextCompat; - -import com.facebook.react.bridge.ReadableMap; -import com.facebook.react.bridge.ReadableArray; -import com.mapbox.mapboxsdk.annotations.Annotation; -import com.mapbox.mapboxsdk.annotations.Icon; -import com.mapbox.mapboxsdk.annotations.IconFactory; -import com.mapbox.mapboxsdk.annotations.MarkerOptions; -import com.mapbox.mapboxsdk.annotations.PolygonOptions; -import com.mapbox.mapboxsdk.annotations.PolylineOptions; -import com.mapbox.mapboxsdk.geometry.LatLng; -import com.mapbox.mapboxsdk.maps.MapboxMap; - -import java.io.IOException; -import java.io.InputStream; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.HashMap; -import java.util.Map; - -class RNMGLMarkerOptions implements RNMGLAnnotationOptions { - protected MarkerOptions _options; - - public RNMGLMarkerOptions(MarkerOptions options) { - _options = options; - } - - @Override - public Annotation addToMap(MapboxMap map) { - return map.addMarker(_options); - } -} - -class RNMGLPolylineOptions implements RNMGLAnnotationOptions { - protected PolylineOptions _options; - - public RNMGLPolylineOptions(PolylineOptions options) { - _options = options; - } - - @Override - public Annotation addToMap(MapboxMap map) { - return map.addPolyline(_options); - } -} - -class RNMGLPolygonOptions implements RNMGLAnnotationOptions { - protected PolygonOptions _options; - - public RNMGLPolygonOptions(PolygonOptions options) { - _options = options; - } - - @Override - public Annotation addToMap(MapboxMap map) { - return map.addPolygon(_options); - } -} - -public class RNMGLAnnotationOptionsFactory { - - public static RNMGLAnnotationOptions annotationOptionsFromJS(ReadableMap annotation, Context context) { - String type = annotation.getString("type"); - - if (type.equals("point")) { - return markerOptionsFromJS(annotation, context); - } else if (type.equals("polyline")) { - return polylineOptionsFromJS(annotation); - } else if (type.equals("polygon")) { - return polygonOptionsFromJS(annotation); - } - - return null; - } - - static Drawable drawableFromDrawableName(Context context, String drawableName) { - int resID = context.getResources().getIdentifier(drawableName, "drawable", context.getApplicationContext().getPackageName()); - return ContextCompat.getDrawable(context, resID); - } - - static Drawable drawableFromUrl(Context context, String url) throws IOException { - // This doesn't currently work, as it throws NetworkOnMainThreadException - HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection(); - connection.connect(); - InputStream input = connection.getInputStream(); - - Bitmap bitmap = BitmapFactory.decodeStream(input); - return new BitmapDrawable(context.getResources(), bitmap); - } - - static Map iconCache = new HashMap(); - - static Icon iconFromSourceAndSize(Context context, ReadableMap source, int width, int height) throws IOException { - String path = source.getString("uri"); - String cacheKey = path + "||" + width + "||" + height; - Icon icon = iconCache.get(cacheKey); - if (icon != null) { return icon; } - - Drawable drawable; - try { - drawable = drawableFromUrl(context, path); - } catch (MalformedURLException ex) { - drawable = drawableFromDrawableName(context, path); - } - - IconFactory iconFactory = IconFactory.getInstance(context); - - int intrinsicWidth = drawable.getIntrinsicWidth(); - int intrinsicHeight = drawable.getIntrinsicHeight(); - - if (width < 0) { width = intrinsicWidth; } - if (height < 0) { height = intrinsicHeight; } - - // Check if a rescale would be superfluous - if ((drawable instanceof BitmapDrawable) && width == intrinsicWidth && height == intrinsicHeight) { - icon = iconFactory.fromBitmap(((BitmapDrawable)drawable).getBitmap()); - } else { - // Conversion taken from mapbox-gl-native/issues/7897#issuecomment-277302450 - Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), - drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888); - Canvas canvas = new Canvas(bitmap); - drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); - //DrawableCompat.setTint(drawable, colorRes); - drawable.draw(canvas); - icon = iconFactory.fromBitmap(bitmap); - } - - iconCache.put(cacheKey, icon); - return icon; - } - - static RNMGLAnnotationOptions markerOptionsFromJS(ReadableMap annotation, Context context) { - MarkerOptions marker = new MarkerOptions(); - - double latitude = annotation.getArray("coordinates").getDouble(0); - double longitude = annotation.getArray("coordinates").getDouble(1); - LatLng markerCenter = new LatLng(latitude, longitude); - marker.position(markerCenter); - - if (annotation.hasKey("title")) { - String title = annotation.getString("title"); - marker.title(title); - } - - if (annotation.hasKey("subtitle")) { - String subtitle = annotation.getString("subtitle"); - marker.snippet(subtitle); - } - - if (annotation.hasKey("annotationImage")) { - ReadableMap annotationImage = annotation.getMap("annotationImage"); - ReadableMap annotationSource = annotationImage.getMap("source"); - try { - int width = -1; - int height = -1; - - if (annotationImage.hasKey("height") && annotationImage.hasKey("width")) { - float scale = context.getResources().getDisplayMetrics().density; - height = Math.round((float)annotationImage.getInt("height") * scale); - width = Math.round((float)annotationImage.getInt("width") * scale); - } - - marker.icon(iconFromSourceAndSize(context, annotationSource, width, height)); - } catch (Exception e) { - e.printStackTrace(); - } - } - return new RNMGLMarkerOptions(marker); - } - - static RNMGLAnnotationOptions polylineOptionsFromJS(ReadableMap annotation) { - PolylineOptions polyline = new PolylineOptions(); - - ReadableArray coordinates = annotation.getArray("coordinates"); - int coordinatesSize = coordinates.size(); - if (coordinatesSize > 0) { - LatLng[] points = new LatLng[coordinatesSize]; - ReadableArray coordinate; - for (int p = 0; p < coordinatesSize; p++) { - coordinate = coordinates.getArray(p); - points[p] = new LatLng( - coordinate.getDouble(0), - coordinate.getDouble(1) - ); - } - polyline.add(points); - } - - if (annotation.hasKey("alpha")) { - double strokeAlpha = annotation.getDouble("alpha"); - polyline.alpha((float) strokeAlpha); - } - - if (annotation.hasKey("strokeColor")) { - int strokeColor = Color.parseColor(annotation.getString("strokeColor")); - polyline.color(strokeColor); - } - - if (annotation.hasKey("strokeWidth")) { - float strokeWidth = annotation.getInt("strokeWidth"); - polyline.width(strokeWidth); - } - - return new RNMGLPolylineOptions(polyline); - } - - static RNMGLAnnotationOptions polygonOptionsFromJS(ReadableMap annotation) { - PolygonOptions polygon = new PolygonOptions(); - - int coordSize = annotation.getArray("coordinates").size(); - for (int p = 0; p < coordSize; p++) { - double latitude = annotation.getArray("coordinates").getArray(p).getDouble(0); - double longitude = annotation.getArray("coordinates").getArray(p).getDouble(1); - polygon.add(new LatLng(latitude, longitude)); - } - - if (annotation.hasKey("alpha")) { - double fillAlpha = annotation.getDouble("alpha"); - polygon.alpha((float) fillAlpha); - } - - if (annotation.hasKey("fillColor")) { - int fillColor = Color.parseColor(annotation.getString("fillColor")); - polygon.fillColor(fillColor); - } - - if (annotation.hasKey("strokeColor")) { - int strokeColor = Color.parseColor(annotation.getString("strokeColor")); - polygon.strokeColor(strokeColor); - } - - return new RNMGLPolygonOptions(polygon); - } -} diff --git a/android/src/main/java/com/mapbox/reactnativemapboxgl/RNMGLAnnotationView.java b/android/src/main/java/com/mapbox/reactnativemapboxgl/RNMGLAnnotationView.java deleted file mode 100644 index 10b4bba..0000000 --- a/android/src/main/java/com/mapbox/reactnativemapboxgl/RNMGLAnnotationView.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.mapbox.reactnativemapboxgl; - -import android.content.Context; - -import com.facebook.react.views.view.ReactViewGroup; -import com.mapbox.mapboxsdk.geometry.LatLng; - -import java.util.HashSet; -import java.util.Set; - -public class RNMGLAnnotationView extends ReactViewGroup { - - private Set propertyListeners; - private String annotationId; - private LatLng coordinate; - private float layoutWidth; - private float layoutHeight; - - public RNMGLAnnotationView(Context context) { - super(context); - this.propertyListeners = new HashSet<>(); - } - - // Properties - - public String getAnnotationId() { - return annotationId; - } - - public void setAnnotationId(String annotationId) { - this.annotationId = annotationId; - } - - public LatLng getCoordinate() { - return coordinate; - } - - public void setCoordinate(LatLng coordinate) { - this.coordinate = coordinate; - fireUpdateEvent(); - } - - // React layout - - public void setLayoutDimensions(float layoutWidth, float layoutHeight) { - this.layoutWidth = layoutWidth; - this.layoutHeight = layoutHeight; - } - - public float getLayoutWidth() { - return layoutWidth; - } - - public float getLayoutHeight() { - return layoutHeight; - } - - // Listeners - - public void addPropertyListener(PropertyListener propertyListener) { - propertyListeners.add(propertyListener); - } - - public void removePropertyListener(PropertyListener propertyListener) { - propertyListeners.remove(propertyListener); - } - - private void fireUpdateEvent() { - for (PropertyListener listener : propertyListeners) { - listener.propertiesUpdated(this); - } - } - - public interface PropertyListener { - void propertiesUpdated(RNMGLAnnotationView view); - } -} diff --git a/android/src/main/java/com/mapbox/reactnativemapboxgl/RNMGLAnnotationViewManager.java b/android/src/main/java/com/mapbox/reactnativemapboxgl/RNMGLAnnotationViewManager.java deleted file mode 100644 index 159a228..0000000 --- a/android/src/main/java/com/mapbox/reactnativemapboxgl/RNMGLAnnotationViewManager.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.mapbox.reactnativemapboxgl; - -import com.facebook.react.bridge.ReadableMap; -import com.facebook.react.uimanager.LayoutShadowNode; -import com.facebook.react.uimanager.ThemedReactContext; -import com.facebook.react.uimanager.ViewGroupManager; -import com.facebook.react.uimanager.annotations.ReactProp; -import com.mapbox.mapboxsdk.geometry.LatLng; - -import java.util.HashMap; - -public class RNMGLAnnotationViewManager extends ViewGroupManager { - - private static final String NAME = "RCTMapboxAnnotation"; - - @Override - public String getName() { - return NAME; - } - - @Override - protected RNMGLAnnotationView createViewInstance(ThemedReactContext reactContext) { - return new RNMGLAnnotationView(reactContext); - } - - @Override - public Class getShadowNodeClass() { - return SizeReportingShadowNode.class; - } - - @Override - public LayoutShadowNode createShadowNodeInstance() { - return new SizeReportingShadowNode(); - } - - // Props - - @ReactProp(name = "id") - public void setAnnotationId(RNMGLAnnotationView view, String value) { - view.setAnnotationId(value); - } - - @ReactProp(name = "coordinate") - public void setCoordinate(RNMGLAnnotationView view, ReadableMap map) { - LatLng coordinate = new LatLng(); - coordinate.setLatitude(map.getDouble("latitude")); - coordinate.setLongitude(map.getDouble("longitude")); - view.setCoordinate(coordinate); - } - - @Override - public void updateExtraData(RNMGLAnnotationView view, Object extraData) { - // This is called from the {@link SizeReportingShadowNode}. We cache - // the width and height so that we can set the correct size on the marker - // view annotations in ReactNativeMapboxGLView RNMGLCustomMarkerViewAdapter. - HashMap data = (HashMap) extraData; - float width = data.get("width"); - float height = data.get("height"); - view.setLayoutDimensions(width, height); - } -} diff --git a/android/src/main/java/com/mapbox/reactnativemapboxgl/RNMGLCustomMarkerView.java b/android/src/main/java/com/mapbox/reactnativemapboxgl/RNMGLCustomMarkerView.java deleted file mode 100644 index 34f939a..0000000 --- a/android/src/main/java/com/mapbox/reactnativemapboxgl/RNMGLCustomMarkerView.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.mapbox.reactnativemapboxgl; - -import com.mapbox.mapboxsdk.annotations.BaseMarkerViewOptions; -import com.mapbox.mapboxsdk.annotations.MarkerView; - -public class RNMGLCustomMarkerView extends MarkerView { - - private String annotationId; - - public RNMGLCustomMarkerView(BaseMarkerViewOptions baseMarkerViewOptions, String annotationId) { - super(baseMarkerViewOptions); - this.annotationId = annotationId; - } - - public String getAnnotationId() { - return annotationId; - } -} diff --git a/android/src/main/java/com/mapbox/reactnativemapboxgl/RNMGLCustomMarkerViewOptions.java b/android/src/main/java/com/mapbox/reactnativemapboxgl/RNMGLCustomMarkerViewOptions.java deleted file mode 100644 index 3c7cbe2..0000000 --- a/android/src/main/java/com/mapbox/reactnativemapboxgl/RNMGLCustomMarkerViewOptions.java +++ /dev/null @@ -1,90 +0,0 @@ -package com.mapbox.reactnativemapboxgl; - -import android.graphics.Bitmap; -import android.os.Parcel; -import android.os.Parcelable; - -import com.mapbox.mapboxsdk.annotations.BaseMarkerViewOptions; -import com.mapbox.mapboxsdk.annotations.Icon; -import com.mapbox.mapboxsdk.annotations.IconFactory; -import com.mapbox.mapboxsdk.geometry.LatLng; - -public class RNMGLCustomMarkerViewOptions extends BaseMarkerViewOptions { - private String annotationId; - - public RNMGLCustomMarkerViewOptions() {} - - protected RNMGLCustomMarkerViewOptions(Parcel in) { - position((LatLng) in.readParcelable(LatLng.class.getClassLoader())); - snippet(in.readString()); - title(in.readString()); - flat(in.readByte() != 0); - anchor(in.readFloat(), in.readFloat()); - infoWindowAnchor(in.readFloat(), in.readFloat()); - rotation(in.readFloat()); - visible(in.readByte() != 0); - alpha(in.readFloat()); - if (in.readByte() != 0) { - // this means we have an icon - String iconId = in.readString(); - Bitmap iconBitmap = in.readParcelable(Bitmap.class.getClassLoader()); - Icon icon = IconFactory.recreate(iconId, iconBitmap); - icon(icon); - } - annotationId(in.readString()); - } - - @Override - public RNMGLCustomMarkerViewOptions getThis() { - return this; - } - - @Override - public RNMGLCustomMarkerView getMarker() { - return new RNMGLCustomMarkerView(this, annotationId); - } - - @Override - public int describeContents() { - return 0; - } - - @Override - public void writeToParcel(Parcel out, int flags) { - out.writeParcelable(getPosition(), flags); - out.writeString(getSnippet()); - out.writeString(getTitle()); - 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(getAlpha()); - Icon icon = getIcon(); - out.writeByte((byte) (icon != null ? 1 : 0)); - if (icon != null) { - out.writeString(getIcon().getId()); - out.writeParcelable(getIcon().getBitmap(), flags); - } - out.writeString(annotationId); - } - - public RNMGLCustomMarkerViewOptions annotationId(String annotationId) { - this.annotationId = annotationId; - return getThis(); - } - - public static final Parcelable.Creator CREATOR - = new Parcelable.Creator() { - public RNMGLCustomMarkerViewOptions createFromParcel(Parcel in) { - return new RNMGLCustomMarkerViewOptions(in); - } - - public RNMGLCustomMarkerViewOptions[] newArray(int size) { - return new RNMGLCustomMarkerViewOptions[size]; - } - }; - -} diff --git a/android/src/main/java/com/mapbox/reactnativemapboxgl/ReactNativeMapboxGLEventTypes.java b/android/src/main/java/com/mapbox/reactnativemapboxgl/ReactNativeMapboxGLEventTypes.java deleted file mode 100644 index d4a4c95..0000000 --- a/android/src/main/java/com/mapbox/reactnativemapboxgl/ReactNativeMapboxGLEventTypes.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.mapbox.reactnativemapboxgl; - - -/** - * Prefix all the internal event names with mapbox so that they don't clobber or get clobbered - * by events with the same name in other libraries. None of this will be visible to the user. - * The callback names will remain normal. - */ -public class ReactNativeMapboxGLEventTypes { - public static String ON_REGION_DID_CHANGE = "mapbox.onRegionDidChange"; - public static String ON_REGION_WILL_CHANGE = "mapbox.onRegionWillChange"; - public static String ON_OPEN_ANNOTATION = "mapbox.onOpenAnnotation"; - public static String ON_RIGHT_ANNOTATION_TAPPED = "mapbox.onRightAnnotationTapped"; - public static String ON_CHANGE_USER_TRACKING_MODE = "mapbox.onChangeUserTrackingMode"; - public static String ON_UPDATE_USER_LOCATION = "mapbox.onUpdateUserLocation"; - public static String ON_LONG_PRESS = "mapbox.onLongPress"; - public static String ON_TAP = "mapbox.onTap"; - public static String ON_FINISH_LOADING_MAP = "mapbox.onFinishLoadingMap"; - public static String ON_START_LOADING_MAP = "mapbox.onStartLoadingMap"; - public static String ON_LOCATE_USER_FAILED = "mapbox.onLocateUserFailed"; - - private ReactNativeMapboxGLEventTypes() {} -} diff --git a/android/src/main/java/com/mapbox/reactnativemapboxgl/ReactNativeMapboxGLManager.java b/android/src/main/java/com/mapbox/reactnativemapboxgl/ReactNativeMapboxGLManager.java deleted file mode 100644 index 069e00d..0000000 --- a/android/src/main/java/com/mapbox/reactnativemapboxgl/ReactNativeMapboxGLManager.java +++ /dev/null @@ -1,489 +0,0 @@ - -package com.mapbox.reactnativemapboxgl; - -import android.util.Log; -import android.view.View; - -import com.facebook.infer.annotation.Assertions; -import com.facebook.react.bridge.Arguments; -import com.facebook.react.bridge.JSApplicationIllegalArgumentException; -import com.facebook.react.bridge.ReactApplicationContext; -import com.facebook.react.bridge.ReadableArray; -import com.facebook.react.bridge.ReadableMap; -import com.facebook.react.bridge.WritableArray; -import com.facebook.react.bridge.WritableMap; -import com.facebook.react.common.MapBuilder; -import com.facebook.react.modules.core.RCTNativeAppEventEmitter; -import com.facebook.react.uimanager.ViewGroupManager; -import com.facebook.react.uimanager.annotations.ReactProp; -import com.facebook.react.uimanager.ThemedReactContext; -import com.mapbox.mapboxsdk.camera.CameraPosition; -import com.mapbox.mapboxsdk.camera.CameraUpdate; -import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; -import com.mapbox.mapboxsdk.constants.MapboxConstants; -import com.mapbox.mapboxsdk.geometry.LatLng; -import com.mapbox.mapboxsdk.geometry.LatLngBounds; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -public class ReactNativeMapboxGLManager extends ViewGroupManager { - - private static final String REACT_CLASS = "RCTMapboxGL"; - - private ReactApplicationContext _context; - private Map> _childViews; - private Set _childListeners; - - public ReactNativeMapboxGLManager(ReactApplicationContext context) { - super(); - _context = context; - _childViews = new HashMap<>(); - _childListeners = new HashSet<>(); - } - - @Override - public String getName() { - return REACT_CLASS; - } - - public ReactApplicationContext getContext() { - return _context; - } - - public List getAnnotationViews(ReactNativeMapboxGLView parent) { - List annotationViews = new ArrayList<>(); - for (View view : _childViews.get(parent)) { - if (RNMGLAnnotationView.class.equals(view.getClass())) { - annotationViews.add((RNMGLAnnotationView) view); - } - } - return annotationViews; - } - - // Lifecycle methods - - @Override - public ReactNativeMapboxGLView createViewInstance(ThemedReactContext context) { - return new ReactNativeMapboxGLView(context, this); - } - - @Override - protected void onAfterUpdateTransaction(ReactNativeMapboxGLView view) { - super.onAfterUpdateTransaction(view); - view.onAfterUpdateTransaction(); - } - - @Override - public void onDropViewInstance(ReactNativeMapboxGLView view) { - view.onDrop(); - } - - // Event types - @Override - public @Nullable Map getExportedCustomDirectEventTypeConstants() { - return MapBuilder.builder() - .put(ReactNativeMapboxGLEventTypes.ON_REGION_DID_CHANGE, MapBuilder.of("registrationName", "onRegionDidChange")) - .put(ReactNativeMapboxGLEventTypes.ON_REGION_WILL_CHANGE, MapBuilder.of("registrationName", "onRegionWillChange")) - .put(ReactNativeMapboxGLEventTypes.ON_OPEN_ANNOTATION, MapBuilder.of("registrationName", "onOpenAnnotation")) - .put(ReactNativeMapboxGLEventTypes.ON_RIGHT_ANNOTATION_TAPPED, MapBuilder.of("registrationName", "onRightAnnotationTapped")) - .put(ReactNativeMapboxGLEventTypes.ON_CHANGE_USER_TRACKING_MODE, MapBuilder.of("registrationName", "onChangeUserTrackingMode")) - .put(ReactNativeMapboxGLEventTypes.ON_UPDATE_USER_LOCATION, MapBuilder.of("registrationName", "onUpdateUserLocation")) - .put(ReactNativeMapboxGLEventTypes.ON_LONG_PRESS, MapBuilder.of("registrationName", "onLongPress")) - .put(ReactNativeMapboxGLEventTypes.ON_TAP, MapBuilder.of("registrationName", "onTap")) - .put(ReactNativeMapboxGLEventTypes.ON_FINISH_LOADING_MAP, MapBuilder.of("registrationName", "onFinishLoadingMap")) - .put(ReactNativeMapboxGLEventTypes.ON_START_LOADING_MAP, MapBuilder.of("registrationName", "onStartLoadingMap")) - .put(ReactNativeMapboxGLEventTypes.ON_LOCATE_USER_FAILED, MapBuilder.of("registrationName", "onLocateUserFailed")) - .build(); - } - - // Children - - public interface ChildListener { - void childAdded(View child); - void childRemoved(View child); - } - - public void addChildListener(ChildListener listener) { - _childListeners.add(listener); - } - - public void removeChildListener(ChildListener listener) { - _childListeners.remove(listener); - } - - @Override - public void addView(ReactNativeMapboxGLView parent, View child, int index) { - if (!_childViews.containsKey(parent)) { - _childViews.put(parent, new ArrayList()); - } - _childViews.get(parent).add(index, child); - if (!RNMGLAnnotationView.class.equals(child.getClass())) { - super.addView(parent, child, getRealIndex(parent, index)); - } - for (ChildListener listener : _childListeners) { - listener.childAdded(child); - } - } - - @Override - public int getChildCount(ReactNativeMapboxGLView parent) { - return _childViews.get(parent).size(); - } - - @Override - public View getChildAt(ReactNativeMapboxGLView parent, int index) { - return _childViews.get(parent).get(index); - } - - @Override - public void removeViewAt(ReactNativeMapboxGLView parent, int index) { - int realIndex = getRealIndex(parent, index); - View child = _childViews.get(parent).remove(index); - if (!RNMGLAnnotationView.class.equals(child.getClass())) { - super.removeViewAt(parent, realIndex); - } - for (ChildListener listener : _childListeners) { - listener.childRemoved(child); - } - if (_childViews.get(parent).isEmpty()) { - _childViews.remove(parent); - } - } - - private int getRealIndex(ReactNativeMapboxGLView parent, int index) { - int annotationViews = 0; - for (int i = 0; i < index; i++) { - if (RNMGLAnnotationView.class.equals(getChildAt(parent, i).getClass())) { - annotationViews++; - } - } - return index - annotationViews; - } - - // Props - - @ReactProp(name = "initialZoomLevel") - public void setInitialZoomLevel(ReactNativeMapboxGLView view, double value) { - view.setInitialZoomLevel(value); - } - - @ReactProp(name = "minimumZoomLevel") - public void setMinumumZoomLevel(ReactNativeMapboxGLView view, double value) { - view.setMinimumZoomLevel(value); - } - - @ReactProp(name = "maximumZoomLevel") - public void setMaxumumZoomLevel(ReactNativeMapboxGLView view, double value) { - view.setMaximumZoomLevel(value); - } - - @ReactProp(name = "initialDirection") - public void setInitialDirection(ReactNativeMapboxGLView view, double value) { - view.setInitialDirection(value); - } - - @ReactProp(name = "initialCenterCoordinate") - public void setInitialCenterCoordinate(ReactNativeMapboxGLView view, ReadableMap coord) { - double lat = coord.getDouble("latitude"); - double lon = coord.getDouble("longitude"); - view.setInitialCenterCoordinate(lat, lon); - } - - @ReactProp(name = "enableOnRegionDidChange") - public void setEnableOnRegionDidChange(ReactNativeMapboxGLView view, boolean value) { - view.setEnableOnRegionDidChange(value); - } - - @ReactProp(name = "enableOnRegionWillChange") - public void setEnableOnRegionWillChange(ReactNativeMapboxGLView view, boolean value) { - view.setEnableOnRegionWillChange(value); - } - - @ReactProp(name = "debugActive") - public void setDebugActive(ReactNativeMapboxGLView view, boolean value) { - view.setDebugActive(value); - } - - @ReactProp(name = "rotateEnabled") - public void setRotateEnabled(ReactNativeMapboxGLView view, boolean value) { - view.setRotateEnabled(value); - } - - @ReactProp(name = "scrollEnabled") - public void setScrollEnabled(ReactNativeMapboxGLView view, boolean value) { - view.setScrollEnabled(value); - } - - @ReactProp(name = "zoomEnabled") - public void setZoomEnabled(ReactNativeMapboxGLView view, boolean value) { - view.setZoomEnabled(value); - } - - @ReactProp(name = "pitchEnabled") - public void setPitchEnabled(ReactNativeMapboxGLView view, boolean value) { - view.setPitchEnabled(value); - } - - @ReactProp(name = "annotationsPopUpEnabled") - public void setAnnotationsPopUpEnabled(ReactNativeMapboxGLView view, boolean value) { - view.setAnnotationsPopUpEnabled(value); - } - - @ReactProp(name = "showsUserLocation") - public void setShowsUserLocation(ReactNativeMapboxGLView view, boolean value) { - view.setShowsUserLocation(value); - } - - @ReactProp(name = "styleURL") - public void setStyleUrl(ReactNativeMapboxGLView view, @Nonnull String styleURL) { - view.setStyleURL(styleURL); - } - - @ReactProp(name = "userTrackingMode") - public void setUserTrackingMode(ReactNativeMapboxGLView view, int mode) { - view.setLocationTracking(ReactNativeMapboxGLModule.locationTrackingModes[mode]); - view.setBearingTracking(ReactNativeMapboxGLModule.bearingTrackingModes[mode]); - } - - @ReactProp(name = "attributionButtonIsHidden") - public void setAttributionButtonIsHidden(ReactNativeMapboxGLView view, boolean value) { - view.setAttributionButtonIsHidden(value); - } - - @ReactProp(name = "logoIsHidden") - public void setLogoIsHidden(ReactNativeMapboxGLView view, boolean value) { - view.setLogoIsHidden(value); - } - - @ReactProp(name = "compassIsHidden") - public void setCompassIsHidden(ReactNativeMapboxGLView view, boolean value) { - view.setCompassIsHidden(value); - } - - @ReactProp(name = "contentInset") - public void setContentInset(ReactNativeMapboxGLView view, ReadableArray inset) { - view.setContentInset(inset.getInt(0), inset.getInt(1), inset.getInt(2), inset.getInt(3)); - } - - // Commands - - public static final int COMMAND_GET_DIRECTION = 0; - public static final int COMMAND_GET_PITCH = 1; - public static final int COMMAND_GET_CENTER_COORDINATE_ZOOM_LEVEL = 2; - public static final int COMMAND_GET_BOUNDS = 3; - public static final int COMMAND_EASE_TO = 4; - public static final int COMMAND_SET_VISIBLE_COORDINATE_BOUNDS = 6; - public static final int COMMAND_SELECT_ANNOTATION = 7; - public static final int COMMAND_SPLICE_ANNOTATIONS = 8; - public static final int COMMAND_DESELECT_ANNOTATION = 9; - - @Override - public - @Nullable - Map getCommandsMap() { - return MapBuilder.builder() - .put("getDirection", COMMAND_GET_DIRECTION) - .put("getPitch", COMMAND_GET_PITCH) - .put("getCenterCoordinateZoomLevel", COMMAND_GET_CENTER_COORDINATE_ZOOM_LEVEL) - .put("getBounds", COMMAND_GET_BOUNDS) - .put("easeTo", COMMAND_EASE_TO) - .put("setVisibleCoordinateBounds", COMMAND_SET_VISIBLE_COORDINATE_BOUNDS) - .put("selectAnnotation", COMMAND_SELECT_ANNOTATION) - .put("spliceAnnotations", COMMAND_SPLICE_ANNOTATIONS) - .put("deselectAnnotation", COMMAND_DESELECT_ANNOTATION) - .build(); - } - - private void fireCallback(int callbackId, WritableArray args) { - WritableArray event = Arguments.createArray(); - event.pushInt(callbackId); - event.pushArray(args); - - _context.getJSModule(RCTNativeAppEventEmitter.class) - .emit("MapboxAndroidCallback", event); - } - - @Override - public void receiveCommand(ReactNativeMapboxGLView view, int commandId, @Nullable ReadableArray args) { - Assertions.assertNotNull(args); - switch (commandId) { - case COMMAND_GET_DIRECTION: - getDirection(view, args.getInt(0)); - break; - case COMMAND_GET_PITCH: - getPitch(view, args.getInt(0)); - break; - case COMMAND_GET_CENTER_COORDINATE_ZOOM_LEVEL: - getCenterCoordinateZoomLevel(view, args.getInt(0)); - break; - case COMMAND_GET_BOUNDS: - getBounds(view, args.getInt(0)); - break; - case COMMAND_EASE_TO: - easeTo(view, args.getMap(0), args.getBoolean(1), args.getInt(2)); - break; - case COMMAND_SET_VISIBLE_COORDINATE_BOUNDS: - setVisibleCoordinateBounds(view, - args.getDouble(0), args.getDouble(1), args.getDouble(2), args.getDouble(3), - args.getDouble(4), args.getDouble(5), args.getDouble(6), args.getDouble(7), - args.getBoolean(8) - ); - break; - case COMMAND_SELECT_ANNOTATION: - selectAnnotation(view, args.getString(0), args.getBoolean(1)); - break; - case COMMAND_SPLICE_ANNOTATIONS: - spliceAnnotations(view, args.getBoolean(0), args.getArray(1), args.getArray(2)); - break; - case COMMAND_DESELECT_ANNOTATION: - deselectAnnotation(view); - break; - default: - throw new JSApplicationIllegalArgumentException("Invalid commandId " + commandId + " sent to " + getClass().getSimpleName()); - } - } - - // Getters - - private void getDirection(ReactNativeMapboxGLView view, int callbackId) { - WritableArray result = Arguments.createArray(); - result.pushDouble(view.getCameraPosition().bearing); - fireCallback(callbackId, result); - } - - private void getPitch(ReactNativeMapboxGLView view, int callbackId) { - WritableArray result = Arguments.createArray(); - result.pushDouble(view.getCameraPosition().tilt); - fireCallback(callbackId, result); - } - - private void getCenterCoordinateZoomLevel(ReactNativeMapboxGLView view, int callbackId) { - CameraPosition camera = view.getCameraPosition(); - - WritableArray args = Arguments.createArray(); - WritableMap result = Arguments.createMap(); - result.putDouble("latitude", camera.target.getLatitude()); - result.putDouble("longitude", camera.target.getLongitude()); - result.putDouble("zoomLevel", camera.zoom); - args.pushMap(result); - - fireCallback(callbackId, args); - } - - private void getBounds(ReactNativeMapboxGLView view, int callbackId) { - LatLngBounds bounds = view.getBounds(); - - WritableArray args = Arguments.createArray(); - WritableArray result = Arguments.createArray(); - result.pushDouble(bounds.getLatSouth()); - result.pushDouble(bounds.getLonWest()); - result.pushDouble(bounds.getLatNorth()); - result.pushDouble(bounds.getLonEast()); - args.pushArray(result); - - fireCallback(callbackId, args); - } - - // Setters - - private void easeTo(ReactNativeMapboxGLView view, ReadableMap updates, boolean animated, int callbackId) { - CameraPosition oldPosition = view.getCameraPosition(); - CameraPosition.Builder cameraBuilder = new CameraPosition.Builder(oldPosition); - - if (updates.hasKey("latitude") && updates.hasKey("longitude")) { - cameraBuilder.target(new LatLng(updates.getDouble("latitude"), updates.getDouble("longitude"))); - } - if (updates.hasKey("zoomLevel")) { - cameraBuilder.zoom(updates.getDouble("zoomLevel")); - } - if (updates.hasKey("direction")) { - cameraBuilder.bearing(updates.getDouble("direction")); - } - if (updates.hasKey("pitch")) { - cameraBuilder.tilt(updates.getDouble("pitch")); - } - - // I want lambdas :( - class CallbackRunnable implements Runnable { - int callbackId; - ReactNativeMapboxGLManager manager; - - CallbackRunnable(ReactNativeMapboxGLManager manager, int callbackId) { - this.callbackId = callbackId; - this.manager = manager; - } - - @Override - public void run() { - manager.fireCallback(callbackId, Arguments.createArray()); - } - } - - int duration = animated ? MapboxConstants.ANIMATION_DURATION : 0; - view.setCameraPosition(cameraBuilder.build(), duration, new CallbackRunnable(this, callbackId)); - } - - public void setCamera( - ReactNativeMapboxGLView view, - double latitude, double longitude, - double altitude, double pitch, double direction, - double duration) { - throw new JSApplicationIllegalArgumentException("MapView.setCamera() is not supported on Android. If you're trying to change pitch, use MapView.easeTo()"); - } - - public void setVisibleCoordinateBounds( - ReactNativeMapboxGLView view, - double latS, double lonW, double latN, double lonE, - double paddingTop, double paddingRight, double paddingBottom, double paddingLeft, - boolean animated) { - CameraUpdate update = CameraUpdateFactory.newLatLngBounds( - new LatLngBounds.Builder() - .include(new LatLng(latS, lonW)) - .include(new LatLng(latN, lonE)) - .build(), - (int) paddingLeft, - (int) paddingTop, - (int) paddingRight, - (int) paddingBottom - ); - view.setCameraUpdate(update, animated ? MapboxConstants.ANIMATION_DURATION : 0, null); - } - - // Annotations - - public void spliceAnnotations(ReactNativeMapboxGLView view, boolean removeAll, ReadableArray itemsToRemove, ReadableArray itemsToAdd) { - if (removeAll) { - view.removeAllAnnotations(); - } else { - int removeCount = itemsToRemove.size(); - for (int i = 0; i < removeCount; i++) { - view.removeAnnotation(itemsToRemove.getString(i)); - } - } - - int addCount = itemsToAdd.size(); - for (int i = 0; i < addCount; i++) { - ReadableMap annotation = itemsToAdd.getMap(i); - RNMGLAnnotationOptions annotationOptions = RNMGLAnnotationOptionsFactory.annotationOptionsFromJS(annotation, view.getContext()); - - String name = annotation.getString("id"); - view.setAnnotation(name, annotationOptions); - } - } - - public void selectAnnotation(ReactNativeMapboxGLView view, String annotationId, boolean animated) { - view.selectAnnotation(annotationId, animated); - } - - public void deselectAnnotation(ReactNativeMapboxGLView view) { - view.deselectAnnotation(); - } -} diff --git a/android/src/main/java/com/mapbox/reactnativemapboxgl/ReactNativeMapboxGLView.java b/android/src/main/java/com/mapbox/reactnativemapboxgl/ReactNativeMapboxGLView.java deleted file mode 100644 index c5e9117..0000000 --- a/android/src/main/java/com/mapbox/reactnativemapboxgl/ReactNativeMapboxGLView.java +++ /dev/null @@ -1,835 +0,0 @@ -package com.mapbox.reactnativemapboxgl; - -import android.content.Context; -import android.graphics.PointF; -import android.hardware.GeomagneticField; -import android.location.Location; -import android.os.Handler; -import android.support.annotation.NonNull; -import android.support.annotation.UiThread; -import android.view.MotionEvent; -import android.view.View; -import android.view.ViewGroup; -import android.widget.FrameLayout; -import android.widget.RelativeLayout; - -import com.facebook.react.bridge.Arguments; -import com.facebook.react.bridge.LifecycleEventListener; -import com.facebook.react.bridge.ReactContext; -import com.facebook.react.bridge.WritableMap; -import com.facebook.react.touch.OnInterceptTouchEventListener; -import com.facebook.react.uimanager.events.RCTEventEmitter; -import com.mapbox.mapboxsdk.annotations.Annotation; -import com.mapbox.mapboxsdk.annotations.Marker; -import com.mapbox.mapboxsdk.annotations.MarkerView; -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.maps.MapView; -import com.mapbox.mapboxsdk.maps.MapboxMap; -import com.mapbox.mapboxsdk.maps.MapboxMapOptions; -import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; -import com.mapbox.mapboxsdk.maps.UiSettings; - -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import javax.annotation.Nullable; - -public class ReactNativeMapboxGLView extends RelativeLayout implements - OnMapReadyCallback, LifecycleEventListener, - MapboxMap.OnMapClickListener, MapboxMap.OnMapLongClickListener, - MapboxMap.OnMyBearingTrackingModeChangeListener, MapboxMap.OnMyLocationTrackingModeChangeListener, - MapboxMap.OnMyLocationChangeListener, - MapboxMap.OnMarkerClickListener, MapboxMap.OnInfoWindowClickListener, - MapView.OnMapChangedListener, ReactNativeMapboxGLManager.ChildListener -{ - - private MapboxMap _map = null; - private MapView _mapView = null; - private ReactNativeMapboxGLManager _manager; - private boolean _paused = false; - - private CameraPosition.Builder _initialCamera = new CameraPosition.Builder(); - private MapboxMapOptions _mapOptions; - private int _locationTrackingMode; - private int _bearingTrackingMode; - private boolean _trackingModeUpdateScheduled = false; - private boolean _showsUserLocation; - private boolean _annotationsPopUpEnabled = true; - private boolean _zoomEnabled = true; - private double _minimumZoomLevel = 0; - private double _maximumZoomLevel = 20; - private boolean _pitchEnabled = true; - private boolean _scrollEnabled = true; - private boolean _rotateEnabled = true; - private boolean _enableOnRegionWillChange = false; - private boolean _enableOnRegionDidChange = false; - private int _paddingTop, _paddingRight, _paddingBottom, _paddingLeft; - private boolean _recentlyChanged = false; - private boolean _willChangeThrottled = false; - private boolean _didChangeThrottled = false; - private boolean _changeWasAnimated = false; - - private Map _annotations = new HashMap<>(); - private Map _annotationIdsToName = new HashMap<>(); - private Map _annotationOptions = new HashMap<>(); - private Map _customAnnodationIds = new HashMap<>(); - private Map _customAnnotationViewMap = new HashMap<>(); - private Map _propertyListeners = new HashMap<>(); - - private Handler _handler; - - - @UiThread - public ReactNativeMapboxGLView(Context context, ReactNativeMapboxGLManager manager) { - super(context); - _handler = new android.os.Handler(); - _manager = manager; - _mapOptions = MapboxMapOptions.createFromAttributes(context, null); - _mapOptions.zoomGesturesEnabled(true); - _mapOptions.rotateGesturesEnabled(true); - _mapOptions.scrollGesturesEnabled(true); - _mapOptions.tiltGesturesEnabled(true); - } - - // Lifecycle methods - - public void onAfterUpdateTransaction() { - if (_mapView != null) { return; } - setupMapView(); - _paused = false; - _mapView.onStart(); - _mapView.onResume(); - _manager.getContext().addLifecycleEventListener(this); - } - - public void onDrop() { - if (_mapView == null) { return; } - _manager.getContext().removeLifecycleEventListener(this); - _manager.removeChildListener(this); - if (!_paused) { - _paused = true; - _mapView.onPause(); - _mapView.onStop(); - } - destroyMapView(); - _mapView = null; - } - - @Override - public void onHostResume() { - _paused = false; - _mapView.onStart(); - _mapView.onResume(); - } - - @Override - public void onHostPause() { - _paused = true; - _mapView.onPause(); - _mapView.onStop(); - } - - @Override - public void onHostDestroy() { - onDrop(); - } - - // Initialization - - private void setupMapView() { - _mapOptions.camera(_initialCamera.build()); - _mapView = new MapView(this.getContext(), _mapOptions); - _manager.addView(this, _mapView, 0); - _mapView.addOnMapChangedListener(this); - _mapView.onCreate(null); - _mapView.getMapAsync(this); - } - - @Override - public void onMapReady(MapboxMap mapboxMap) { - if (_mapView == null) { return; } - _map = mapboxMap; - - // Configure map - _map.setMyLocationEnabled(_showsUserLocation); - _map.getTrackingSettings().setMyLocationTrackingMode(_locationTrackingMode); - _map.getTrackingSettings().setMyBearingTrackingMode(_bearingTrackingMode); - _map.setPadding(_paddingLeft, _paddingTop, _paddingRight, _paddingBottom); - _map.setMinZoomPreference(_minimumZoomLevel); - _map.setMaxZoomPreference(_maximumZoomLevel); - - UiSettings uiSettings = _map.getUiSettings(); - uiSettings.setZoomGesturesEnabled(_zoomEnabled); - uiSettings.setScrollGesturesEnabled(_scrollEnabled); - uiSettings.setRotateGesturesEnabled(_rotateEnabled); - uiSettings.setTiltGesturesEnabled(_pitchEnabled); - - // If these settings changed between setupMapView() and onMapReady(), coerce them to their right values - // This doesn't happen in the current implementation of MapView, but let's be future proof - if (_map.isDebugActive() != _mapOptions.getDebugActive()) { - _map.setDebugActive(_mapOptions.getDebugActive()); - } - if (!_map.getStyleUrl().equals(_mapOptions.getStyle())) { - _map.setStyleUrl(_mapOptions.getStyle()); - } - if (uiSettings.isLogoEnabled() != _mapOptions.getLogoEnabled()) { - uiSettings.setLogoEnabled(_mapOptions.getLogoEnabled()); - } - if (uiSettings.isAttributionEnabled() != _mapOptions.getAttributionEnabled()) { - uiSettings.setAttributionEnabled(_mapOptions.getAttributionEnabled()); - } - if (uiSettings.isCompassEnabled() != _mapOptions.getCompassEnabled()) { - uiSettings.setCompassEnabled(_mapOptions.getCompassEnabled()); - } - - // Attach listeners - _map.setOnMapClickListener(this); - _map.setOnMapLongClickListener(this); - _map.setOnMyLocationTrackingModeChangeListener(this); - _map.setOnMyBearingTrackingModeChangeListener(this); - _map.setOnMyLocationChangeListener(this); - _map.setOnMarkerClickListener(this); - _map.setOnInfoWindowClickListener(this); - - // Create annotations - for (Map.Entry entry : _annotationOptions.entrySet()) { - Annotation annotation = entry.getValue().addToMap(_map); - _annotations.put(entry.getKey(), annotation); - _annotationIdsToName.put(annotation.getId(), entry.getKey()); - } - - _annotationOptions.clear(); - - _map.getMarkerViewManager().addMarkerViewAdapter( - new RNMGLCustomMarkerViewAdapter(getContext())); - } - - private void destroyMapView() { - _mapView.removeOnMapChangedListener(this); - if (_map != null) { - _map.setOnMapClickListener(null); - _map.setOnMapLongClickListener(null); - _map.setOnMyLocationTrackingModeChangeListener(null); - _map.setOnMyBearingTrackingModeChangeListener(null); - _map.setOnMyLocationChangeListener(null); - _map.setOnMarkerClickListener(null); - _map.setOnInfoWindowClickListener(null); - _map = null; - } - _mapView.onDestroy(); - } - - // Children - - @Override - public void childAdded(View child) { - if (child instanceof RNMGLAnnotationView) { - updateMarkerAnnotations(); - } - } - - @Override - public void childRemoved(View child) { - if (child instanceof RNMGLAnnotationView) { - updateMarkerAnnotations(); - } - } - - private void updateMarkerAnnotations() { - Set newAnnotationViews = new HashSet<>(_manager.getAnnotationViews(this)); - Set currentViews = new HashSet<>(_customAnnotationViewMap.values()); - Collection addedChildren = Utils.difference(newAnnotationViews, currentViews); - Collection removedChildren = Utils.difference(currentViews, newAnnotationViews); - - for (RNMGLAnnotationView annotationView : removedChildren) { - annotationView.removePropertyListener(_propertyListeners.get(annotationView)); - _customAnnotationViewMap.remove(annotationView.getAnnotationId()); - MarkerView markerView = _customAnnodationIds.remove(annotationView.getAnnotationId()); - _map.removeMarker(markerView); - } - - for (RNMGLAnnotationView annotationView : addedChildren) { - _customAnnotationViewMap.put(annotationView.getAnnotationId(), annotationView); - RNMGLCustomMarkerViewOptions options = new RNMGLCustomMarkerViewOptions() - .annotationId(annotationView.getAnnotationId()) - .position(annotationView.getCoordinate()) - .anchor(0.5f, 0.5f) - .flat(true); - final MarkerView markerView = _map.addMarker(options); - _customAnnodationIds.put(annotationView.getAnnotationId(), markerView); - _annotationIdsToName.put(markerView.getId(), annotationView.getAnnotationId()); - RNMGLAnnotationView.PropertyListener propertyListener = new RNMGLAnnotationView.PropertyListener() { - @Override - public void propertiesUpdated(RNMGLAnnotationView view) { - markerView.setPosition(view.getCoordinate()); - } - }; - annotationView.addPropertyListener(propertyListener); - _propertyListeners.put(annotationView, propertyListener); - } - - relayout(); - } - - private void relayout() { - // Need a relayout to show custom marker views - _handler.post(new Runnable() { - @Override - public void run() { - if(_mapView != null) { - _mapView.measure( - View.MeasureSpec.makeMeasureSpec(_mapView.getMeasuredWidth(), View.MeasureSpec.EXACTLY), - View.MeasureSpec.makeMeasureSpec(_mapView.getMeasuredHeight(), View.MeasureSpec.EXACTLY)); - _mapView.layout(_mapView.getLeft(), _mapView.getTop(), _mapView.getRight(), _mapView.getBottom()); - } - } - }); - } - - // Props - - public void setInitialZoomLevel(double value) { - _initialCamera.zoom(value); - } - - public void setInitialDirection(double value) { - _initialCamera.bearing(value); - } - - public void setInitialCenterCoordinate(double lat, double lon) { - _initialCamera.target(new LatLng(lat, lon)); - } - - public void setEnableOnRegionDidChange(boolean value) { - _enableOnRegionDidChange = value; - } - - public void setEnableOnRegionWillChange(boolean value) { - _enableOnRegionWillChange = value; - } - - public void setShowsUserLocation(boolean value) { - if (_showsUserLocation == value) { return; } - _showsUserLocation = value; - if (_map != null) { _map.setMyLocationEnabled(value); } - } - - public void setRotateEnabled(boolean value) { - if (_rotateEnabled == value) { return; } - _rotateEnabled = value; - if (_map != null) { - _map.getUiSettings().setRotateGesturesEnabled(value); - } - } - - public void setScrollEnabled(boolean value) { - if (_scrollEnabled == value) { return; } - _scrollEnabled = value; - if (_map != null) { - _map.getUiSettings().setScrollGesturesEnabled(value); - } - } - - public void setZoomEnabled(boolean value) { - if (_zoomEnabled == value) { return; } - _zoomEnabled = value; - if (_map != null) { - _map.getUiSettings().setZoomGesturesEnabled(value); - } - } - - public void setMinimumZoomLevel(double value) { - if (_minimumZoomLevel == value) { return; } - _minimumZoomLevel = value; - if (_map != null) { - _map.setMinZoomPreference(value); - } - } - - public void setMaximumZoomLevel(double value) { - if (_maximumZoomLevel == value) { return; } - _maximumZoomLevel = value; - if (_map != null) { - _map.setMaxZoomPreference(value); - } - } - - public void setPitchEnabled(boolean value) { - if (_pitchEnabled == value) { return; } - _pitchEnabled = value; - if (_map != null) { - _map.getUiSettings().setTiltGesturesEnabled(value); - } - } - - public void setAnnotationsPopUpEnabled(boolean value) { - _annotationsPopUpEnabled = value; - } - - public void setStyleURL(String styleURL) { - if (styleURL.equals(_mapOptions.getStyle())) { return; } - _mapOptions.styleUrl(styleURL); - if (_map != null) { _map.setStyleUrl(styleURL); } - } - - public void setDebugActive(boolean value) { - if (_mapOptions.getDebugActive() == value) { return; } - _mapOptions.debugActive(value); - if (_map != null) { _map.setDebugActive(value); } - } - - public void setLocationTracking(int value) { - if (_locationTrackingMode == value) { return; } - _locationTrackingMode = value; - if (_map != null) { _map.getTrackingSettings().setMyLocationTrackingMode(value); } - } - - public void setBearingTracking(int value) { - if (_bearingTrackingMode == value) { return; } - _bearingTrackingMode = value; - if (_map != null) { _map.getTrackingSettings().setMyBearingTrackingMode(value); } - } - - public void setAttributionButtonIsHidden(boolean value) { - if (_mapOptions.getAttributionEnabled() == !value) { return; } - _mapOptions.attributionEnabled(!value); - if (_map != null) { - _map.getUiSettings().setAttributionEnabled(!value); - } - } - - public void setLogoIsHidden(boolean value) { - if (_mapOptions.getLogoEnabled() == !value) { return; } - _mapOptions.logoEnabled(!value); - if (_map != null) { - _map.getUiSettings().setLogoEnabled(!value); - } - } - - public void setCompassIsHidden(boolean value) { - if (_mapOptions.getCompassEnabled() == !value) { return; } - _mapOptions.compassEnabled(!value); - if (_map != null) { - _map.getUiSettings().setCompassEnabled(!value); - } - } - - public void setContentInset(int top, int right, int bottom, int left) { - if (top == _paddingTop && - bottom == _paddingBottom && - left == _paddingLeft && - right == _paddingRight) { return; } - _paddingTop = top; - _paddingRight = right; - _paddingBottom = bottom; - _paddingLeft = left; - if (_map != null) { _map.setPadding(left, top, right, bottom); } - } - - // Events - - void emitEvent(String name, @Nullable WritableMap event) { - if (event == null) { - event = Arguments.createMap(); - } - ((ReactContext)getContext()) - .getJSModule(RCTEventEmitter.class) - .receiveEvent(getId(), name, event); - } - - WritableMap serializePoint(LatLng point) { - PointF screenCoords = _map.getProjection().toScreenLocation(point); - - WritableMap event = Arguments.createMap(); - WritableMap src = Arguments.createMap(); - src.putDouble("latitude", point.getLatitude()); - src.putDouble("longitude", point.getLongitude()); - src.putDouble("screenCoordX", screenCoords.x); - src.putDouble("screenCoordY", screenCoords.y); - event.putMap("src", src); - return event; - } - - @Override - public void onMapClick(LatLng point) { - emitEvent(ReactNativeMapboxGLEventTypes.ON_TAP, serializePoint(point)); - } - - @Override - public void onMapLongClick(@NonNull LatLng point) { - emitEvent(ReactNativeMapboxGLEventTypes.ON_LONG_PRESS, serializePoint(point)); - } - - @Override - public void onMyLocationChange(@Nullable Location location) { - WritableMap event = Arguments.createMap(); - WritableMap src = Arguments.createMap(); - - if (location == null) { - src.putString("message", "Could not get user location"); - event.putMap("src", src); - emitEvent(ReactNativeMapboxGLEventTypes.ON_LOCATE_USER_FAILED, event); - return; - } - - src.putDouble("latitude", location.getLatitude()); - src.putDouble("longitude", location.getLongitude()); - - if (location.hasAccuracy()) { - src.putDouble("verticalAccuracy", location.getAccuracy()); - src.putDouble("horizontalAccuracy", location.getAccuracy()); - } - - GeomagneticField geoField = new GeomagneticField( - (float)location.getLatitude(), - (float)location.getLongitude(), - location.hasAltitude() ? (float)location.getAltitude() : 0.0f, - System.currentTimeMillis() - ); - - src.putDouble("magneticHeading", location.getBearing()); - src.putDouble("trueHeading", location.getBearing() + geoField.getDeclination()); - - event.putMap("src", src); - emitEvent(ReactNativeMapboxGLEventTypes.ON_UPDATE_USER_LOCATION, event); - } - - class TrackingModeChangeRunnable implements Runnable { - ReactNativeMapboxGLView target; - TrackingModeChangeRunnable(ReactNativeMapboxGLView target) { - this.target = target; - } - @Override - public void run() { - target.onTrackingModeChange(); - } - } - - public void onTrackingModeChange() { - if (!_trackingModeUpdateScheduled) { return; } - _trackingModeUpdateScheduled = false; - - for (int mode = 0; mode < ReactNativeMapboxGLModule.locationTrackingModes.length; mode++) { - if (_locationTrackingMode == ReactNativeMapboxGLModule.locationTrackingModes[mode] && - _bearingTrackingMode == ReactNativeMapboxGLModule.bearingTrackingModes[mode]) { - WritableMap event = Arguments.createMap(); - event.putInt("src", mode); - emitEvent(ReactNativeMapboxGLEventTypes.ON_CHANGE_USER_TRACKING_MODE, event); - break; - } - } - } - - @Override - @UiThread - public void onMyBearingTrackingModeChange(int myBearingTrackingMode) { - if (_bearingTrackingMode == myBearingTrackingMode) { return; } - _bearingTrackingMode = myBearingTrackingMode; - _trackingModeUpdateScheduled = true; - _handler.post(new TrackingModeChangeRunnable(this)); - - } - - @Override - @UiThread - public void onMyLocationTrackingModeChange(int myLocationTrackingMode) { - if (_locationTrackingMode == myLocationTrackingMode) { return; } - _locationTrackingMode = myLocationTrackingMode; - _trackingModeUpdateScheduled = true; - _handler.post(new TrackingModeChangeRunnable(this)); - } - - WritableMap serializeCurrentRegion(boolean animated) { - CameraPosition camera = _map == null - ? _initialCamera.build() - : _map.getCameraPosition(); - - WritableMap event = Arguments.createMap(); - WritableMap src = Arguments.createMap(); - src.putDouble("longitude", camera.target.getLongitude()); - src.putDouble("latitude", camera.target.getLatitude()); - src.putDouble("zoomLevel", camera.zoom); - src.putDouble("direction", camera.bearing); - src.putDouble("pitch", camera.tilt); - src.putBoolean("animated", animated); - event.putMap("src", src); - return event; - } - - class RegionChangedThrottleRunnable implements Runnable { - ReactNativeMapboxGLView target; - RegionChangedThrottleRunnable(ReactNativeMapboxGLView target) { - this.target = target; - } - @Override - public void run() { - target.flushRegionChangedThrottle(true); - } - } - - private void flushRegionChangedThrottle(boolean fireAgain) { - _recentlyChanged = false; - if (_willChangeThrottled) { - emitEvent(ReactNativeMapboxGLEventTypes.ON_REGION_WILL_CHANGE, serializeCurrentRegion(_changeWasAnimated)); - } - if (_didChangeThrottled) { - emitEvent(ReactNativeMapboxGLEventTypes.ON_REGION_DID_CHANGE, serializeCurrentRegion(_changeWasAnimated)); - } - - if (fireAgain && _didChangeThrottled) { - _recentlyChanged = true; - _handler.postDelayed(new RegionChangedThrottleRunnable(this), 100); - } - _willChangeThrottled = false; - _didChangeThrottled = false; - } - - private void onRegionWillChange(boolean animated) { - if (animated) { - flushRegionChangedThrottle(false); - } - - if (_recentlyChanged) { - _willChangeThrottled = true; - _changeWasAnimated = animated; - } else { - emitEvent(ReactNativeMapboxGLEventTypes.ON_REGION_WILL_CHANGE, serializeCurrentRegion(animated)); - } - } - - private void onRegionDidChange(boolean animated) { - if (animated) { - flushRegionChangedThrottle(false); - } - - if (_recentlyChanged) { - _didChangeThrottled = true; - _changeWasAnimated = animated; - } else { - emitEvent(ReactNativeMapboxGLEventTypes.ON_REGION_DID_CHANGE, serializeCurrentRegion(animated)); - _recentlyChanged = true; - _handler.postDelayed(new RegionChangedThrottleRunnable(this), 100); - } - } - - @Override - public void onMapChanged(int change) { - switch (change) { - case MapView.REGION_WILL_CHANGE: - case MapView.REGION_WILL_CHANGE_ANIMATED: - if (_enableOnRegionWillChange) { - onRegionWillChange(change == MapView.REGION_WILL_CHANGE_ANIMATED); - } - break; - case MapView.REGION_DID_CHANGE: - case MapView.REGION_DID_CHANGE_ANIMATED: - if (_enableOnRegionDidChange) { - onRegionDidChange(change == MapView.REGION_DID_CHANGE_ANIMATED); - } - break; - case MapView.WILL_START_LOADING_MAP: - _manager.removeChildListener(this); - emitEvent(ReactNativeMapboxGLEventTypes.ON_START_LOADING_MAP, null); - break; - case MapView.DID_FINISH_LOADING_MAP: - _manager.addChildListener(this); - updateMarkerAnnotations(); - emitEvent(ReactNativeMapboxGLEventTypes.ON_FINISH_LOADING_MAP, null); - break; - } - } - - WritableMap serializeMarker(Marker marker) { - WritableMap event = Arguments.createMap(); - WritableMap src = Arguments.createMap(); - - src.putString("id", _annotationIdsToName.get(marker.getId())); - src.putDouble("longitude", marker.getPosition().getLongitude()); - src.putDouble("latitude", marker.getPosition().getLatitude()); - src.putString("title", marker.getTitle()); - src.putString("subtitle", marker.getSnippet()); - - event.putMap("src", src); - return event; - } - - @Override - public boolean onInfoWindowClick(@NonNull Marker marker) { - emitEvent(ReactNativeMapboxGLEventTypes.ON_RIGHT_ANNOTATION_TAPPED, serializeMarker(marker)); - return false; - } - - @Override - public boolean onMarkerClick(@NonNull Marker marker) { - emitEvent(ReactNativeMapboxGLEventTypes.ON_OPEN_ANNOTATION, serializeMarker(marker)); - - if (_annotationsPopUpEnabled == false) { return true; } - - relayout(); - - return false; - } - - // Getters - - public CameraPosition getCameraPosition() { - if (_map == null) { return _initialCamera.build(); } - return _map.getCameraPosition(); - } - - public LatLngBounds getBounds() { - if (_map == null) { return new LatLngBounds.Builder().build(); } - return _map.getProjection().getVisibleRegion().latLngBounds; - } - - // Camera setters - - public void setCameraPosition(CameraPosition position, int duration, @Nullable Runnable callback) { - if (_map == null) { - _initialCamera = new CameraPosition.Builder(position); - if (callback != null) { callback.run(); } - return; - } - - CameraUpdate update = CameraUpdateFactory.newCameraPosition(position); - setCameraUpdate(update, duration, callback); - } - - public void setCameraUpdate(CameraUpdate update, int duration, @Nullable Runnable callback) { - if (_map == null) { - return; - } - - if (duration == 0) { - _map.moveCamera(update); - if (callback != null) { callback.run(); } - } else { - // Ugh... Java callbacks suck - class CameraCallback implements MapboxMap.CancelableCallback { - Runnable callback; - CameraCallback(Runnable callback) { - this.callback = callback; - } - @Override - public void onCancel() { - if (callback != null) { callback.run(); } - } - @Override - public void onFinish() { - if (callback != null) { callback.run(); } - } - } - - _map.animateCamera(update, duration, new CameraCallback(callback)); - } - } - - // Annotations - - @Nullable Annotation _removeAnnotation(String name, boolean keep) { - if (_map == null) { - _annotationOptions.remove(name); - return null; - } - Annotation annotation = _annotations.remove(name); - if (annotation == null) { return null; } - _annotationIdsToName.remove(annotation.getId()); - - if (keep) { return annotation; } - _map.removeAnnotation(annotation); - return null; - } - - public void removeAnnotation(String name) { - _removeAnnotation(name, false); - } - - public void removeAllAnnotations() { - _annotationOptions.clear(); - _annotations.clear(); - _annotationIdsToName.clear(); - if (_map != null) { - _map.removeAnnotations(); - } - } - - public void setAnnotation(String name, RNMGLAnnotationOptions options) { - Annotation removed = _removeAnnotation(name, true); - - if (_map == null) { - _annotationOptions.put(name, options); - } else { - Annotation annotation = options.addToMap(_map); - _annotations.put(name, annotation); - _annotationIdsToName.put(annotation.getId(), name); - } - - if (removed != null) { _map.removeAnnotation(removed); } - } - - public void selectAnnotation(String name, boolean animated) { - if (_map == null) { return; } - Annotation annotation = _annotations.get(name); - if (annotation == null) { return; } - if (!(annotation instanceof Marker)) { return; } - Marker marker = (Marker)annotation; - _map.selectMarker(marker); - } - - public void deselectAnnotation() { - if (_map == null) { return; } - _map.deselectMarkers(); - } - - // Custom Marker View Adapter - Adapts a MarkerView to display an custom react native view. - - private class RNMGLCustomMarkerViewAdapter extends MapboxMap.MarkerViewAdapter { - - RNMGLCustomMarkerViewAdapter(@NonNull Context context) { - super(context); - } - - @Nullable - @Override - public View getView(@NonNull final RNMGLCustomMarkerView marker, @Nullable View convertView, @NonNull ViewGroup parent) { - RNMGLAnnotationView reactView = _customAnnotationViewMap.get(marker.getAnnotationId()); - if (reactView.getParent() != null) { - ViewGroup group = (ViewGroup) reactView.getParent(); - group.removeView(reactView); - } - int width = (int)reactView.getLayoutWidth(); - int height = (int)reactView.getLayoutHeight(); - ViewGroup.LayoutParams frameLayoutMeasurements = new FrameLayout.LayoutParams(width, height); - ViewGroup.LayoutParams viewGroupMeasurements = new ViewGroup.LayoutParams(width, height); - - FrameLayout layout; - if (convertView == null) { - layout = new FrameLayout(getContext()); - } else { - layout = (FrameLayout) convertView; - layout.removeAllViews(); - } - reactView.setLayoutParams(viewGroupMeasurements); - reactView.setOnInterceptTouchEventListener(new OnInterceptTouchEventListener() { - @Override - public boolean onInterceptTouchEvent(ViewGroup v, MotionEvent event) { - onMarkerClick(marker); - return true; - } - }); - layout.setLayoutParams(frameLayoutMeasurements); - layout.addView(reactView); - - relayout(); - - return layout; - } - } -} diff --git a/android/src/main/java/com/mapbox/reactnativemapboxgl/SizeReportingShadowNode.java b/android/src/main/java/com/mapbox/reactnativemapboxgl/SizeReportingShadowNode.java deleted file mode 100644 index e7d968f..0000000 --- a/android/src/main/java/com/mapbox/reactnativemapboxgl/SizeReportingShadowNode.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.mapbox.reactnativemapboxgl; - -import com.facebook.react.uimanager.LayoutShadowNode; -import com.facebook.react.uimanager.UIViewOperationQueue; - -import java.util.HashMap; -import java.util.Map; - -public class SizeReportingShadowNode extends LayoutShadowNode { - - @Override - public void onCollectExtraUpdates(UIViewOperationQueue uiViewOperationQueue) { - super.onCollectExtraUpdates(uiViewOperationQueue); - - Map data = new HashMap<>(); - data.put("width", getLayoutWidth()); - data.put("height", getLayoutHeight()); - - uiViewOperationQueue.enqueueUpdateExtraData(getReactTag(), data); - } -} diff --git a/ios/RCTMapboxGL.podspec b/ios/RCTMapboxGL.podspec deleted file mode 100644 index 6fb1ee2..0000000 --- a/ios/RCTMapboxGL.podspec +++ /dev/null @@ -1,19 +0,0 @@ -Pod::Spec.new do |s| - s.name = "RCTMapboxGL" - s.version = "5.1.0" - s.summary = "A Mapbox GL react native module for creating custom maps." - s.homepage = "https://github.com/mapbox/react-native-mapbox-gl#readme" - s.license = "BSD" - s.author = "Bobby Sudekum" - s.screenshot = "https://cldup.com/A8S_7rLg1L.png" - s.social_media_url = "https://twitter.com/mapbox" - s.documentation_url = "https://github.com/mapbox/react-native-mapbox-gl/blob/master/API.md" - - s.source = { :git => "https://github.com/mapbox/react-native-mapbox-gl.git", :tag => "#{s.version}" } - s.platform = :ios, "8.0" - - s.vendored_frameworks = 'Mapbox.framework' - s.module_name = 'Mapbox' - s.source_files = "RCTMapboxGL/*.{h,m}" - -end diff --git a/ios/RCTMapboxGL.xcodeproj/project.pbxproj b/ios/RCTMapboxGL.xcodeproj/project.pbxproj deleted file mode 100644 index 3727af8..0000000 --- a/ios/RCTMapboxGL.xcodeproj/project.pbxproj +++ /dev/null @@ -1,449 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 46; - objects = { - -/* Begin PBXBuildFile section */ - 874C0C441D9436D80034AF3F /* RCTMapboxAnnotation.m in Sources */ = {isa = PBXBuildFile; fileRef = 874C0C401D9436D80034AF3F /* RCTMapboxAnnotation.m */; }; - 874C0C451D9436D80034AF3F /* RCTMapboxAnnotationManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 874C0C421D9436D80034AF3F /* RCTMapboxAnnotationManager.m */; }; - C167F89C1D18112B007C7A42 /* RCTMapboxGLConversions.m in Sources */ = {isa = PBXBuildFile; fileRef = C167F89B1D18112B007C7A42 /* RCTMapboxGLConversions.m */; }; - C5DBB3441AF2EF2B00E611A9 /* RCTMapboxGL.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C5DBB3431AF2EF2B00E611A9 /* RCTMapboxGL.h */; }; - C5DBB3461AF2EF2B00E611A9 /* RCTMapboxGL.m in Sources */ = {isa = PBXBuildFile; fileRef = C5DBB3451AF2EF2B00E611A9 /* RCTMapboxGL.m */; }; - C5DBB34C1AF2EF2B00E611A9 /* libRCTMapboxGL.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C5DBB3401AF2EF2B00E611A9 /* libRCTMapboxGL.a */; }; - C5DBB3661AF2EFB500E611A9 /* RCTMapboxGLManager.m in Sources */ = {isa = PBXBuildFile; fileRef = C5DBB3651AF2EFB500E611A9 /* RCTMapboxGLManager.m */; }; - CB7CB11F1F5092CD30562E07 /* MGLPolyline+RCTAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = CB7CBE434C8597B1509C3FCA /* MGLPolyline+RCTAdditions.m */; }; - CB7CB49F42C4A55593F71A37 /* MGLPolygon+RCTAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = CB7CBC07803C0F5C28ECB201 /* MGLPolygon+RCTAdditions.m */; }; -/* End PBXBuildFile section */ - -/* Begin PBXContainerItemProxy section */ - C5DBB34D1AF2EF2B00E611A9 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = C5DBB3381AF2EF2B00E611A9 /* Project object */; - proxyType = 1; - remoteGlobalIDString = C5DBB33F1AF2EF2B00E611A9; - remoteInfo = RCTMapboxGL; - }; -/* End PBXContainerItemProxy section */ - -/* Begin PBXCopyFilesBuildPhase section */ - C5DBB33E1AF2EF2B00E611A9 /* CopyFiles */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 8; - dstPath = "include/$(PRODUCT_NAME)"; - dstSubfolderSpec = 16; - files = ( - C5DBB3441AF2EF2B00E611A9 /* RCTMapboxGL.h in CopyFiles */, - ); - runOnlyForDeploymentPostprocessing = 1; - }; -/* End PBXCopyFilesBuildPhase section */ - -/* Begin PBXFileReference section */ - 874C0C401D9436D80034AF3F /* RCTMapboxAnnotation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTMapboxAnnotation.m; sourceTree = ""; }; - 874C0C411D9436D80034AF3F /* RCTMapboxAnnotation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTMapboxAnnotation.h; sourceTree = ""; }; - 874C0C421D9436D80034AF3F /* RCTMapboxAnnotationManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTMapboxAnnotationManager.m; sourceTree = ""; }; - 874C0C431D9436D80034AF3F /* RCTMapboxAnnotationManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTMapboxAnnotationManager.h; sourceTree = ""; }; - C167F89A1D18111F007C7A42 /* RCTMapboxGLConversions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RCTMapboxGLConversions.h; sourceTree = ""; }; - C167F89B1D18112B007C7A42 /* RCTMapboxGLConversions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTMapboxGLConversions.m; sourceTree = ""; }; - C5DBB3401AF2EF2B00E611A9 /* libRCTMapboxGL.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRCTMapboxGL.a; sourceTree = BUILT_PRODUCTS_DIR; }; - C5DBB3431AF2EF2B00E611A9 /* RCTMapboxGL.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RCTMapboxGL.h; sourceTree = ""; }; - C5DBB3451AF2EF2B00E611A9 /* RCTMapboxGL.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RCTMapboxGL.m; sourceTree = ""; }; - C5DBB34B1AF2EF2B00E611A9 /* RCTMapboxGLTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RCTMapboxGLTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - C5DBB3511AF2EF2B00E611A9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - C5DBB3641AF2EFB500E611A9 /* RCTMapboxGLManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTMapboxGLManager.h; sourceTree = ""; }; - C5DBB3651AF2EFB500E611A9 /* RCTMapboxGLManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTMapboxGLManager.m; sourceTree = ""; }; - CB7CB655DADBFA72D7B5EB33 /* MGLPolygon+RCTAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MGLPolygon+RCTAdditions.h"; sourceTree = ""; }; - CB7CBC07803C0F5C28ECB201 /* MGLPolygon+RCTAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "MGLPolygon+RCTAdditions.m"; sourceTree = ""; }; - CB7CBC3A586F235841D94946 /* MGLPolyline+RCTAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MGLPolyline+RCTAdditions.h"; sourceTree = ""; }; - CB7CBE434C8597B1509C3FCA /* MGLPolyline+RCTAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "MGLPolyline+RCTAdditions.m"; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - C5DBB33D1AF2EF2B00E611A9 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - C5DBB3481AF2EF2B00E611A9 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - C5DBB34C1AF2EF2B00E611A9 /* libRCTMapboxGL.a in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - C5DBB3371AF2EF2B00E611A9 = { - isa = PBXGroup; - children = ( - C5DBB3421AF2EF2B00E611A9 /* RCTMapboxGL */, - C5DBB34F1AF2EF2B00E611A9 /* RCTMapboxGLTests */, - C5DBB3411AF2EF2B00E611A9 /* Products */, - ); - sourceTree = ""; - }; - C5DBB3411AF2EF2B00E611A9 /* Products */ = { - isa = PBXGroup; - children = ( - C5DBB3401AF2EF2B00E611A9 /* libRCTMapboxGL.a */, - C5DBB34B1AF2EF2B00E611A9 /* RCTMapboxGLTests.xctest */, - ); - name = Products; - sourceTree = ""; - }; - C5DBB3421AF2EF2B00E611A9 /* RCTMapboxGL */ = { - isa = PBXGroup; - children = ( - 874C0C401D9436D80034AF3F /* RCTMapboxAnnotation.m */, - 874C0C411D9436D80034AF3F /* RCTMapboxAnnotation.h */, - 874C0C421D9436D80034AF3F /* RCTMapboxAnnotationManager.m */, - 874C0C431D9436D80034AF3F /* RCTMapboxAnnotationManager.h */, - C5DBB3431AF2EF2B00E611A9 /* RCTMapboxGL.h */, - C5DBB3451AF2EF2B00E611A9 /* RCTMapboxGL.m */, - C5DBB3641AF2EFB500E611A9 /* RCTMapboxGLManager.h */, - C5DBB3651AF2EFB500E611A9 /* RCTMapboxGLManager.m */, - C167F89A1D18111F007C7A42 /* RCTMapboxGLConversions.h */, - C167F89B1D18112B007C7A42 /* RCTMapboxGLConversions.m */, - CB7CBE434C8597B1509C3FCA /* MGLPolyline+RCTAdditions.m */, - CB7CBC3A586F235841D94946 /* MGLPolyline+RCTAdditions.h */, - CB7CBC07803C0F5C28ECB201 /* MGLPolygon+RCTAdditions.m */, - CB7CB655DADBFA72D7B5EB33 /* MGLPolygon+RCTAdditions.h */, - ); - path = RCTMapboxGL; - sourceTree = ""; - }; - C5DBB34F1AF2EF2B00E611A9 /* RCTMapboxGLTests */ = { - isa = PBXGroup; - children = ( - C5DBB3501AF2EF2B00E611A9 /* Supporting Files */, - ); - path = RCTMapboxGLTests; - sourceTree = ""; - }; - C5DBB3501AF2EF2B00E611A9 /* Supporting Files */ = { - isa = PBXGroup; - children = ( - C5DBB3511AF2EF2B00E611A9 /* Info.plist */, - ); - name = "Supporting Files"; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - C5DBB33F1AF2EF2B00E611A9 /* RCTMapboxGL */ = { - isa = PBXNativeTarget; - buildConfigurationList = C5DBB3541AF2EF2B00E611A9 /* Build configuration list for PBXNativeTarget "RCTMapboxGL" */; - buildPhases = ( - C5DBB33C1AF2EF2B00E611A9 /* Sources */, - C5DBB33D1AF2EF2B00E611A9 /* Frameworks */, - C5DBB33E1AF2EF2B00E611A9 /* CopyFiles */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = RCTMapboxGL; - productName = RCTMapboxGL; - productReference = C5DBB3401AF2EF2B00E611A9 /* libRCTMapboxGL.a */; - productType = "com.apple.product-type.library.static"; - }; - C5DBB34A1AF2EF2B00E611A9 /* RCTMapboxGLTests */ = { - isa = PBXNativeTarget; - buildConfigurationList = C5DBB3571AF2EF2B00E611A9 /* Build configuration list for PBXNativeTarget "RCTMapboxGLTests" */; - buildPhases = ( - C5DBB3471AF2EF2B00E611A9 /* Sources */, - C5DBB3481AF2EF2B00E611A9 /* Frameworks */, - C5DBB3491AF2EF2B00E611A9 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - C5DBB34E1AF2EF2B00E611A9 /* PBXTargetDependency */, - ); - name = RCTMapboxGLTests; - productName = RCTMapboxGLTests; - productReference = C5DBB34B1AF2EF2B00E611A9 /* RCTMapboxGLTests.xctest */; - productType = "com.apple.product-type.bundle.unit-test"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - C5DBB3381AF2EF2B00E611A9 /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 0630; - ORGANIZATIONNAME = Mapbox; - TargetAttributes = { - C5DBB33F1AF2EF2B00E611A9 = { - CreatedOnToolsVersion = 6.3.1; - }; - C5DBB34A1AF2EF2B00E611A9 = { - CreatedOnToolsVersion = 6.3.1; - }; - }; - }; - buildConfigurationList = C5DBB33B1AF2EF2B00E611A9 /* Build configuration list for PBXProject "RCTMapboxGL" */; - compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; - hasScannedForEncodings = 0; - knownRegions = ( - en, - ); - mainGroup = C5DBB3371AF2EF2B00E611A9; - productRefGroup = C5DBB3411AF2EF2B00E611A9 /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - C5DBB33F1AF2EF2B00E611A9 /* RCTMapboxGL */, - C5DBB34A1AF2EF2B00E611A9 /* RCTMapboxGLTests */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - C5DBB3491AF2EF2B00E611A9 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - C5DBB33C1AF2EF2B00E611A9 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - C5DBB3461AF2EF2B00E611A9 /* RCTMapboxGL.m in Sources */, - C5DBB3661AF2EFB500E611A9 /* RCTMapboxGLManager.m in Sources */, - C167F89C1D18112B007C7A42 /* RCTMapboxGLConversions.m in Sources */, - 874C0C451D9436D80034AF3F /* RCTMapboxAnnotationManager.m in Sources */, - 874C0C441D9436D80034AF3F /* RCTMapboxAnnotation.m in Sources */, - CB7CB11F1F5092CD30562E07 /* MGLPolyline+RCTAdditions.m in Sources */, - CB7CB49F42C4A55593F71A37 /* MGLPolygon+RCTAdditions.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - C5DBB3471AF2EF2B00E611A9 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXTargetDependency section */ - C5DBB34E1AF2EF2B00E611A9 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = C5DBB33F1AF2EF2B00E611A9 /* RCTMapboxGL */; - targetProxy = C5DBB34D1AF2EF2B00E611A9 /* PBXContainerItemProxy */; - }; -/* End PBXTargetDependency section */ - -/* Begin XCBuildConfiguration section */ - C5DBB3521AF2EF2B00E611A9 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_BITCODE = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_SYMBOLS_PRIVATE_EXTERN = NO; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; - MTL_ENABLE_DEBUG_INFO = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; - }; - name = Debug; - }; - C5DBB3531AF2EF2B00E611A9 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_BITCODE = NO; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; - MTL_ENABLE_DEBUG_INFO = NO; - SDKROOT = iphoneos; - VALIDATE_PRODUCT = YES; - }; - name = Release; - }; - C5DBB3551AF2EF2B00E611A9 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ENABLE_BITCODE = YES; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)", - ); - HEADER_SEARCH_PATHS = ( - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../node_modules/react-native/React/**", - "$(SRCROOT)/../../../React/**", - "$(SRCROOT)/../../react-native/React/**", - ); - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "/Users/bobby/Downloads/mapbox-gl-ios-0.2.17", - "$(PROJECT_DIR)/RCTMapboxGL", - ); - OTHER_LDFLAGS = "-ObjC"; - PRODUCT_NAME = "$(TARGET_NAME)"; - SKIP_INSTALL = YES; - }; - name = Debug; - }; - C5DBB3561AF2EF2B00E611A9 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ENABLE_BITCODE = YES; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)", - ); - HEADER_SEARCH_PATHS = ( - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../node_modules/react-native/React/**", - "$(SRCROOT)/../../../React/**", - "$(SRCROOT)/../../react-native/React/**", - ); - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "/Users/bobby/Downloads/mapbox-gl-ios-0.2.17", - "$(PROJECT_DIR)/RCTMapboxGL", - ); - OTHER_LDFLAGS = "-ObjC"; - PRODUCT_NAME = "$(TARGET_NAME)"; - SKIP_INSTALL = YES; - }; - name = Release; - }; - C5DBB3581AF2EF2B00E611A9 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - FRAMEWORK_SEARCH_PATHS = ( - "$(SDKROOT)/Developer/Library/Frameworks", - "$(inherited)", - ); - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - INFOPLIST_FILE = RCTMapboxGLTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Debug; - }; - C5DBB3591AF2EF2B00E611A9 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - FRAMEWORK_SEARCH_PATHS = ( - "$(SDKROOT)/Developer/Library/Frameworks", - "$(inherited)", - ); - INFOPLIST_FILE = RCTMapboxGLTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - C5DBB33B1AF2EF2B00E611A9 /* Build configuration list for PBXProject "RCTMapboxGL" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - C5DBB3521AF2EF2B00E611A9 /* Debug */, - C5DBB3531AF2EF2B00E611A9 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - C5DBB3541AF2EF2B00E611A9 /* Build configuration list for PBXNativeTarget "RCTMapboxGL" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - C5DBB3551AF2EF2B00E611A9 /* Debug */, - C5DBB3561AF2EF2B00E611A9 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - C5DBB3571AF2EF2B00E611A9 /* Build configuration list for PBXNativeTarget "RCTMapboxGLTests" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - C5DBB3581AF2EF2B00E611A9 /* Debug */, - C5DBB3591AF2EF2B00E611A9 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = C5DBB3381AF2EF2B00E611A9 /* Project object */; -} diff --git a/ios/RCTMapboxGL/MGLPolygon+RCTAdditions.h b/ios/RCTMapboxGL/MGLPolygon+RCTAdditions.h deleted file mode 100644 index 9390b03..0000000 --- a/ios/RCTMapboxGL/MGLPolygon+RCTAdditions.h +++ /dev/null @@ -1,10 +0,0 @@ -// -// Copyright (c) 2016 Mapbox. All rights reserved. -// - -#import -#import - -@interface MGLPolygon (RCTAdditions) -- (NSMutableArray *)coordinateArray; -@end \ No newline at end of file diff --git a/ios/RCTMapboxGL/MGLPolygon+RCTAdditions.m b/ios/RCTMapboxGL/MGLPolygon+RCTAdditions.m deleted file mode 100644 index 8004f40..0000000 --- a/ios/RCTMapboxGL/MGLPolygon+RCTAdditions.m +++ /dev/null @@ -1,31 +0,0 @@ -// -// Copyright (c) 2016 Mapbox. All rights reserved. -// - -#import "MGLPolygon+RCTAdditions.h" - - -@implementation MGLPolygon (RCTAdditions) - -- (NSMutableArray *)coordinateArray -{ - NSMutableArray *coordinates = [[NSMutableArray alloc] init]; - - NSMutableArray *outerRingCoordinates = [[NSMutableArray alloc] init]; - for (int index = 0; index < self.pointCount; index++) { - CLLocationCoordinate2D coord = self.coordinates[index]; - [outerRingCoordinates addObject:@[@(coord.longitude), @(coord.latitude)]]; - } - [coordinates addObject:outerRingCoordinates]; - - for (MGLPolygon *interiorRing in self.interiorPolygons) { - NSMutableArray *interiorRingCoordinates = [[NSMutableArray alloc] init]; - for (int index = 0; index < interiorRing.pointCount; index++) { - CLLocationCoordinate2D coord = interiorRing.coordinates[index]; - [interiorRingCoordinates addObject:@[@(coord.longitude), @(coord.latitude)]]; - } - [coordinates addObject:interiorRingCoordinates]; - } - return coordinates; -} -@end \ No newline at end of file diff --git a/ios/RCTMapboxGL/MGLPolyline+RCTAdditions.h b/ios/RCTMapboxGL/MGLPolyline+RCTAdditions.h deleted file mode 100644 index 133bb09..0000000 --- a/ios/RCTMapboxGL/MGLPolyline+RCTAdditions.h +++ /dev/null @@ -1,10 +0,0 @@ -// -// Copyright (c) 2016 Mapbox. All rights reserved. -// - -#import -#import - -@interface MGLPolyline (RCTAdditions) -- (NSMutableArray *)coordinateArray; -@end \ No newline at end of file diff --git a/ios/RCTMapboxGL/MGLPolyline+RCTAdditions.m b/ios/RCTMapboxGL/MGLPolyline+RCTAdditions.m deleted file mode 100644 index 00252d2..0000000 --- a/ios/RCTMapboxGL/MGLPolyline+RCTAdditions.m +++ /dev/null @@ -1,20 +0,0 @@ -// -// Copyright (c) 2016 Mapbox. All rights reserved. -// - -#import "MGLPolyline+RCTAdditions.h" - - -@implementation MGLPolyline (RCTAdditions) - -- (NSMutableArray *)coordinateArray -{ - NSMutableArray *coordinates = [[NSMutableArray alloc] init]; - for (int index = 0; index < self.pointCount; index++) { - CLLocationCoordinate2D coord = self.coordinates[index]; - [coordinates addObject:@[@(coord.longitude), @(coord.latitude)]]; - } - return coordinates; -} - -@end \ No newline at end of file diff --git a/ios/RCTMapboxGL/RCTMapboxAnnotation.h b/ios/RCTMapboxGL/RCTMapboxAnnotation.h deleted file mode 100644 index 978c46c..0000000 --- a/ios/RCTMapboxGL/RCTMapboxAnnotation.h +++ /dev/null @@ -1,50 +0,0 @@ -#import "RCTMapboxAnnotation.h" - -#import -#import - -#import -#import -#import "RCTMapboxGL.h" - -@class RCTBridge; - -@interface RCTMapboxAnnotation : MGLAnnotationView - -@property (nonatomic, weak, nullable) RCTMapboxGL *map; -@property (nonatomic, weak, nullable) RCTBridge *bridge; -/** - The center point (specified as a map coordinate) of the annotation. (required) - (read-only) - */ -@property (nonatomic) CLLocationCoordinate2D coordinate; - -/** - The string containing the annotation’s title. - - Although this property is optional, if you support the selection of annotations - in your map view, you are expected to provide this property. This string is - displayed in the callout for the associated annotation. - */ -@property (nonatomic, copy, nullable) NSString *id; - -/** - The string containing the annotation’s title. - - Although this property is optional, if you support the selection of annotations - in your map view, you are expected to provide this property. This string is - displayed in the callout for the associated annotation. - */ -@property (nonatomic, copy, nullable) NSString *title; - -/** - The string containing the annotation’s subtitle. - - This string is displayed in the callout for the associated annotation. - */ -@property (nonatomic, copy, nullable) NSString *subtitle; - - -@end - - diff --git a/ios/RCTMapboxGL/RCTMapboxAnnotation.m b/ios/RCTMapboxGL/RCTMapboxAnnotation.m deleted file mode 100644 index d853a3a..0000000 --- a/ios/RCTMapboxGL/RCTMapboxAnnotation.m +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -#import "RCTMapboxAnnotation.h" - -#import -#import -#import -#import - -@implementation RCTMapboxAnnotation { -} - --(NSString *)reuseIdentifier { - return self.id; -} - --(void)layoutSubviews { - [super layoutSubviews]; - [self.map restoreAnnotationPosition:self.id]; -} - - -@end diff --git a/ios/RCTMapboxGL/RCTMapboxAnnotationManager.h b/ios/RCTMapboxGL/RCTMapboxAnnotationManager.h deleted file mode 100644 index 819cfa6..0000000 --- a/ios/RCTMapboxGL/RCTMapboxAnnotationManager.h +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -#import - -@interface RCTMapboxAnnotationManager : RCTViewManager - -@end diff --git a/ios/RCTMapboxGL/RCTMapboxAnnotationManager.m b/ios/RCTMapboxGL/RCTMapboxAnnotationManager.m deleted file mode 100644 index dca8846..0000000 --- a/ios/RCTMapboxGL/RCTMapboxAnnotationManager.m +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -#import "RCTMapboxAnnotationManager.h" - -#import -#import -#import -#import "RCTMapboxAnnotation.h" - -@interface RCTMapboxAnnotationManager () - -@end - -@implementation RCTMapboxAnnotationManager - -RCT_EXPORT_MODULE() - -- (UIView *)view -{ - RCTMapboxAnnotation *marker = [[RCTMapboxAnnotation alloc] init]; -// UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(_handleTap:)]; -// // setting this to NO allows the parent MapView to continue receiving marker selection events -// tapGestureRecognizer.cancelsTouchesInView = NO; -// [marker addGestureRecognizer:tapGestureRecognizer]; - marker.bridge = self.bridge; - return marker; -} - -RCT_EXPORT_VIEW_PROPERTY(id, NSString) -RCT_EXPORT_VIEW_PROPERTY(title, NSString) -RCT_EXPORT_VIEW_PROPERTY(subtitle, NSString) -RCT_EXPORT_VIEW_PROPERTY(coordinate, CLLocationCoordinate2D) - -@end diff --git a/ios/RCTMapboxGL/RCTMapboxGL.h b/ios/RCTMapboxGL/RCTMapboxGL.h deleted file mode 100644 index 1d16583..0000000 --- a/ios/RCTMapboxGL/RCTMapboxGL.h +++ /dev/null @@ -1,121 +0,0 @@ -// -// RCTMapboxGL.h -// RCTMapboxGL -// -// Created by Bobby Sudekum on 4/30/15. -// Copyright (c) 2015 Mapbox. All rights reserved. -// - -#import -#import -#import -#import - -@interface RCTMapboxGL : RCTView - -- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher; - -// React props -- (void)setInitialCenterCoordinate:(CLLocationCoordinate2D)centerCoordinate; -- (void)setInitialZoomLevel:(double)zoomLevel; -- (void)setInitialDirection:(double)direction; -- (void)setClipsToBounds:(BOOL)clipsToBounds; -- (void)setDebugActive:(BOOL)debugActive; -- (void)setRotateEnabled:(BOOL)rotateEnabled; -- (void)setScrollEnabled:(BOOL)scrollEnabled; -- (void)setZoomEnabled:(BOOL)zoomEnabled; -- (void)setShowsUserLocation:(BOOL)showsUserLocation; -- (void)setStyleURL:(NSURL *)styleURL; -- (void)setUserTrackingMode:(int)userTrackingMode; -- (void)setAttributionButtonIsHidden:(BOOL)isHidden; -- (void)setLogoIsHidden:(BOOL)isHidden; -- (void)setCompassIsHidden:(BOOL)isHidden; -- (void)setUserLocationVerticalAlignment:(MGLAnnotationVerticalAlignment) aligment; -- (void)setContentInset:(UIEdgeInsets)contentInset; -@property (nonatomic) BOOL annotationsPopUpEnabled; - -// Imperative methods -- (void)setCenterCoordinate:(CLLocationCoordinate2D)coordinates zoomLevel:(double)zoomLevel direction:(double)direction animated:(BOOL)animated completionHandler:(void (^)())callback; -- (void)setCamera:(MGLMapCamera *)camera withDuration:(NSTimeInterval)duration animationTimingFunction:(nullable CAMediaTimingFunction *)function completionHandler:(nullable void (^)(void))handler; -- (void)setVisibleCoordinateBounds:(MGLCoordinateBounds)bounds edgePadding:(UIEdgeInsets)padding animated:(BOOL)animated; -- (void)selectAnnotation:(NSString*)selectedId animated:(BOOL)animated; -- (void)deselectAnnotation; -- (nonnull NSArray> *)visibleFeaturesAtPoint:(CGPoint)point inStyleLayersWithIdentifiers:(nullable NSSet *)styleLayerIdentifiers; -- (nonnull NSArray> *)visibleFeaturesInRect:(CGRect)rect inStyleLayersWithIdentifiers:(nullable NSSet *)identifiers; - -// Annotation management -- (void)upsertAnnotation:(NSObject *)annotation; -- (void)removeAnnotation:(NSString*)selectedIdentifier; -- (void)removeAllAnnotations; -- (void)restoreAnnotationPosition:(NSString *)annotationId; - -// Getters -- (MGLCoordinateBounds)visibleCoordinateBounds; -- (double)zoomLevel; -- (double)direction; -- (double)pitch; -- (MGLMapCamera*)camera; -- (CLLocationCoordinate2D)centerCoordinate; - -// Events -@property (nonatomic, copy) RCTDirectEventBlock onRegionDidChange; -@property (nonatomic, copy) RCTDirectEventBlock onRegionWillChange; -@property (nonatomic, copy) RCTDirectEventBlock onChangeUserTrackingMode; -@property (nonatomic, copy) RCTDirectEventBlock onOpenAnnotation; -@property (nonatomic, copy) RCTDirectEventBlock onCloseAnnotation; -@property (nonatomic, copy) RCTDirectEventBlock onRightAnnotationTapped; -@property (nonatomic, copy) RCTDirectEventBlock onUpdateUserLocation; -@property (nonatomic, copy) RCTDirectEventBlock onTap; -@property (nonatomic, copy) RCTDirectEventBlock onLongPress; -@property (nonatomic, copy) RCTDirectEventBlock onFinishLoadingMap; -@property (nonatomic, copy) RCTDirectEventBlock onStartLoadingMap; -@property (nonatomic, copy) RCTDirectEventBlock onLocateUserFailed; - -@end - -@interface RCTMGLAnnotation : NSObject - -@property (nonatomic, strong) UIButton *rightCalloutAccessory; -@property (nonatomic) NSString *id; -@property (nonatomic) NSDictionary *annotationImageSource; -@property (nonatomic) CGSize annotationImageSize; - -+ (instancetype)annotationWithLocation:(CLLocationCoordinate2D)coordinate title:(NSString *)title subtitle:(NSString *)subtitle id:(NSString *)id; - -+ (instancetype)annotationWithLocationRightCallout:(CLLocationCoordinate2D)coordinate title:(NSString *)title subtitle:(NSString *)subtitle id:(NSString *)id rightCalloutAccessory:(UIButton *)rightCalloutAccessory; - -- (instancetype)initWithLocation:(CLLocationCoordinate2D)coordinate title:(NSString *)title subtitle:(NSString *)subtitle id:(NSString *)id; - -- (instancetype)initWithLocationRightCallout:(CLLocationCoordinate2D)coordinate title:(NSString *)title subtitle:(NSString *)subtitle id:(NSString *)id rightCalloutAccessory:(UIButton *)rightCalloutAccessory; - - -@end - -@interface RCTMGLAnnotationPolyline : MGLPolyline - -@property (nonatomic) NSString *id; -@property (nonatomic) double strokeAlpha; -@property (nonatomic) NSString *strokeColor; -@property (nonatomic) double strokeWidth; -@property (nonatomic) NSString *type; -@property (nonatomic) NSUInteger count; -@property (nonatomic) CLLocationCoordinate2D *coordinates; - -+ (instancetype)polylineAnnotation:(CLLocationCoordinate2D *)coordinates strokeAlpha:(double)strokeAlpha strokeColor:(NSString *)strokeColor strokeWidth:(double)strokeWidth id:(NSString *)id type:(NSString *)type count:(NSUInteger)count; - -@end - -@interface RCTMGLAnnotationPolygon : MGLPolygon - -@property (nonatomic) NSString *id; -@property (nonatomic) double fillAlpha; -@property (nonatomic) NSString *fillColor; -@property (nonatomic) double strokeAlpha; -@property (nonatomic) NSString *strokeColor; -@property (nonatomic) NSString *type; -@property (nonatomic) NSUInteger count; -@property (nonatomic) CLLocationCoordinate2D *coordinates; - -+ (instancetype)polygonAnnotation:(CLLocationCoordinate2D *)coordinates fillAlpha:(double)fillAlpha fillColor:(NSString *)fillColor strokeColor:(NSString *)strokeColor strokeAlpha:(double)strokeAlpha id:(NSString *)id type:(NSString *)type count:(NSUInteger)count; - -@end diff --git a/ios/RCTMapboxGL/RCTMapboxGLConversions.h b/ios/RCTMapboxGL/RCTMapboxGLConversions.h deleted file mode 100644 index cb7d1c3..0000000 --- a/ios/RCTMapboxGL/RCTMapboxGLConversions.h +++ /dev/null @@ -1,13 +0,0 @@ -// -// RCTMapboxGLConversions.h -// RCTMapboxGL -// -// Created by Marius Petcu on 20/06/16. -// Copyright © 2016 Mapbox. All rights reserved. -// - -UIImage *imageFromSource (NSDictionary *source); -NSObject *convertObjectToPoint (NSObject *annotationObject); -NSObject *convertObjectToPolyline (NSObject *annotationObject); -NSObject *convertObjectToPolygon (NSObject *annotationObject); -NSObject *convertToMGLAnnotation (NSDictionary *annotationObject); \ No newline at end of file diff --git a/ios/RCTMapboxGL/RCTMapboxGLConversions.m b/ios/RCTMapboxGL/RCTMapboxGLConversions.m deleted file mode 100644 index 9451bda..0000000 --- a/ios/RCTMapboxGL/RCTMapboxGLConversions.m +++ /dev/null @@ -1,231 +0,0 @@ -// -// RCTMapboxGLConversions.m -// RCTMapboxGL -// -// Created by Marius Petcu on 20/06/16. -// Copyright © 2016 Mapbox. All rights reserved. -// - -#import -#import -#import -#import "RCTMapboxGL.h" - -UIImage *imageFromSource (NSDictionary *source) -{ - if (!source) { return nil; } - NSString *uri = source[@"uri"]; - if (!uri) { return nil; } - - NSURL* checkURL = [NSURL URLWithString:uri]; - if (checkURL && checkURL.scheme && checkURL.host) { - return [UIImage imageWithData:[NSData dataWithContentsOfURL:checkURL]]; - } - - return [UIImage imageNamed:uri]; -} - -NSObject *convertObjectToPoint (NSObject *annotationObject) -{ - NSString *title = @""; - if ([annotationObject valueForKey:@"title"]) { - title = [RCTConvert NSString:[annotationObject valueForKey:@"title"]]; - } - - NSString *subtitle = @""; - if ([annotationObject valueForKey:@"subtitle"]) { - subtitle = [RCTConvert NSString:[annotationObject valueForKey:@"subtitle"]]; - } - - NSString *id = @""; - if ([annotationObject valueForKey:@"id"]) { - id = [RCTConvert NSString:[annotationObject valueForKey:@"id"]]; - } - - RCTMGLAnnotation *point; - - if ([annotationObject valueForKey:@"rightCalloutAccessory"]) { - NSDictionary *rightCalloutAccessory = [annotationObject valueForKey:@"rightCalloutAccessory"]; - NSDictionary *imageSource = (NSDictionary*)rightCalloutAccessory[@"source"]; - CGFloat height = (CGFloat)[[rightCalloutAccessory valueForKey:@"height"] doubleValue]; - CGFloat width = (CGFloat)[[rightCalloutAccessory valueForKey:@"width"] doubleValue]; - - UIImage *image = imageFromSource(imageSource); - - UIButton *imageButton = [UIButton buttonWithType:UIButtonTypeCustom]; - imageButton.frame = CGRectMake(0, 0, height, width); - [imageButton setImage:image forState:UIControlStateNormal]; - - NSArray *coordinate = [RCTConvert NSArray:[annotationObject valueForKey:@"coordinates"]]; - CLLocationDegrees lat = [coordinate[0] doubleValue]; - CLLocationDegrees lng = [coordinate[1] doubleValue]; - - point = [[RCTMGLAnnotation alloc] initWithLocationRightCallout:CLLocationCoordinate2DMake(lat, lng) title:title subtitle:subtitle id:id rightCalloutAccessory:imageButton]; - - } else { - - NSArray *coordinate = [RCTConvert NSArray:[annotationObject valueForKey:@"coordinates"]]; - CLLocationDegrees lat = [coordinate[0] doubleValue]; - CLLocationDegrees lng = [coordinate[1] doubleValue]; - - point = [[RCTMGLAnnotation alloc] initWithLocation:CLLocationCoordinate2DMake(lat, lng) title:title subtitle:subtitle id:id]; - } - - if ([annotationObject valueForKey:@"annotationImage"]) { - NSDictionary *annotationImage = [annotationObject valueForKey:@"annotationImage"]; - NSDictionary *imageSource = (NSDictionary*)annotationImage[@"source"]; - CGFloat height = (CGFloat)[[annotationImage valueForKey:@"height"] doubleValue]; - CGFloat width = (CGFloat)[[annotationImage valueForKey:@"width"] doubleValue]; - if (!height || !width) { - RCTLogError(@"Height and width for image required"); - return nil; - } - CGSize annotationImageSize = CGSizeMake(width, height); - point.annotationImageSource = imageSource; - point.annotationImageSize = annotationImageSize; - } - - return point; -} - -NSObject *convertObjectToPolyline (NSObject *annotationObject) -{ - - NSString *title = @""; - if ([annotationObject valueForKey:@"title"]) { - title = [RCTConvert NSString:[annotationObject valueForKey:@"title"]]; - } - - NSString *subtitle = @""; - if ([annotationObject valueForKey:@"subtitle"]) { - subtitle = [RCTConvert NSString:[annotationObject valueForKey:@"subtitle"]]; - } - - NSString *id = @""; - if ([annotationObject valueForKey:@"id"]) { - id = [RCTConvert NSString:[annotationObject valueForKey:@"id"]]; - } - - NSString *type = @""; - if ([annotationObject valueForKey:@"type"]) { - type = [RCTConvert NSString:[annotationObject valueForKey:@"type"]]; - } - - CGFloat strokeAlpha = 1.0; - if ([annotationObject valueForKey:@"strokeAlpha"]) { - strokeAlpha = [RCTConvert CGFloat:[annotationObject valueForKey:@"strokeAlpha"]]; - } - - NSString *strokeColor = nil; - if ([annotationObject valueForKey:@"strokeColor"]) { - strokeColor = [RCTConvert NSString:[annotationObject valueForKey:@"strokeColor"]]; - } - - double strokeWidth = 3; - if ([annotationObject valueForKey:@"strokeWidth"]) { - strokeWidth = [RCTConvert double:[annotationObject valueForKey:@"strokeWidth"]]; - } - - NSArray *coordinates = [RCTConvert NSArray:[annotationObject valueForKey:@"coordinates"]]; - NSUInteger numberOfPoints = coordinates.count; - int count = 0; - CLLocationCoordinate2D *coord = malloc(sizeof(CLLocationCoordinate2D) * numberOfPoints); - - if ([annotationObject valueForKey:@"coordinates"]) { - for (int i = 0; i < [coordinates count]; i++) { - CLLocationDegrees lat = [coordinates[i][0] doubleValue]; - CLLocationDegrees lng = [coordinates[i][1] doubleValue]; - coord[count] = CLLocationCoordinate2DMake(lat, lng); - count++; - } - } - RCTMGLAnnotationPolyline *polyline = [RCTMGLAnnotationPolyline polylineAnnotation:coord strokeAlpha:strokeAlpha strokeColor:strokeColor strokeWidth:strokeWidth id:id type:@"polyline" count:count]; - free(coord); - return polyline; -} - -NSObject *convertObjectToPolygon (NSObject *annotationObject) -{ - NSString *title = @""; - if ([annotationObject valueForKey:@"title"]) { - title = [RCTConvert NSString:[annotationObject valueForKey:@"title"]]; - } - - NSString *subtitle = @""; - if ([annotationObject valueForKey:@"subtitle"]) { - subtitle = [RCTConvert NSString:[annotationObject valueForKey:@"subtitle"]]; - } - - NSString *id = @""; - if ([annotationObject valueForKey:@"id"]) { - id = [RCTConvert NSString:[annotationObject valueForKey:@"id"]]; - } - - NSString *type = @""; - if ([annotationObject valueForKey:@"type"]) { - type = [RCTConvert NSString:[annotationObject valueForKey:@"type"]]; - } - - CGFloat fillAlpha = 1.0; - if ([annotationObject valueForKey:@"fillAlpha"]) { - fillAlpha = [RCTConvert CGFloat:[annotationObject valueForKey:@"fillAlpha"]]; - } - - NSString *fillColor = @""; - if ([annotationObject valueForKey:@"fillColor"]) { - fillColor = [RCTConvert NSString:[annotationObject valueForKey:@"fillColor"]]; - } - - CGFloat strokeAlpha = 1.0; - if ([annotationObject valueForKey:@"strokeAlpha"]) { - strokeAlpha = [RCTConvert CGFloat:[annotationObject valueForKey:@"strokeAlpha"]]; - } - - NSString *strokeColor = @""; - if ([annotationObject valueForKey:@"strokeColor"]) { - strokeColor = [RCTConvert NSString:[annotationObject valueForKey:@"strokeColor"]]; - } - - NSArray *coordinates = [RCTConvert NSArray:[annotationObject valueForKey:@"coordinates"]]; - NSUInteger numberOfPoints = coordinates.count; - int count = 0; - CLLocationCoordinate2D *coord = malloc(sizeof(CLLocationCoordinate2D) * numberOfPoints); - - if ([annotationObject valueForKey:@"coordinates"]) { - for (int i = 0; i < [coordinates count]; i++) { - CLLocationDegrees lat = [coordinates[i][0] doubleValue]; - CLLocationDegrees lng = [coordinates[i][1] doubleValue]; - coord[count] = CLLocationCoordinate2DMake(lat, lng); - count++; - } - } - RCTMGLAnnotationPolygon *polygon = [RCTMGLAnnotationPolygon polygonAnnotation:coord fillAlpha:fillAlpha fillColor:fillColor strokeColor:strokeColor strokeAlpha:strokeAlpha id:id type:@"polygon" count:count]; - free(coord); - return polygon; -} - -NSObject *convertToMGLAnnotation (NSDictionary *annotationObject) -{ - if (![annotationObject valueForKey:@"type"]) { - RCTLogError(@"type point, polyline or polygon required"); - return nil; - } - - NSString *type = [RCTConvert NSString:[annotationObject valueForKey:@"type"]]; - - if ([type isEqual: @"point"]) { - return convertObjectToPoint(annotationObject); - - } else if ([type isEqual: @"polyline"]) { - return convertObjectToPolyline(annotationObject); - - - } else if ([type isEqual: @"polygon"]) { - return convertObjectToPolygon(annotationObject); - - } else { - RCTLogError(@"type point, polyline or polygon required"); - return nil; - } - -} diff --git a/ios/RCTMapboxGL/RCTMapboxGLManager.h b/ios/RCTMapboxGL/RCTMapboxGLManager.h deleted file mode 100644 index ce3e15d..0000000 --- a/ios/RCTMapboxGL/RCTMapboxGLManager.h +++ /dev/null @@ -1,20 +0,0 @@ -// -// RCTMapboxGLManager.h -// RCTMapboxGL -// -// Created by Bobby Sudekum on 4/30/15. -// Copyright (c) 2015 Mapbox. All rights reserved. -// - -#import - -@interface RCTMapboxGLManager : RCTViewManager { - NSMutableSet * _recentPacks; - NSMutableSet * _throttledPacks; - NSMutableArray * _packRequests; - NSMutableSet * _removedPacks; - int _throttleInterval; - BOOL _loadedPacks; - NSMutableSet * _loadingPacks; -} -@end diff --git a/ios/RCTMapboxGLTests/Info.plist b/ios/RCTMapboxGLTests/Info.plist deleted file mode 100644 index eee99fb..0000000 --- a/ios/RCTMapboxGLTests/Info.plist +++ /dev/null @@ -1,24 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - com.mapbox.$(PRODUCT_NAME:rfc1034identifier) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - BNDL - CFBundleShortVersionString - 1.0 - CFBundleSignature - ???? - CFBundleVersion - 1 - - diff --git a/ios/install-cocoapods.md b/ios/install-cocoapods.md deleted file mode 100644 index ee99737..0000000 --- a/ios/install-cocoapods.md +++ /dev/null @@ -1,55 +0,0 @@ -# Installation process with CocoaPods - -If you use already [CocoaPods](https://cocoapods.org/) in your react-native -project, you can also add the react-native-mapbox-gl project to your Podfile. - -1. Run `npm install --save @mapbox/react-native-mapbox-gl` -2. In your `podfile`, make sure that `platform :ios, '8.0'` is set to `8.0` -3. Add `pod 'RCTMapboxGL', :path => '../node_modules/@mapbox/react-native-mapbox-gl/ios'` - to your `Podfile` file. - (The path depends on your Podfile location.) -4. Open your Xcode project and ensure that the "Build Settings" parameter - "Other linker flags" (`OTHER_LDFLAGS`) contains the CocoaPods generated - linker options! - * If you have used `react-native init` to setup your project you can just - remove this parameter. Just select the line and press the Delete key. - * Alternative, if you setup your Xcode project yourself, ensure that the - parent configuration was included with a `$(inherited)` variable. -5. Install the new CocoaPods dependency with `pod install`. - This command must not have output any warning. ;) - -## Troubleshooting with CocoaPods - -### RCTView.h file not found - -Because react-native is only available as npm module (and not as "regular" -CocoaPods dependency, see [v0.13 release notes](https://github.com/facebook/react-native/releases/tag/v0.13.0) -for more informations). - -So it is required that you import react-native also from a local path. -Ensure that you include `React` before you include `react-native-mapbox-gl` in -your `Podfile`. Here is a complete working example if you want add your Podfile -in the project root while your generated Xcode project is still in the `ios` -folder: - -```ruby -source 'https://github.com/CocoaPods/Specs.git' - -xcodeproj 'ios/YourProject' -workspace 'ios/YourProject' - -pod 'React', :path => 'node_modules/react-native' -pod 'React/RCTGeolocation', :path => 'node_modules/react-native' -pod 'React/RCTImage', :path => 'node_modules/react-native' -pod 'React/RCTNetwork', :path => 'node_modules/react-native' -pod 'React/RCTText', :path => 'node_modules/react-native' -pod 'React/RCTWebSocket', :path => 'node_modules/react-native' - -pod 'RCTMapboxGL', :path => 'node_modules/@mapbox/react-native-mapbox-gl/ios' -``` - -### NativeModules.MapboxGLManager.* not defined - -Verify that your "Build Settings" parameter "Other linker flags" (`OTHER_LDFLAGS`) -is defined correctly. This is NOT the case in a `react-native init` project which doesn't -use CocoaPods. See Step 3 above! diff --git a/ios/install.md b/ios/install.md deleted file mode 100644 index b9d9ed1..0000000 --- a/ios/install.md +++ /dev/null @@ -1,65 +0,0 @@ -#### Note - -If you were using react-native-mapbox-gl before we moved it into the mapbox npm org. -You will need to unlink react-native-mapbox-gl and link @mapbox/react-native-mapbox-gl - -# Manual installation process - -_Make sure to follow these directions carefully._ - -First, -```bash -npm install @mapbox/react-native-mapbox-gl --save -``` - -### 1: Adding RCTMapboxGL.xcodeproj - -In the Xcode's `Project navigator`, right click on the `Libraries` folder ➜ `Add Files to <...>`. Add `node_modules/@mapbox/react-native-mapbox-gl/ios/RCTMapboxGL.xcodeproj` - -![](https://dl.dropboxusercontent.com/s/6trwtezp3009eot/2016-03-14%20at%2012.52%20PM.png) - -![](https://cldup.com/DTD2UZMYu5.png) - -### 2: Adding Mapbox.framework - -Select your project in the `Project navigator`. Click `General` tab then add `node_modules/@mapbox/react-native-mapbox-gl/ios/Mapbox.framework` to `Embedded Binaries`. :collision: **Important, make sure you're adding it to general -> `Embedded Binaries` :collision:** - -Click 'Add other' to open the file browser and select Mapbox.framework. - -![](https://dl.dropboxusercontent.com/s/7bjl6hul1q955o0/2016-03-14%20at%2012.57%20PM.png) - -Select the 'Copy items if needed' checkbox. - -![](https://dl.dropboxusercontent.com/s/5ain808tuhalx30/2016-03-14%20at%201.02%20PM.png) - -![](https://cldup.com/s4U3JfS_-l.png) - -### 3: Adding the script - -In the `Build Phases` tab, click the plus sign and then `New Run Script Phase` - -![](https://cldup.com/jgt8p_dHjD.png) - -Open the newly added `Run Script` and paste: - -```bash - "${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}/Mapbox.framework/strip-frameworks.sh" -``` - -![](https://cldup.com/SGt3NdX-yy.png) - -### 4: Link Binaries with Libraries - -In `Build Phases` tab, click `Link Binaries With Libraries` and add `libRCTMapboxGL.a` - -![](https://cldup.com/FuOlGOwAli.png) - -### 5: Update minimum iOS version to 8.0 - -React Native Mapbox GL doesn't support iOS version less than 8.0. Under **Targets** ⇢ **Deployment Info**, set the minimum version to 8.0. - -![](https://dl.dropboxusercontent.com/s/yu3zyjy59p44cxb/2016-03-14%20at%201.15%20PM.png) - -### 6: Add to project, [see example](../example.js) - -If you already have an iOS Simulator running from before you followed these steps, you'll need to rebuild the project from XCode - automatic refresh won't bring in the changes you made to this build process.