Docs › Get started
Website kit
The Wazli Maps website kit: one script and one stylesheet that add the Wazli map, an address search box, nearby places and directions to any web page.
Add the kit
The kit is one script (global WazliMaps) and one stylesheet. The map engine (MapLibre) is inside it, so you need nothing else.
HTML
<link rel="stylesheet" href="https://map.wazli.com/maps/v1/wazli-maps.css">
<script src="https://map.wazli.com/maps/v1/wazli-maps.js"></script>WazliMaps.createMap
Makes a map in a box with a height. It returns a MapLibre map, so everything MapLibre offers works on it.
| Option | What it is |
|---|---|
key | Your website key (with the Map product). |
center | [longitude, latitude] of the starting point. |
zoom | Starting zoom, 12 if left out. |
look | "light" (default) or "dark". |
lang | "en" (default) or "ar": the language of the map's labels. |
style | The name of one of your Map styles (brand looks). |
WazliMaps.autocomplete
Turns an input into an address search box: suggestions after 2 letters, arrow keys, Enter and Escape, right to left in Arabic. Needs a key with Autocomplete.
| Option | What it is |
|---|---|
key | Your website key (with Autocomplete). |
onSelect | Called with the place the person picked. |
lang | "en" or "ar". |
near | { lat, lng } to rank close places first. |
limit | How many suggestions to show. |
Other calls
| Call | Answers |
|---|---|
WazliMaps.geocode(text, { key }) | { results: Place[] } |
WazliMaps.reverse(lat, lng, { key }) | { result: Place | null } |
WazliMaps.nearby({ lat, lng }, type, { key, radius, unit }) | { results } closest first, each with distance in miles (unit "mi", the default) or kilometres ("km") |
WazliMaps.directions({ from, to, mode, unit, avoid }, { key }) | { route } |
Every call returns a promise. When the API refuses, the promise rejects with { code, message }; the codes are on the Errors page.
Everything together
HTML
<link rel="stylesheet" href="https://map.wazli.com/maps/v1/wazli-maps.css">
<script src="https://map.wazli.com/maps/v1/wazli-maps.js"></script>
<div id="map" style="height: 400px"></div>
<input id="address" placeholder="Search an address">
<script>
const key = "YOUR_WEBSITE_KEY";
const map = WazliMaps.createMap("map", { key, center: [-81.379, 28.538], lang: "en" });
WazliMaps.autocomplete("#address", {
key,
onSelect: (place) => map.flyTo({ center: [place.lng, place.lat], zoom: 15 }),
});
WazliMaps.nearby({ lat: 28.538, lng: -81.379 }, "mosque", { key, radius: 2, unit: "mi" })
.then(({ results }) => console.log(results))
.catch((error) => console.error(error.code, error.message));
</script>