Skip to content

Commit

Permalink
add labels
Browse files Browse the repository at this point in the history
  • Loading branch information
almccon committed Jul 12, 2024
1 parent dbf7019 commit e38b1e7
Showing 1 changed file with 156 additions and 1 deletion.
157 changes: 156 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<button id="fly">Zoom in/out</button>
<script>
const start = 22;
const end = 3;
const end = 2;
const target = [0, 0];
const map = new maplibregl.Map({
container: 'map',
Expand Down Expand Up @@ -66,6 +66,66 @@

map.once("load", () => {

map.addSource("null-island-nixta-label-point", {
type: "geojson",
data: {
'type': 'FeatureCollection',
'features': [
{
'type': 'Feature',
'geometry': {
'type': 'Point',
'coordinates': [0, -0.05]
},
'properties': {
'name':
"Null Island\nnixta's version\ncirca 2014",
}
}
]
}
});

map.addSource("null-island-original-label-point", {
type: "geojson",
data: {
'type': 'FeatureCollection',
'features': [
{
'type': 'Feature',
'geometry': {
'type': 'Point',
'coordinates': [0, -0.0004]
},
'properties': {
'name':
"Null Island\noriginal version\ncirca 2010",
}
}
]
}
});

map.addSource("null-island-natural-earth-label-point", {
type: "geojson",
data: {
'type': 'FeatureCollection',
'features': [
{
'type': 'Feature',
'geometry': {
'type': 'Point',
'coordinates': [0, -0.00001]
},
'properties': {
'name':
"Null Island\nNatural Earth version\ncirca 2011",
}
}
]
}
});

map.addSource("null-island-nixta", {
type: "geojson",
data: "data/null-island-nixta.geojson"
Expand All @@ -82,6 +142,37 @@
}
});

map.addLayer({
id: "null-island-nixta-label",
type: "symbol",
source: "null-island-nixta-label-point",
minzoom: 9,
maxzoom: 13,
layout: {
"symbol-placement": "point",
"text-font": ["Inter Regular"],
"text-field": ['get', 'name'],
"text-size": [
'interpolate',
['exponential', 2],
['zoom'],
9, 6,
13, 96
]
},
paint: {
"text-opacity": [
'interpolate',
['linear'],
['zoom'],
9, 0,
10, 1,
12, 1,
13, 0
]
}
});

map.addSource("null-island-original", {
type: "geojson",
data: "data/null-island-original.geojson"
Expand All @@ -98,6 +189,37 @@
}
});

map.addLayer({
id: "null-island-original-label",
type: "symbol",
source: "null-island-original-label-point",
minzoom: 16,
maxzoom: 20,
layout: {
"symbol-placement": "point",
"text-font": ["Inter Regular"],
"text-field": ['get', 'name'],
"text-size": [
'interpolate',
['exponential', 2],
['zoom'],
16, 6,
20, 96
]
},
paint: {
"text-opacity": [
'interpolate',
['linear'],
['zoom'],
16, 0,
17, 1,
19, 1,
20, 0
]
}
});

map.addSource("null-island-natural-earth", {
type: "geojson",
data: "data/null-island-natural-earth.geojson"
Expand All @@ -113,6 +235,39 @@
"fill-outline-color": "black",
}
});

map.addLayer({
id: "null-island-natural-earth-label",
type: "symbol",
source: "null-island-natural-earth-label-point",
minzoom: 20,
maxzoom: 24,
layout: {
"symbol-placement": "point",
"text-font": ["Inter Regular"],
"text-field": ['get', 'name'],
"text-size": [
'interpolate',
['exponential', 2],
['zoom'],
20, 3,
24, 48
]
},
paint: {
"text-opacity": [
'interpolate',
['linear'],
['zoom'],
20, 0,
21, 1,
23, 1,
24, 0
]
}
});

map.showCollisionBoxes(true);
});

let isAtStart = true;
Expand Down

0 comments on commit e38b1e7

Please sign in to comment.