viewof map = {
const container = html`<div style="height:${height}px;">`;
yield container;
const map = container.value = new mapboxgl.Map({
container,
center: [-97.547760, 35.486067],
zoom: 11,
style: "mapbox://styles/mapbox/streets-v9",
scrollZoom: true
});
map.on("load", () => {
var geojson = {
"type": "geojson",
"data": {
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [
[-97.554882, 35.542201],
[-97.617270, 35.482703]
]
},
"properties": {
"title": 'aaaaaa'
}
}, {
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [
[-97.617270, 35.482703],
[-97.535206, 35.427500]
]
},
"properties": {
"title": 'bbbbbb'
}
}, {
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [
[-97.617270, 35.482703],
[-97.491217, 35.476099]
]
},
"properties": {
"title": 'cccccc'
}
}]
}
};
map.addSource("route", geojson);
map.addLayer({
"id": "route",
"type": "line",
"source": "route",
"layout": {
"line-join": "round",
"line-cap": "round"
},
"paint": {
"line-color": "lightgreen",
"line-width": 8
}
});
map.addLayer({
"id": "symbols",
"type": "symbol",
"source": "route",
"layout": {
"symbol-placement": "line-center",
"text-font": ["Open Sans Regular"],
"text-field": '{title}',
"text-size": 16,
"text-rotate": -4,
"symbol-spacing": 1,
},
"paint":{
"text-translate":[0,-20],
}
});
});
invalidation.then(() => map.remove());
}