Skip to content

Commit

Permalink
feat: close popup method
Browse files Browse the repository at this point in the history
  • Loading branch information
turban committed Nov 25, 2019
1 parent dd4c148 commit 070df2b
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,25 +258,27 @@ export class Map extends Evented {
this._layers.sort((a, b) => a.getIndex() - b.getIndex())

for (let i = 1; i < this._layers.length; i++) {
// console.log('moveToTop', this._layers[i])
this._layers[i].moveToTop()
}
}
}

// console.log('style', this._mapgl.getStyle().layers);
openPopup(content, lnglat, onClose) {
this._popup = new mapboxgl.Popup()
.setLngLat(lnglat)
.setDOMContent(content)
.addTo(this._mapgl)

/*
setTimeout(() => {
console.log('style II', this._mapgl.getStyle().layers);
}, 500)
*/
if (typeof onClose === 'function') {
this._popup.once('close', onClose)
}
}

openPopup(content, coordinates) {
new mapboxgl.Popup()
.setLngLat(coordinates)
.setHTML(content)
.addTo(this._mapgl)
closePopup() {
if (this._popup) {
this._popup.remove()
this._popup = null
}
}

_createClickEvent(evt) {
Expand Down

0 comments on commit 070df2b

Please sign in to comment.