diff --git a/src/android/plugin/google/maps/PluginPolyline.java b/src/android/plugin/google/maps/PluginPolyline.java index 2d77d6f02..e08d0847d 100644 --- a/src/android/plugin/google/maps/PluginPolyline.java +++ b/src/android/plugin/google/maps/PluginPolyline.java @@ -21,6 +21,10 @@ public class PluginPolyline extends MyPlugin implements MyPluginInterface { private String polylineHashCode; + private String getPolylineHashCode(String polylineId) { + return polylineId.replaceFirst("^polyline_", ""); + } + /** * Create polyline * @param args @@ -157,10 +161,12 @@ public void remove(final JSONArray args, final CallbackContext callbackContext) } pluginMap.objects.remove(id); - id = "polyline_bounds_" + polylineHashCode; - pluginMap.objects.remove(id); + String hashCode = this.getPolylineHashCode(id); + + String boundPropertyKey = "polyline_bounds_" + hashCode; + pluginMap.objects.remove(boundPropertyKey); - String propertyKey = "polyline_property_" + polylineHashCode; + String propertyKey = "polyline_property_" + hashCode; pluginMap.objects.remove(propertyKey); cordova.getActivity().runOnUiThread(new Runnable() { @@ -178,7 +184,8 @@ public void setPoints(final JSONArray args, final CallbackContext callbackContex final Polyline polyline = this.getPolyline(id); // Recalculate the polygon bounds - final String propertyId = "polyline_bounds_" + polylineHashCode; + String hashCode = this.getPolylineHashCode(id); + final String propertyId = "polyline_bounds_" + hashCode; cordova.getActivity().runOnUiThread(new Runnable() { @Override @@ -208,7 +215,8 @@ public void removePointAt(final JSONArray args, CallbackContext callbackContext) final Polyline polyline = this.getPolyline(id); // Recalculate the polygon bounds - final String propertyId = "polyline_bounds_" + polylineHashCode; + String hashCode = this.getPolylineHashCode(id); + final String propertyId = "polyline_bounds_" + hashCode; cordova.getActivity().runOnUiThread(new Runnable() { @Override @@ -239,7 +247,8 @@ public void insertPointAt(final JSONArray args, CallbackContext callbackContext) // Recalculate the polygon bounds - final String propertyId = "polyline_bounds_" + polylineHashCode; + String hashCode = this.getPolylineHashCode(id); + final String propertyId = "polyline_bounds_" + hashCode; cordova.getActivity().runOnUiThread(new Runnable() { @Override @@ -264,6 +273,10 @@ public void setPointAt(final JSONArray args, CallbackContext callbackContext) th final Polyline polyline = this.getPolyline(id); + // Recalculate the polygon bounds + String hashCode = this.getPolylineHashCode(id); + String propertyId = "polyline_bounds_" + hashCode; + cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { @@ -271,8 +284,6 @@ public void run() { if (path.size() > index) { path.set(index, latLng); - // Recalculate the polygon bounds - String propertyId = "polyline_bounds_" + polylineHashCode; pluginMap.objects.put(propertyId, PluginUtil.getBoundsFromPath(path)); polyline.setPoints(path); @@ -312,7 +323,9 @@ public void run() { polyline.setVisible(isVisible); } }); - String propertyId = "polyline_property_" + polylineHashCode; + + String hashCode = this.getPolylineHashCode(id); + String propertyId = "polyline_property_" + hashCode; JSONObject properties = (JSONObject)pluginMap.objects.get(propertyId); properties.put("isVisible", isVisible); pluginMap.objects.put(propertyId, properties);