diff --git a/android/manifest b/android/manifest index 190854b8..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.3 +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 diff --git a/android/src/ti/map/PolygonProxy.java b/android/src/ti/map/PolygonProxy.java index 45df62c4..17f66fb2 100644 --- a/android/src/ti/map/PolygonProxy.java +++ b/android/src/ti/map/PolygonProxy.java @@ -9,6 +9,7 @@ import android.app.Activity; 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; @@ -304,6 +305,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..a077bd9f 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: "12.3.0"