From 96a50b76a345fee726839191d322581c14e83b08 Mon Sep 17 00:00:00 2001 From: enieber cunha Date: Fri, 22 Apr 2022 05:29:53 -0300 Subject: [PATCH 1/2] feat: update version of osm-lib --- lib/android/build.gradle | 2 +- .../com/airbnb/android/react/maps/open/LatLngBoundsUtils.java | 1 + .../com/airbnb/android/react/maps/open/OpenAirMapFeature.java | 3 --- .../com/airbnb/android/react/maps/open/OpenAirMapManager.java | 1 - package.json | 2 +- 5 files changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/android/build.gradle b/lib/android/build.gradle index 1702e0d4c..f0dc5d4f8 100644 --- a/lib/android/build.gradle +++ b/lib/android/build.gradle @@ -37,6 +37,6 @@ dependencies { provided "com.facebook.react:react-native:+" compile "com.google.android.gms:play-services-base:10.2.4" compile "com.google.android.gms:play-services-maps:10.2.4" - compile 'org.osmdroid:osmdroid-android:5.6.5' + compile 'org.osmdroid:osmdroid-android:6.1.11' testCompile 'junit:junit:4.12' } diff --git a/lib/android/src/main/java/com/airbnb/android/react/maps/open/LatLngBoundsUtils.java b/lib/android/src/main/java/com/airbnb/android/react/maps/open/LatLngBoundsUtils.java index a6dacaa2a..857847ac1 100644 --- a/lib/android/src/main/java/com/airbnb/android/react/maps/open/LatLngBoundsUtils.java +++ b/lib/android/src/main/java/com/airbnb/android/react/maps/open/LatLngBoundsUtils.java @@ -4,6 +4,7 @@ import com.google.android.gms.maps.model.LatLngBounds; public class LatLngBoundsUtils { + public static boolean BoundsAreDifferent(LatLngBounds a, LatLngBounds b) { LatLng centerA = a.getCenter(); double latA = centerA.latitude; diff --git a/lib/android/src/main/java/com/airbnb/android/react/maps/open/OpenAirMapFeature.java b/lib/android/src/main/java/com/airbnb/android/react/maps/open/OpenAirMapFeature.java index b70dab6ce..90b4eddc3 100644 --- a/lib/android/src/main/java/com/airbnb/android/react/maps/open/OpenAirMapFeature.java +++ b/lib/android/src/main/java/com/airbnb/android/react/maps/open/OpenAirMapFeature.java @@ -1,9 +1,6 @@ package com.airbnb.android.react.maps.open; - import android.content.Context; - import com.facebook.react.views.view.ReactViewGroup; - import org.osmdroid.views.MapView; public abstract class OpenAirMapFeature extends ReactViewGroup { diff --git a/lib/android/src/main/java/com/airbnb/android/react/maps/open/OpenAirMapManager.java b/lib/android/src/main/java/com/airbnb/android/react/maps/open/OpenAirMapManager.java index 0832bf503..69d1c29c4 100644 --- a/lib/android/src/main/java/com/airbnb/android/react/maps/open/OpenAirMapManager.java +++ b/lib/android/src/main/java/com/airbnb/android/react/maps/open/OpenAirMapManager.java @@ -23,7 +23,6 @@ import org.osmdroid.views.MapView; import java.util.Map; - import javax.annotation.Nullable; public class OpenAirMapManager extends ViewGroupManager { diff --git a/package.json b/package.json index 15c895873..b5444d5a6 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "description": "React Native Mapview component for Android", "main": "index.js", "author": "Enieber Cunha ", - "version": "0.0.2", + "version": "0.1.0", "scripts": { "start": "node node_modules/react-native/local-cli/cli.js start", "test": "jest", From 10faa529f3b1d3be118557c1872f6262926f8ae9 Mon Sep 17 00:00:00 2001 From: enieber cunha Date: Fri, 22 Apr 2022 05:30:19 -0300 Subject: [PATCH 2/2] fix: change init render componenet --- .../react/maps/open/OpenAirMapManager.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/android/src/main/java/com/airbnb/android/react/maps/open/OpenAirMapManager.java b/lib/android/src/main/java/com/airbnb/android/react/maps/open/OpenAirMapManager.java index 69d1c29c4..8789ccfcc 100644 --- a/lib/android/src/main/java/com/airbnb/android/react/maps/open/OpenAirMapManager.java +++ b/lib/android/src/main/java/com/airbnb/android/react/maps/open/OpenAirMapManager.java @@ -36,7 +36,9 @@ public class OpenAirMapManager extends ViewGroupManager { private static final int FIT_TO_SUPPLIED_MARKERS = 6; private static final int FIT_TO_COORDINATES = 7; private static final int SET_MAP_BOUNDARIES = 8; - + private double lat = -18.9855811 + private double log = -53.7266065 + private final Map MAP_TYPES = MapBuilder.of( "standard", TileSourceFactory.MAPNIK, "satellite", TileSourceFactory.OPEN_SEAMAP @@ -60,7 +62,7 @@ protected OpenAirMapView createViewInstance(ThemedReactContext context) { MapView mapView = view.map; mapView.setTileSource(TileSourceFactory.MAPNIK); IMapController controller = mapView.getController(); - GeoPoint startPoint = new GeoPoint(-18.9855811, -53.7266065); + GeoPoint startPoint = new GeoPoint(this.lat, this.log); controller.setCenter(startPoint); return view; } @@ -75,8 +77,8 @@ private void emitMapError(ThemedReactContext context, String message, String typ error.putString("type", type); context - .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) - .emit("onError", error); + .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) + .emit("onError", error); } @ReactProp(name = "region") @@ -94,6 +96,16 @@ public void showMultiTouchControls(OpenAirMapView view, boolean hasMultiTouchCon view.showMultiTouchControls(hasMultiTouchControls); } + @ReactProp(name = "initalLat") + public void setIntialLat(double lat) { + this.lat = lat; + } + + @ReactProp(name = "initalLog") + public void setIntialLat(double log) { + this.log = log; + } + @ReactProp(name = "initialRegion") public void setInitialRegion(OpenAirMapView view, ReadableMap initialRegion) { view.setInitialRegion(initialRegion);