mapbox-gl-geocoder
mapbox-gl-geocoder copied to clipboard
add typescript declaration files
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.
Does someone have types for this module?
https://www.typescriptlang.org/dt/search?search=%40types%2Fmapbox still nothing 🥲
maybe this https://github.com/otris/jsdoc-tsd
There's this gist which may be of use, although it's 4 years old: https://gist.github.com/use-strict/b7363cf9ffbfd0f65582f708d4c22e67
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.
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?
Just ran in to the same issue as @weirdyang
Added the Types for mapbox-gl-geocoder but still getting the same constructor error.