Step 4 - Adding More Control (Intermediate)

Using Maptiks is as simple as adding the scripts to your library block, but that just puts it into automatic. Like a top end sports car, you'll get the best performance by learning how to use it in manual.

Maptiks identifies everything by its URL by default, so to prevent data fragmentation from name changes and folder moves, lock in its identity by attaching the property maptiks_id to tracked maps and layers. This also has the benefit of displaying a more readable name on your reports.

Identifying a map

// a leaflet map without any layers
var map = new L.Map('map-canvas', {
  center: [55, -100],
  zoom: 4,
  maptiks_id: 'My Leaflet Map'

Don't forget to add layers too!

// a leaflet XYZ layer
var layer = L.tileLayer('http://{s}{z}/{x}/{y}.png', { attribution: '&copy; <a href="' + 'copyright">OpenStreetMap</a> contributors', maptiks_id: 'My Tile Layer' }).addTo(map);