From 79c9d84c4145e2d376abcf15b008f621671eb11a Mon Sep 17 00:00:00 2001 From: msamitahir Date: Sun, 5 Mar 2017 22:40:01 +0800 Subject: [PATCH 1/3] Dynamic updates to markers array using dom-repeat The current version is not able to handle changes to array of markers added via dom-repeat template. Updated the listener to observe 'iron-items-changed' event at line 534. The listener is now able to update all the markers when there is a change in items array. Please note that this code does not update the info window content. The following code now works correctly. google-map map="{{map}}" api-key=xxxx latitude="[[lat]]" longitude="[[lon]]"> --- google-map.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/google-map.html b/google-map.html index 4fbb6a9..ce58729 100644 --- a/google-map.html +++ b/google-map.html @@ -531,7 +531,7 @@ if (this._markersChildrenListener) { return; } - this._markersChildrenListener = this.listen(this.$.selector, 'items-changed', '_updateMarkers'); + this._markersChildrenListener = this.listen(this.$.selector, 'iron-items-changed', '_updateMarkers'); }, _updateMarkers: function() { From 3e30913449c4ab556a5706df5726789f09080290 Mon Sep 17 00:00:00 2001 From: msamitahir Date: Mon, 6 Mar 2017 22:22:20 +0800 Subject: [PATCH 2/3] Dynamic update to infowindow in dom-repeat Currently when using dom-repeat template, the info windows are not updated when the item array is updated. This change to mutation observer allows the info window content to update automatically. --- google-map-marker.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/google-map-marker.html b/google-map-marker.html index e28503e..747780b 100644 --- a/google-map-marker.html +++ b/google-map-marker.html @@ -394,7 +394,8 @@ this._contentObserver = new MutationObserver( this._contentChanged.bind(this)); this._contentObserver.observe( this, { childList: true, - subtree: true + subtree: true, + characterData: true }); var content = this.innerHTML.trim(); From da92b504fa778f2dc80b519a4da70a5859ddf1e8 Mon Sep 17 00:00:00 2001 From: msamitahir Date: Wed, 8 Mar 2017 09:38:21 +0800 Subject: [PATCH 3/3] update detached to remove listener --- google-map.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/google-map.html b/google-map.html index ce58729..8d2af0f 100644 --- a/google-map.html +++ b/google-map.html @@ -457,7 +457,7 @@ detached: function() { if (this._markersChildrenListener) { - this.unlisten(this.$.selector, 'items-changed', '_updateMarkers'); + this.unlisten(this.$.selector, 'iron-items-changed', '_updateMarkers'); this._markersChildrenListener = null; } if (this._objectsMutationObserver) {