问题
I want to add the mapbox geocoding feature to my web app but when I try to initialize it the error comes in.
I've tried searching almost on every library inside the node_modules/mapbox-gl-geocoder for some constructor or something to see if I'm importing the wrong library but no success, If tried reading in the documentation but nothing either.
import { MapboxGeocoder } from "mapbox-gl-geocoder";
.
.
.
this.map.addControl(new MapboxGeocoder({
accessToken: mapboxgl.accessToken
}));
回答1:
import * as MapboxGeocoder from '@mapbox/mapbox-gl-geocoder';
Solved the problem by replacing the current import with the one above.
来源:https://stackoverflow.com/questions/54702192/mapboxgeocoder-is-not-a-constructor-when-trying-to-initialize-a-mapboxgeocoder