mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2024-12-29 08:20:28 +01:00
For better debuggability, actually keep one popup node around
This commit is contained in:
parent
8f391d7d52
commit
1375240bfa
1 changed files with 6 additions and 6 deletions
|
@ -17,11 +17,9 @@ import '../../libs/mapbox-rtl'
|
||||||
|
|
||||||
const IS_SUPPORTED = MapboxGl.supported();
|
const IS_SUPPORTED = MapboxGl.supported();
|
||||||
|
|
||||||
function renderPopup(popup) {
|
function renderPopup(popup, mountNode) {
|
||||||
var mountNode = document.createElement('div');
|
ReactDOM.render(popup, mountNode);
|
||||||
ReactDOM.render(popup, mountNode)
|
|
||||||
var content = mountNode.innerHTML;
|
var content = mountNode.innerHTML;
|
||||||
ReactDOM.unmountComponentAtNode(mountNode);
|
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,6 +147,8 @@ export default class MapboxGlMap extends React.Component {
|
||||||
const nav = new MapboxGl.NavigationControl();
|
const nav = new MapboxGl.NavigationControl();
|
||||||
map.addControl(nav, 'top-right');
|
map.addControl(nav, 'top-right');
|
||||||
|
|
||||||
|
const tmpNode = document.createElement('div');
|
||||||
|
|
||||||
const inspect = new MapboxInspect({
|
const inspect = new MapboxInspect({
|
||||||
popup: new MapboxGl.Popup({
|
popup: new MapboxGl.Popup({
|
||||||
closeOnClick: false
|
closeOnClick: false
|
||||||
|
@ -164,9 +164,9 @@ export default class MapboxGlMap extends React.Component {
|
||||||
buildInspectStyle: (originalMapStyle, coloredLayers) => buildInspectStyle(originalMapStyle, coloredLayers, this.props.highlightedLayer),
|
buildInspectStyle: (originalMapStyle, coloredLayers) => buildInspectStyle(originalMapStyle, coloredLayers, this.props.highlightedLayer),
|
||||||
renderPopup: features => {
|
renderPopup: features => {
|
||||||
if(this.props.inspectModeEnabled) {
|
if(this.props.inspectModeEnabled) {
|
||||||
return renderPopup(<FeaturePropertyPopup features={features} />);
|
return renderPopup(<FeaturePropertyPopup features={features} />, tmpNode);
|
||||||
} else {
|
} else {
|
||||||
return renderPopup(<FeatureLayerPopup features={features} onLayerSelect={this.props.onLayerSelect} />);
|
return renderPopup(<FeatureLayerPopup features={features} onLayerSelect={this.props.onLayerSelect} />, tmpNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue