diff --git a/android/build.gradle b/android/build.gradle index a323ad2b..769d70eb 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -4,7 +4,7 @@ dependencies { implementation 'com.google.android.gms:play-services-maps:18.1.0' // https://github.com/googlemaps/android-maps-utils/releases - implementation 'com.google.maps.android:android-maps-utils:3.5.3' + implementation 'com.google.maps.android:android-maps-utils:3.8.2' // https://developer.android.com/jetpack/androidx/releases/fragment implementation 'androidx.fragment:fragment:1.5.7' diff --git a/android/manifest b/android/manifest index 6c6ce06c..949a175a 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.6.1 +version: 5.7.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/TiUIMapView.java b/android/src/ti/map/TiUIMapView.java index f52b68c5..02e90745 100644 --- a/android/src/ti/map/TiUIMapView.java +++ b/android/src/ti/map/TiUIMapView.java @@ -39,6 +39,7 @@ import com.google.maps.android.clustering.ClusterManager; import com.google.maps.android.clustering.view.DefaultClusterRenderer; import com.google.maps.android.collections.MarkerManager; +import com.google.maps.android.data.kml.KmlLayer; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; @@ -1447,4 +1448,18 @@ public boolean onClusterItemClick(TiMarker tiMarker) { return onMarkerClick(tiMarker.getMarker()); } + + public void loadKml(KrollDict args) + { + if (map != null) { + TiBlob file = TiConvert.toBlob(args.get("file")); + try { + KmlLayer layer = + new KmlLayer(map, file.getInputStream(), TiApplication.getInstance().getApplicationContext()); + layer.addLayerToMap(); + } catch (Exception ex) { + Log.e(TAG, "Error: " + ex.getMessage()); + } + } + } } diff --git a/android/src/ti/map/ViewProxy.java b/android/src/ti/map/ViewProxy.java index a09b9faf..2a561f28 100644 --- a/android/src/ti/map/ViewProxy.java +++ b/android/src/ti/map/ViewProxy.java @@ -1514,6 +1514,22 @@ public void setClusterAnnotation() { } + @Kroll.method + public void loadKml(KrollDict args) + { + if (!args.containsKeyAndNotNull("file")) { + Log.w(TAG, "file property is not set to a TiBlob"); + return; + } + + TiUIView view = peekView(); + if (view instanceof TiUIMapView) { + ((TiUIMapView) view).loadKml(args); + } else { + Log.e(TAG, "Map is not available"); + } + } + public String getApiName() { return "Ti.Map.View"; diff --git a/apidoc/Map.yml b/apidoc/Map.yml index 3b980deb..47fcc00a 100644 --- a/apidoc/Map.yml +++ b/apidoc/Map.yml @@ -33,7 +33,7 @@ description: | - @@ -438,7 +438,7 @@ properties: since: "6.3.0" - name: FEATURE_TERRITORIES - summary: | + summary: | The option that represents territorial boundaries such as a national border, a state boundary, or a neighborhood. type: Number @@ -448,7 +448,7 @@ properties: since: "12.0.0" - name: FEATURE_PHYSICAL_FEATURES - summary: | + summary: | The option that represents physical map features such as mountain ranges, rivers, and ocean basins. type: Number @@ -484,14 +484,14 @@ properties: osver: {ios: {min: "11.0"} } exclude-platforms: [android] since: "6.3.0" - + - name: SEARCH_RESULT_TYPE_ADDRESS summary: A value that indicates that search results include addresses. type: Number permission: read-only osver: {ios: {min: "13.0"} } since: "12.3.0" - + - name: SEARCH_RESULT_TYPE_POINT_OF_INTEREST summary: A value that indicates that search results include points of interest. type: Number @@ -518,7 +518,7 @@ methods: summary: Returns a code to indicate whether Google Play Services is available on the device. since: "3.1.1" platforms: [android] - + - name: search summary: | Uses the native `MKLocalSearchCompleter` class to search places for @@ -537,6 +537,19 @@ methods: platforms: [iphone, ipad, macos] since: "12.3.0" + - name: loadKml + summary: | + Loads a KML file and displays the content on the map. + description: | + Check [Google Maps KML support](https://developers.google.com/maps/documentation/android-sdk/utility/kml#supported) + for more details. + parameters: + - name: file + summary: Ti.Blob of the KML file. + type: Object + platforms: [android] + since: "12.4.0" + - name: geocodeAddress summary: | Resolve address details using the `CLGeocoder` to get information (e.g. @@ -614,7 +627,7 @@ examples: const mapView = Map.createView({ mapType: Map.NORMAL_TYPE, - region: { + region: { latitude: 33.74511, longitude: -84.38993, latitudeDelta: 0.01, @@ -769,7 +782,7 @@ examples: The following example shows the MapKit based search request. The options in `search` (2nd parameter) are optional, but improve the accuracy of the results. - + ```javascript import Map from 'ti.map'; @@ -817,4 +830,4 @@ properties: - - - - type: Array \ No newline at end of file + type: Array