Implement network link tag
MODIFY
plugin.xml
plugin.xml
<?xml version='1.0' encoding='utf-8'?>
-<plugin id="cordova-plugin-googlemaps" version="2.1.2-beta-20180109-1800" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
+<plugin id="cordova-plugin-googlemaps" version="2.1.2-beta-20180111-1306" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<name>cordova-plugin-googlemaps</name>
<js-module name="BaseClass" src="www/BaseClass.js">
<runs />

MODIFY
src/android/plugin/google/maps/PluginGroundOverlay.java
src/android/plugin/google/maps/PluginGroundOverlay.java
@@ -28,6 +28,7 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
+import java.util.Calendar;
import java.util.HashMap;
import java.util.Set;
@@ -108,8 +109,9 @@ public class PluginGroundOverlay extends MyPlugin implements MyPluginInterface
AsyncLoadImage.AsyncLoadImageResult result = (AsyncLoadImage.AsyncLoadImageResult)object;
BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(result.image);
options.image(bitmapDescriptor);
+ //options.zIndex(Calendar.getInstance().getTimeInMillis());
GroundOverlay groundOverlay = self.map.addGroundOverlay(options);
- overlayImage.put(groundOverlay.getId(), result.image);
+ overlayImage.put("groundoverlay_" + idBase, result.image);
groundOverlay.setTag("groundoverlay_" + idBase);
@@ -164,7 +166,7 @@ public class PluginGroundOverlay extends MyPlugin implements MyPluginInterface
!objectId.startsWith("groundoverlay_initOpts_") &&
!objectId.startsWith("groundoverlay_bounds_")) {
GroundOverlay groundOverlay = (GroundOverlay) pluginMap.objects.remove(objectId);
- image = overlayImage.remove(groundOverlay.getId());
+ image = overlayImage.remove(objectId);
if (image != null && !image.isRecycled()) {
image.recycle();
}
@@ -223,7 +225,7 @@ public class PluginGroundOverlay extends MyPlugin implements MyPluginInterface
synchronized (pluginMap.objects) {
GroundOverlay groundOverlay = (GroundOverlay) pluginMap.objects.remove(id);
if (groundOverlay != null) {
- Bitmap image = overlayImage.remove(groundOverlay.getId());
+ Bitmap image = overlayImage.remove(id);
if (image != null && !image.isRecycled()) {
image.recycle();
}
@@ -262,13 +264,13 @@ public class PluginGroundOverlay extends MyPlugin implements MyPluginInterface
AsyncLoadImage.AsyncLoadImageResult result = (AsyncLoadImage.AsyncLoadImageResult) object;
GroundOverlay groundOverlay = getGroundOverlay(id);
if (groundOverlay != null) {
- Bitmap currentBmp = overlayImage.remove(groundOverlay.getId());
+ Bitmap currentBmp = overlayImage.remove(id);
if (currentBmp != null) {
currentBmp.recycle();
}
}
if (result.image != null) {
- overlayImage.put(groundOverlay.getId(), result.image);
+ overlayImage.put(id, result.image);
groundOverlay.setImage(BitmapDescriptorFactory.fromBitmap(result.image));
callbackContext.success();
} else {
@@ -294,7 +296,7 @@ public class PluginGroundOverlay extends MyPlugin implements MyPluginInterface
String id = args.getString(0);
final GroundOverlay groundOverlay = (GroundOverlay)pluginMap.objects.get(id);
- String propertyId = "groundoverlay_initOpts_" + groundOverlay.getId();
+ String propertyId = id.replace("groundoverlay_", "groundoverlay_initOpts_");
JSONObject opts = (JSONObject) pluginMap.objects.get(propertyId);
JSONArray points = args.getJSONArray(1);
@@ -309,7 +311,7 @@ public class PluginGroundOverlay extends MyPlugin implements MyPluginInterface
}
});
- String boundsId = "groundoverlay_bounds_" + groundOverlay.getId();
+ String boundsId = id.replace("groundoverlay_", "groundoverlay_bounds_");
pluginMap.objects.put(boundsId, bounds);
callbackContext.success();
@@ -386,7 +388,7 @@ public class PluginGroundOverlay extends MyPlugin implements MyPluginInterface
groundOverlay.setVisible(isVisible);
}
});
- String propertyId = "groundoverlay_property_" + groundOverlay.getId();
+ String propertyId = id.replace("groundoverlay_", "groundoverlay_property_");
JSONObject properties = (JSONObject)pluginMap.objects.get(propertyId);
properties.put("isVisible", isVisible);
pluginMap.objects.put(propertyId, properties);

MODIFY
src/android/plugin/google/maps/PluginKmlOverlay.java
src/android/plugin/google/maps/PluginKmlOverlay.java
@@ -164,7 +164,7 @@ public class PluginKmlOverlay extends MyPlugin implements MyPluginInterface {
ArrayList<Bundle> children;
ArrayList<String> styleIDs;
- Log.d(TAG, "--->tagName = " + tagName + "(" + rootElement + ")");
+ //Log.d(TAG, "--->tagName = " + tagName + "(" + rootElement + ")");
result.putString("tagName", tagName);
KML_TAG kmlTag = null;
@@ -314,7 +314,7 @@ public class PluginKmlOverlay extends MyPlugin implements MyPluginInterface {
InputStream inputStream;
try {
if (urlStr.startsWith("http://") || urlStr.startsWith("https://")) {
- Log.d("PluginKmlOverlay", "---> url = " + urlStr);
+ //Log.d("PluginKmlOverlay", "---> url = " + urlStr);
URL url = new URL(urlStr);
boolean redirect = true;
HttpURLConnection http = null;
@@ -369,7 +369,7 @@ public class PluginKmlOverlay extends MyPlugin implements MyPluginInterface {
} catch (Exception e) {
e.printStackTrace();
}
- Log.d("PluginKmlOverlay", "---> url = " + urlStr);
+ //Log.d("PluginKmlOverlay", "---> url = " + urlStr);
inputStream = new FileInputStream(urlStr);
} else {
if (urlStr.indexOf("file:///android_asset/") == 0) {
@@ -389,7 +389,7 @@ public class PluginKmlOverlay extends MyPlugin implements MyPluginInterface {
} catch (Exception e) {
e.printStackTrace();
}
- Log.d("PluginKmlOverlay", "---> url = " + urlStr);
+ //Log.d("PluginKmlOverlay", "---> url = " + urlStr);
inputStream = cordova.getActivity().getResources().getAssets().open(urlStr);
}

MODIFY
www/KmlLoader.js
www/KmlLoader.js
@@ -70,7 +70,7 @@ console.log(kmlData);
});
var placeMarks = new BaseArrayClass(kmlData.root.children);
- placeMarks.mapSeries(function(placeMark, cb) {
+ placeMarks.mapAsync(function(placeMark, cb) {
self.kmlTagProcess.call(self, {
child: placeMark,
attrHolder: {},
@@ -99,7 +99,7 @@ KmlLoader.prototype.kmlTagProcess = function(params, callback) {
// Read styles if specified
//---------------------------
var styleIDs = new BaseArrayClass(params.child.styleIDs);
- styleIDs.mapSeries(function(styleId, cb) {
+ styleIDs.mapAsync(function(styleId, cb) {
self.getStyleById.call(self, styleId, cb);
}, function(styleSets) {
@@ -410,7 +410,7 @@ KmlLoader.prototype.parseContainerTag = function(params, callback) {
// Generate overlays or load another files...etc
//--------------------------------------------------------
var children = new BaseArrayClass(params.placeMark.children);
- children.mapSeries(function(child, cb) {
+ children.mapAsync(function(child, cb) {
//-------------------------
// Copy parent information
@@ -805,7 +805,7 @@ KmlLoader.prototype.parseGroundOverlayTag = function(params, callback) {
KmlLoader.prototype.parseNetworkLinkTag = function(params, callback) {
var self = this;
var networkLinkOptions = {};
- console.log(params);
+ //console.log(params);
var attrNames = Object.keys(params.attrHolder);
attrNames.forEach(function(attrName) {
@@ -813,7 +813,6 @@ KmlLoader.prototype.parseNetworkLinkTag = function(params, callback) {
case "region":
networkLinkOptions.region = networkLinkOptions.region || {};
params.attrHolder[attrName].children.forEach(function(gChild) {
- console.log(gChild);
switch(gChild.tagName) {
case "latlonaltbox":
var box = {};
@@ -882,7 +881,7 @@ KmlLoader.prototype.parseNetworkLinkTag = function(params, callback) {
}
});
- console.log(networkLinkOptions);
+ //console.log(networkLinkOptions);
if (!networkLinkOptions.link) {
// <networklink> tag must contain <link> tag.
@@ -902,7 +901,6 @@ KmlLoader.prototype.parseNetworkLinkTag = function(params, callback) {
networkOverlay.set("_loaded", false);
networkOverlay.set("_visible", false);
networkOverlay.on("_visible_changed", function(oldValue, newValue) {
-
var overlay = networkOverlay.get("overlay");
if (newValue === true) {
if (overlay) {
@@ -926,17 +924,17 @@ KmlLoader.prototype.parseNetworkLinkTag = function(params, callback) {
self.camera.target.push(networkLinkOptions.region.bounds.sw);
self.camera.target.push(networkLinkOptions.region.bounds.ne);
self.camera.target.push(networkLinkOptions.region.bounds.nw);
- self.map.addPolygon({
- 'points': [
- networkLinkOptions.region.bounds.se,
- networkLinkOptions.region.bounds.sw,
- networkLinkOptions.region.bounds.nw,
- networkLinkOptions.region.bounds.ne
- ],
- 'strokeColor' : '#FFFFFF77',
- 'strokeWidth': 1,
- 'fillColor' : '#00000000'
- },callback);
+ // self.map.addPolygon({
+ // 'points': [
+ // networkLinkOptions.region.bounds.se,
+ // networkLinkOptions.region.bounds.sw,
+ // networkLinkOptions.region.bounds.nw,
+ // networkLinkOptions.region.bounds.ne
+ // ],
+ // 'strokeColor' : '#FFFFFF77',
+ // 'strokeWidth': 1,
+ // 'fillColor' : '#00000000'
+ // }, function(groundoverlay) {
if (networkLinkOptions.region && networkLinkOptions.link.viewrefreshmode === "onRegion") {
self.map.on(event.CAMERA_MOVE_END, function() {
@@ -952,8 +950,6 @@ KmlLoader.prototype.parseNetworkLinkTag = function(params, callback) {
nRegion.contains(vRegion.nearLeft) ||
nRegion.contains(vRegion.nearRight)) {
- if (networkLinkOptions.region.lod.maxlodpixels !== -1 ||
- networkLinkOptions.region.lod.minlodpixels !== -1) {
(new BaseArrayClass([
networkLinkOptions.region.bounds.sw,
networkLinkOptions.region.bounds.ne
@@ -962,19 +958,24 @@ KmlLoader.prototype.parseNetworkLinkTag = function(params, callback) {
}, function(points) {
var width = Math.abs(points[0][0] - points[1][0]);
var height = Math.abs(points[0][1] - points[1][1]);
- if (width <= networkLinkOptions.region.lod.maxlodpixels &&
- height <= networkLinkOptions.region.lod.maxlodpixels &&
+
+ var maxCondition = (networkLinkOptions.region.lod.maxlodpixels === -1 ||
+ width <= networkLinkOptions.region.lod.maxlodpixels &&
+ height <= networkLinkOptions.region.lod.maxlodpixels);
+ var minCondition = (networkLinkOptions.region.lod.minlodpixels === -1 ||
width >= networkLinkOptions.region.lod.minlodpixels &&
- height >= networkLinkOptions.region.lod.minlodpixels) {
+ height >= networkLinkOptions.region.lod.minlodpixels);
+
+ if (maxCondition && minCondition) {
+ // groundoverlay.setVisible(true);
networkOverlay.set("_visible", true);
} else {
+ // groundoverlay.setVisible(false);
networkOverlay.set("_visible", false);
}
}));
} else {
- networkOverlay.set("_visible", true);
- }
- } else {
+ // groundoverlay.setVisible(false);
networkOverlay.set("_visible", false);
}
});
@@ -982,9 +983,13 @@ KmlLoader.prototype.parseNetworkLinkTag = function(params, callback) {
//-------------------------------
// Simply load another kml file
//-------------------------------
+ // groundoverlay.setVisible(true);
networkOverlay.set("_visible", true);
}
- //callback.call(self);
+
+ callback.call(networkOverlay);
+ //});
+
};
KmlLoader.prototype.parseLookAtTag = function(params, callback) {

MODIFY
www/KmlOverlay.js
www/KmlOverlay.js
@@ -204,7 +204,7 @@ KmlOverlay.prototype.setVisible = function(visible) {
children.forEach(function(child) {
if ('setVisible' in child &&
typeof child.setVisible === 'function') {
- child.setVisible();
+ child.setVisible(visible);
return;
}
if (child instanceof BaseArrayClass) {

Implement network link tag