Getting started
A map on your page takes three steps: get an API key, load the SDK, and create a map. The SDK draws the map, MilsatMaps' own places on top of it, and gives you search and directions.
1. Get an API key
MilsatMaps is in private beta: request access first, and we'll email you when you're in. Then in the console, create a project, then a public key. List the websites the key may be used from, for example https://www.example.com. Add http://localhost:* while you develop.
A public key is visible to anyone who opens your page, and that is fine: it only works from the sites you list. For calls from your own servers, use a secret key instead and keep it out of web pages. See API keys, limits and errors.
2. Load the SDK
With a script tag
One line, nothing to build. Everything is on the global milsat.
<script src="https://sdk.maps.milsat.africa/sdk/v1.js"></script>v1.js always serves the latest 1.x release, so you get fixes without changing anything. To pin an exact version, use its number instead, such as v1.0.0.js.
Open a complete page that uses the script tag.
With npm
npm install @milsat/mapsimport * as milsat from "@milsat/maps";The package is an ES module with TypeScript types. It brings in its own CSS, so there is no stylesheet to import.
3. Create a map
Give the map an element with a height, then create it:
<div id="map" style="height: 400px"></div>const map = new milsat.Map(document.getElementById("map"), {
apiKey: "YOUR_API_KEY",
center: { lat: 6.5244, lng: 3.3792 },
zoom: 13,
});
new milsat.Marker({ position: { lat: 6.5244, lng: 3.3792 }, map, title: "Yaba" });Positions can be written as { lat, lng }, as [lng, lat] like GeoJSON and Mapbox, or as a Google Maps LatLng. The SDK always answers with { lng, lat } objects.
You need to give the key once per page: on the first map, or with milsat.config({ apiKey: "…" }) before using search or directions without a map.