Add search bar to MapLibre or Mapbox GL JS
Estimated reading time: 1 minuteFind usage examples of Jawg Places with MapLibre GL JS and Mapbox GL JS. All options
from <input> examples will work here too, make sure you use the class Maplibre or
Mapbox. When Jawg Places JS is loaded, you can have access to these two classes.
See the class definition for MapLibre or Mapbox.
const map = new maplibregl.Map({
container: "my-map",
style: `https://api.jawg.io/styles/jawg-sunny.json?access-token=<YOUR_ACCESS_TOKEN>`,
center: [0, 0],
zoom: 1,
});
let jawgPlaces = new JawgPlaces.MapLibre({});
// Use it as a Leaflet control plugin, the input will be on the map
map.addControl(jawgPlaces);
// Or as a standalone input that will be connected to de map
jawgPlaces.attachMap(map);