Map Display

First steps

Import the Javascript API

Maplink’s Javascript API is publicly available at the url https://maps.maplink.global, and can be included in any web page easily with a tag script:

<script src="https://maps.maplink.global"></script>

Create map object

With the API already imported, all you need to do to render a map is define a div element on your page, and create an instance of the MaplinkMap class associated with this element.

The class constructor waits for two mandatory arguments: the Maplink api key(client_id used for API authentication), and the id of the div element where the map will be rendered.

<div id="map"></div>
<script>
const apiKey = "[CHAVE DE API]";
const maplink = new MaplinkMap(apiKey, "map");
</script>

A third settings argument can optionally be passed when building the map. This argument must be an object, where each property corresponds to a configuration definition.

The options available are:

  • renderType – Accepts string values "pbf" and "png". Selects the format in which the map tiles will be sent by the server. By default, the format is protobuf (pbf), which uses the browser’s graphics acceleration feature via the WebGL API. In environments without WebGL support, the png option must be set, otherwise the map cannot be rendered.
  • center – A coordinate object, defining the center point in the initial rendering of the map.
  • zoom – A number that defines the initial zoom level. This value is passed directly to the leaflet instance associated with the map. More information can be found at the link: Zoom levels – Leaflet.