diff --git a/android/src/ti/map/TiUIMapView.java b/android/src/ti/map/TiUIMapView.java index 82baf1f2..c5806f65 100644 --- a/android/src/ti/map/TiUIMapView.java +++ b/android/src/ti/map/TiUIMapView.java @@ -1451,13 +1451,15 @@ public boolean onClusterItemClick(TiMarker tiMarker) public void loadKml(KrollDict args) { - 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()); + 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 711a79e2..2a561f28 100644 --- a/android/src/ti/map/ViewProxy.java +++ b/android/src/ti/map/ViewProxy.java @@ -1517,9 +1517,16 @@ 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"); } } diff --git a/apidoc/Map.yml b/apidoc/Map.yml index 3b980deb..209cd7a6 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: TiBlob + 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