mapbox-gl-inspect
mapbox-gl-inspect copied to clipboard
Mablibre attempt help
Hi lukasmartinelli,
I am trying to make a version of mapbox-gl-inspect that works with the new maplibre-gl-js fork.
For my first attempt I took the already built mapbox-gl-inspect.min.js and did a string replace on all mapbox text (except classes). This was successful and that version is here https://raw.githubusercontent.com/acalcutt/maplibre-gl-inspect/master/dist/maplibre-gl-inspect.min.js
However, I noticed the version I had modified was a bit out of date so I wanted to make a newer version. I made this fork here ( https://raw.githubusercontent.com/acalcutt/maplibre-gl-inspect/ ). It is mostly working except I can't seem to get the popup to work.
I see the following error, which seems to be trying to append html into the popup, which seems to be null...I'm guessing this is because the popup does not exists.
Uncaught TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'.
at o.setDOMContent (popup.js:426)
at u._onMousemove (maplibre-gl-inspect.min.js:177)
at r.Ct.fire (evented.js:119)
at Fo.mousemove (map_event.js:118)
at gr.handleEvent (handler_manager.js:325)
However as far as i can tell I have changed what would be needed to make a popup in maplibere ( window.maplibregl.Popup ).
I'm not seeing any errors and I was wondering if you have any ideas why the popup piece is not working (everything else seemed to be working as far as I can tell)
This is the version I compiled from the source at https://raw.githubusercontent.com/acalcutt/maplibre-gl-inspect that is not working maplibre-gl-inspect_broken.zip
Wondering if you might have any tips for what the issue may be... its mostly working so maybe I changed something obvious.
Edit: the one I modified by hand can be seen working here ( https://wifidb.net/wifidb/opt/map.php?func=wifidbmap&labeled=0&sig_label=none ).
I've managed to get the Maplibre version working for the most part, though I had to revert a few geojson and raster-dem changes to make it work with my site.
I just wanted to let you know, the popup issue I mentioned above was actually due to a typo in the latest source code.
In this code in MapboxInspect.js
if (!this._popupBlocked && this._popup) {
if (!features.length) {
this._popup.remove();
} else {
this._popup.setLngLat(e.lngLat);
var renderedPopup = this.options.renderPopup(features);
if (typeof renderPopup === 'string') {
this._popup.setHTML(renderedPopup);
} else {
this._popup.setDOMContent(renderedPopup);
}
this._popup.addTo(this._map);
}
}
};
the
if (typeof renderPopup === 'string') {
should be
if (typeof renderedPopup === 'string') {