Wazli Maps Docs

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.

OptionWhat it is
keyYour website key (with the Map product).
center[longitude, latitude] of the starting point.
zoomStarting zoom, 12 if left out.
look"light" (default) or "dark".
lang"en" (default) or "ar": the language of the map's labels.
styleThe name of one of your Map styles (brand looks).

Other calls

CallAnswers
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>