How can I use Mapbox Geocoder without map?
When I remove the map code, the autocomplete text field disappears.
What I have tried is (Which is not working for me):
<div id="geocoder"></div>
mapboxgl.accessToken = 'pk.eyJ1IjoiaGFzc2Fuc2FyZGFyYmFuZ2FzaCIsImEiOiJjazg3MHNldWowbGllM2hvMGloMGY0MXd0In0.baO5lzQ8q4al4T0rDAloQA';
var geocoder = new MapboxGeocoder({
accessToken: mapboxgl.accessToken,
mapboxgl: mapboxgl
});
geocoder.on('select', function (data) {
geocoder._toggle()
})
geocoder.on('result', function(result) {
console.log(result);
})
document.getElementById('geocoder');
How can I manage to use only Geocoder autocomplete, with out showing map?
Here is my working fiddle: