Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mablibre attempt help #24

Closed
acalcutt opened this issue Apr 23, 2021 · 1 comment
Closed

Mablibre attempt help #24

acalcutt opened this issue Apr 23, 2021 · 1 comment

Comments

@acalcutt
Copy link

acalcutt commented Apr 23, 2021

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 ).

@acalcutt
Copy link
Author

acalcutt commented Oct 7, 2021

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') {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant