From 5130bdcd5ddd2e4ce27b47c3b008dda7b275168e Mon Sep 17 00:00:00 2001 From: m1ga Date: Tue, 28 Jun 2022 21:09:25 +0200 Subject: [PATCH 1/5] feat(android): polygon bounds --- android/manifest | 2 +- android/src/ti/map/PolygonProxy.java | 23 +++++++++++++++++++++++ apidoc/Polygon.yml | 6 ++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/android/manifest b/android/manifest index 8ef4b778..1380c543 100644 --- a/android/manifest +++ b/android/manifest @@ -2,7 +2,7 @@ # this is your module manifest and used by Titanium # during compilation, packaging, distribution, etc. # -version: 5.4.0 +version: 5.5.0 apiversion: 4 architectures: arm64-v8a armeabi-v7a x86 x86_64 description: External version of Map module using native Google Maps library diff --git a/android/src/ti/map/PolygonProxy.java b/android/src/ti/map/PolygonProxy.java index 3fd766d2..3077bc21 100644 --- a/android/src/ti/map/PolygonProxy.java +++ b/android/src/ti/map/PolygonProxy.java @@ -8,6 +8,7 @@ import android.os.Message; import com.google.android.gms.maps.model.LatLng; +import com.google.android.gms.maps.model.LatLngBounds; import com.google.android.gms.maps.model.Polygon; import com.google.android.gms.maps.model.PolygonOptions; import com.google.maps.android.PolyUtil; @@ -17,6 +18,7 @@ import org.appcelerator.kroll.KrollProxy; import org.appcelerator.kroll.annotations.Kroll; import org.appcelerator.kroll.common.AsyncResult; +import org.appcelerator.kroll.common.Log; import org.appcelerator.kroll.common.TiMessenger; import org.appcelerator.titanium.TiC; import org.appcelerator.titanium.util.TiConvert; @@ -301,6 +303,27 @@ else if (name.equals(TiC.PROPERTY_TOUCH_ENABLED)) { } } + @Kroll.getProperty + public HashMap getBounds() + { + if (polygon == null) { + return null; + } + final LatLngBounds.Builder centerBuilder = LatLngBounds.builder(); + List points = polygon.getPoints(); + for (LatLng point : points) { + centerBuilder.include(point); + } + + LatLngBounds llb = centerBuilder.build(); + HashMap hm = new HashMap(); + hm.put(TiC.PROPERTY_LONGITUDE, llb.getCenter().longitude); + hm.put(TiC.PROPERTY_LATITUDE, llb.getCenter().latitude); + hm.put(TiC.PROPERTY_LATITUDE_DELTA, Math.abs(llb.northeast.latitude - llb.southwest.latitude)); + hm.put(TiC.PROPERTY_LONGITUDE_DELTA, Math.abs(llb.northeast.longitude - llb.southwest.longitude)); + return hm; + } + public String getApiName() { return "Ti.Map.Polygon"; diff --git a/apidoc/Polygon.yml b/apidoc/Polygon.yml index ba394b2f..6d624e9b 100644 --- a/apidoc/Polygon.yml +++ b/apidoc/Polygon.yml @@ -57,3 +57,9 @@ properties: availability: creation type: Number platforms: [android] + + - name: bounds + summary: Returns the bounding box of the polygon. Useful to center the region. + type: MapRegionTypev2 + platforms: [android] + since: "5.5.0" From 9165a016d0d28212efdf739aebafa5398fb50342 Mon Sep 17 00:00:00 2001 From: m1ga Date: Tue, 28 Jun 2022 21:14:42 +0200 Subject: [PATCH 2/5] remove unused import --- android/src/ti/map/PolygonProxy.java | 1 - 1 file changed, 1 deletion(-) diff --git a/android/src/ti/map/PolygonProxy.java b/android/src/ti/map/PolygonProxy.java index 3077bc21..f879b620 100644 --- a/android/src/ti/map/PolygonProxy.java +++ b/android/src/ti/map/PolygonProxy.java @@ -18,7 +18,6 @@ import org.appcelerator.kroll.KrollProxy; import org.appcelerator.kroll.annotations.Kroll; import org.appcelerator.kroll.common.AsyncResult; -import org.appcelerator.kroll.common.Log; import org.appcelerator.kroll.common.TiMessenger; import org.appcelerator.titanium.TiC; import org.appcelerator.titanium.util.TiConvert; From 2094dd86e93596a808333ac84c0c7328bdb94301 Mon Sep 17 00:00:00 2001 From: Michael Gangolf Date: Sat, 23 Sep 2023 21:16:12 +0200 Subject: [PATCH 3/5] Update apidoc/Polygon.yml --- apidoc/Polygon.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apidoc/Polygon.yml b/apidoc/Polygon.yml index 6d624e9b..a077bd9f 100644 --- a/apidoc/Polygon.yml +++ b/apidoc/Polygon.yml @@ -62,4 +62,4 @@ properties: summary: Returns the bounding box of the polygon. Useful to center the region. type: MapRegionTypev2 platforms: [android] - since: "5.5.0" + since: "12.3.0" From fd84f0b2894ce9915c7b06531d573a23fa54e8d6 Mon Sep 17 00:00:00 2001 From: Michael Gangolf Date: Sat, 23 Sep 2023 21:23:22 +0200 Subject: [PATCH 4/5] Update manifest --- android/manifest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/manifest b/android/manifest index 1380c543..675925fe 100644 --- a/android/manifest +++ b/android/manifest @@ -2,7 +2,7 @@ # this is your module manifest and used by Titanium # during compilation, packaging, distribution, etc. # -version: 5.5.0 +version: 5.6.0 apiversion: 4 architectures: arm64-v8a armeabi-v7a x86 x86_64 description: External version of Map module using native Google Maps library From bf8ac445bf5c3a012269abf465f17f655a08da56 Mon Sep 17 00:00:00 2001 From: Michael Gangolf Date: Sat, 23 Sep 2023 21:25:11 +0200 Subject: [PATCH 5/5] Update android/manifest --- android/manifest | 1 - 1 file changed, 1 deletion(-) diff --git a/android/manifest b/android/manifest index 9fe86b9c..675925fe 100644 --- a/android/manifest +++ b/android/manifest @@ -2,7 +2,6 @@ # this is your module manifest and used by Titanium # during compilation, packaging, distribution, etc. # - version: 5.6.0 apiversion: 4 architectures: arm64-v8a armeabi-v7a x86 x86_64