From 6524dafa673206616756388962dc54533306613d Mon Sep 17 00:00:00 2001 From: Paola De Bartolo Date: Thu, 29 Feb 2024 16:19:19 -0300 Subject: [PATCH] feat: add support for custom control buttons --- google-map.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/google-map.js b/google-map.js index 1856401..67d6dbd 100644 --- a/google-map.js +++ b/google-map.js @@ -532,7 +532,16 @@ Polymer({ customRenderer: { type: Object, value: null - } + }, + + /** + * Custom controls buttons to be added to the map. + */ + customControls: { + type: Array, + value: null, + observer: '_loadCustomControls', + }, }, listeners: { @@ -599,6 +608,7 @@ Polymer({ this._loadMarkersCluster(); this._updateObjects(); this._addMapListeners(); + this._loadCustomControls(); this.fire('google-map-ready'); }, @@ -954,6 +964,18 @@ Polymer({ } }, + _loadCustomControls() { + if(this.map) { + for (var i = 0, control; control = this.customControls[i]; ++i) { + const customControlDiv = document.createElement("div"); + const customControlSlot = document.createElement("slot"); + customControlSlot.name = "customControlSlot_" + control.id; + customControlDiv.appendChild(customControlSlot); + this.map.controls[google.maps.ControlPosition[control.position]].push(customControlDiv); + } + } + }, + attributeChanged(attrName) { if (!this.map) { return;