react-native-maps 1.21.0-alpha.72 → 1.21.0-alpha.73

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -99,6 +99,9 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
99
99
  private RelativeLayout mapLoadingLayout;
100
100
  private ImageView cacheImageView;
101
101
  private Boolean isMapLoaded = false;
102
+
103
+ private Boolean isMapReady = false;
104
+
102
105
  private Integer loadingBackgroundColor = null;
103
106
  private Integer loadingIndicatorColor = null;
104
107
 
@@ -153,6 +156,7 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
153
156
  private Boolean showIndoors;
154
157
  private Boolean scrollEnabled;
155
158
  private Boolean scrollDuringRotateOrZoomEnabled;
159
+ private String kmlSrc = null;
156
160
 
157
161
  private static boolean contextHasBug(Context context) {
158
162
  return context == null ||
@@ -562,6 +566,11 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
562
566
  };
563
567
 
564
568
  context.addLifecycleEventListener(lifecycleListener);
569
+ isMapReady = true;
570
+ if (kmlSrc != null){
571
+ setKmlSrc(kmlSrc);
572
+ kmlSrc = null;
573
+ }
565
574
  }
566
575
 
567
576
  private synchronized void handleMarkerSelection(MapMarker target) {
@@ -1587,64 +1596,66 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
1587
1596
  }
1588
1597
 
1589
1598
  public void setKmlSrc(String kmlSrc) {
1590
- try {
1591
- InputStream kmlStream = new FileUtil(context).execute(kmlSrc).get();
1599
+ if (isMapReady) {
1600
+ try {
1601
+ InputStream kmlStream = new FileUtil(context).execute(kmlSrc).get();
1592
1602
 
1593
- if (kmlStream == null) {
1594
- return;
1595
- }
1596
-
1597
- KmlLayer kmlLayer = new KmlLayer(map, kmlStream, context, markerManager, polygonManager, polylineManager, groundOverlayManager, null);
1598
- kmlLayer.addLayerToMap();
1603
+ if (kmlStream == null) {
1604
+ return;
1605
+ }
1599
1606
 
1600
- WritableMap pointers = new WritableNativeMap();
1601
- WritableArray markers = new WritableNativeArray();
1607
+ KmlLayer kmlLayer = new KmlLayer(map, kmlStream, context, markerManager, polygonManager, polylineManager, groundOverlayManager, null);
1602
1608
 
1603
- if (kmlLayer.getContainers() == null) {
1604
- // todo: use Fabric events
1605
- // manager.pushEvent(context, this, "onKmlReady", pointers);
1606
- return;
1607
- }
1609
+ kmlLayer.addLayerToMap();
1608
1610
 
1609
- //Retrieve a nested container within the first container
1610
- KmlContainer container = kmlLayer.getContainers().iterator().next();
1611
- if (container == null || container.getContainers() == null) {
1612
- // todo: use Fabric events
1613
- // manager.pushEvent(context, this, "onKmlReady", pointers);
1614
- return;
1615
- }
1611
+ WritableMap pointers = new WritableNativeMap();
1612
+ WritableArray markers = new WritableNativeArray();
1616
1613
 
1614
+ if (kmlLayer.getContainers() == null) {
1615
+ // todo: use Fabric events
1616
+ // manager.pushEvent(context, this, "onKmlReady", pointers);
1617
+ return;
1618
+ }
1617
1619
 
1618
- if (container.getContainers().iterator().hasNext()) {
1619
- container = container.getContainers().iterator().next();
1620
- }
1620
+ //Retrieve a nested container within the first container
1621
+ KmlContainer container = kmlLayer.getContainers().iterator().next();
1622
+ if (container == null || container.getContainers() == null) {
1623
+ // todo: use Fabric events
1624
+ // manager.pushEvent(context, this, "onKmlReady", pointers);
1625
+ return;
1626
+ }
1621
1627
 
1622
- int index = 0;
1623
- for (KmlPlacemark placemark : container.getPlacemarks()) {
1624
- MarkerOptions options = new MarkerOptions();
1625
1628
 
1626
- if (placemark.getInlineStyle() != null) {
1627
- options = placemark.getMarkerOptions();
1628
- } else {
1629
- options.icon(BitmapDescriptorFactory.defaultMarker());
1629
+ if (container.getContainers().iterator().hasNext()) {
1630
+ container = container.getContainers().iterator().next();
1630
1631
  }
1631
1632
 
1632
- LatLng latLng = ((LatLng) placemark.getGeometry().getGeometryObject());
1633
- String title = "";
1634
- String snippet = "";
1633
+ int index = 0;
1634
+ for (KmlPlacemark placemark : container.getPlacemarks()) {
1635
+ MarkerOptions options = new MarkerOptions();
1635
1636
 
1636
- if (placemark.hasProperty("name")) {
1637
- title = placemark.getProperty("name");
1638
- }
1637
+ if (placemark.getInlineStyle() != null) {
1638
+ options = placemark.getMarkerOptions();
1639
+ } else {
1640
+ options.icon(BitmapDescriptorFactory.defaultMarker());
1641
+ }
1639
1642
 
1640
- if (placemark.hasProperty("description")) {
1641
- snippet = placemark.getProperty("description");
1642
- }
1643
+ LatLng latLng = ((LatLng) placemark.getGeometry().getGeometryObject());
1644
+ String title = "";
1645
+ String snippet = "";
1646
+
1647
+ if (placemark.hasProperty("name")) {
1648
+ title = placemark.getProperty("name");
1649
+ }
1650
+
1651
+ if (placemark.hasProperty("description")) {
1652
+ snippet = placemark.getProperty("description");
1653
+ }
1643
1654
 
1644
- options.position(latLng);
1645
- options.title(title);
1646
- options.snippet(snippet);
1647
- // FIXME: get markerManager from somewhere
1655
+ options.position(latLng);
1656
+ options.title(title);
1657
+ options.snippet(snippet);
1658
+ // FIXME: get markerManager from somewhere
1648
1659
  /*
1649
1660
  MapMarker marker = new MapMarker(context, options, this.manager.getMarkerManager());
1650
1661
 
@@ -1670,15 +1681,18 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
1670
1681
 
1671
1682
  markers.pushMap(loadedMarker);
1672
1683
  */
1673
- }
1684
+ }
1674
1685
 
1675
- pointers.putArray("markers", markers);
1676
- // todo: use Fabric events
1677
- // manager.pushEvent(context, this, "onKmlReady", pointers);
1686
+ pointers.putArray("markers", markers);
1687
+ // todo: use Fabric events
1688
+ // manager.pushEvent(context, this, "onKmlReady", pointers);
1678
1689
 
1679
- } catch (XmlPullParserException | IOException | InterruptedException |
1680
- ExecutionException e) {
1681
- e.printStackTrace();
1690
+ } catch (XmlPullParserException | IOException | InterruptedException |
1691
+ ExecutionException e) {
1692
+ e.printStackTrace();
1693
+ }
1694
+ } else {
1695
+ this.kmlSrc = kmlSrc;
1682
1696
  }
1683
1697
  }
1684
1698
 
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "main": "lib/index.js",
6
6
  "author": "Leland Richardson <leland.m.richardson@gmail.com>",
7
7
  "homepage": "https://github.com/react-native-maps/react-native-maps#readme",
8
- "version": "1.21.0-alpha.72",
8
+ "version": "1.21.0-alpha.73",
9
9
  "license": "MIT",
10
10
  "scripts": {
11
11
  "lint": "eslint . --max-warnings 0",