Style and share a map
Design how your dataset looks, save it as a MapScale style, and load or share it with one URL.
Intermediate
Design the overlay
A saved style is the MapScale streets basemap plus an overlay of MapLibre layers that draw your datasets. Write the overlay as an array of layer objects (fill, line, circle, heatmap or symbol) with paint and filter expressions. Each layer's source is a dataset tileset id (ds_...). This example sizes and colors points by a staff count property.
[
{
"id": "branches-by-staff",
"type": "circle",
"source": "ds_YOUR_DATASET_ID",
"paint": {
"circle-color": ["step", ["get", "staff"], "#94a3b8", 10, "#0c4a4a", 30, "#b45309"],
"circle-radius": ["interpolate", ["linear"], ["get", "staff"], 0, 4, 50, 14]
}
}
]Save the style
POST the name and overlay with a secret key. The response includes a styleId (st_...) to use in the style URL. Saved styles are private to your account unless you set public to true.
curl -X POST "https://api.mapscale.io/v1/styles" \
-H "x-api-key: sk_live_YOUR_SECRET_KEY" \
-H "content-type: application/json" \
-d '{
"name": "Branches by staff",
"overlay": [
{
"id": "branches-by-staff",
"type": "circle",
"source": "ds_YOUR_DATASET_ID",
"paint": { "circle-color": "#0c4a4a", "circle-radius": 8 }
}
]
}'
# The response includes "styleId": "st_<uuid>"Load it in MapLibre
A saved style is served like the built-in styles: pass its URL as the map style with a publishable key.
const key = "pk_live_YOUR_PUBLISHABLE_KEY"
const map = new maplibregl.Map({
container: "map",
// A saved style is a complete MapLibre style: the streets basemap plus your overlay.
style: "https://api.mapscale.io/styles/v1/st_YOUR_STYLE_ID?key=" + key,
center: [100.5018, 13.7563],
zoom: 5,
})Share it
To let people outside your account open the style, save it with public set to true. A style does not change who can read dataset tiles, so upload the dataset with public=true as well if viewers use their own key. Keep the OpenStreetMap attribution visible on any shared map.
# Make the style readable by any key, then share its URL (with your own pk_ key appended).
curl -X POST "https://api.mapscale.io/v1/styles" \
-H "x-api-key: sk_live_YOUR_SECRET_KEY" \
-H "content-type: application/json" \
-d '{ "name": "Branches (shared)", "public": true, "overlay": [ ... ] }'
# People who open it with their own key also need to read the dataset tiles,
# so upload the dataset with public=true as well:
# POST /v1/datasets?name=Branches&public=true