mapbox-gl-geocoder icon indicating copy to clipboard operation
mapbox-gl-geocoder copied to clipboard

add typescript declaration files

Open zanona opened this issue 5 years ago • 6 comments

zanona avatar Jan 07 '20 22:01 zanona

It looks like mapbox-gl-js leaves these to an external repo https://github.com/mapbox/mapbox-gl-js/issues/2440.

That's my preference for here too, since integrating them here raises the barrier to entry for contributors and increases the workload of maintainers which is already stretched thin.

andrewharvey avatar Jan 21 '20 10:01 andrewharvey

Does someone have types for this module?

doylemark avatar Apr 15 '20 01:04 doylemark

https://www.typescriptlang.org/dt/search?search=%40types%2Fmapbox still nothing 🥲

maybe this https://github.com/otris/jsdoc-tsd

olso avatar Jan 18 '21 13:01 olso

There's this gist which may be of use, although it's 4 years old: https://gist.github.com/use-strict/b7363cf9ffbfd0f65582f708d4c22e67

ediblecode avatar Jan 25 '21 21:01 ediblecode

It's on DefinitelyTyped:

https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/mapbox__mapbox-gl-geocoder

Was added on Feb 3, 2021 in https://github.com/DefinitelyTyped/DefinitelyTyped/pull/50964.

janosh avatar Jan 18 '22 09:01 janosh

I'm having an assume with using the geocoder with markers.

  map!: mapboxgl.Map;
  addGeocoder() {
    const geocoder = new MapboxGeocoder({
      accessToken: mapboxToken,
      mapboxgl: this.map,
      marker: true
    });
    this.map.addControl(geocoder, "top-right");
  }

this causes this error

core.js:6498 
        
       ERROR TypeError: this._mapboxgl.Marker is not a constructor

I think it's because they are expecting a mapboxgl instance and not a map instance as highlighted in this answer: https://stackoverflow.com/questions/57467842/getting-error-this-mapboxgl-marker-is-not-a-constructor-when-using-geocoder

Is the type wrong?

weirdyang avatar Jan 30 '22 04:01 weirdyang

Just ran in to the same issue as @weirdyang

Added the Types for mapbox-gl-geocoder but still getting the same constructor error. image

just-Bri avatar May 18 '22 18:05 just-Bri