Skip to content

Commit

Permalink
feat: add support for custom control buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
paodb authored and javier-godoy committed Feb 29, 2024
1 parent 9e5af1c commit 6524daf
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion google-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -599,6 +608,7 @@ Polymer({
this._loadMarkersCluster();
this._updateObjects();
this._addMapListeners();
this._loadCustomControls();
this.fire('google-map-ready');
},

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 6524daf

Please sign in to comment.