Skip to content

Commit 7e5fd97

Browse files
committed
Add Highway Link Attributes sample.
1 parent 9b8f137 commit 7e5fd97

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

demo.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import Sample from "openmapsamples/lib/Sample";
55
import Layer from "openmapsamples/lib/Layer";
66
import { ExamplePlaceData, ExampleTransportationData } from "openmapsamples/lib/SampleData/ExampleSampleData";
77
import { default as highwayAttributesSample, sampleData as highwayAttributesSampleData } from "openmapsamples/samples/OpenMapTiles/HighwayAttributes";
8+
import { default as highwayLinkAttributesSample, sampleData as highwayLinkAttributesSampleData } from "openmapsamples/samples/OpenMapTiles/HighwayLinkAttributes";
89
// import MaplibreInspect from "maplibre-gl-inspect";
910
// import "maplibre-gl-inspect/dist/maplibre-gl-inspect.css";
1011

@@ -43,6 +44,21 @@ async function main() {
4344
}
4445
});
4546

47+
// Add our Highway Link Attributes sample.
48+
sampleControl.addSample(highwayLinkAttributesSample);
49+
// Set a custom row-hight callback to give more space to motorways at high zooms.
50+
// This isn't needed for all styles, but the osm-standard style
51+
// inflates widths of motorways and trunk at high zooms.
52+
highwayLinkAttributesSampleData.setRowHeightCallback(function(zoom, row, numRows) {
53+
if (zoom > 18 && row < 2) {
54+
return 24 / numRows / Math.pow(2, zoom - 4);
55+
} else if (zoom > 16 && row < 2) {
56+
return 22 / numRows / Math.pow(2, zoom - 4);
57+
} else {
58+
return 20 / numRows / Math.pow(2, zoom - 4);
59+
}
60+
});
61+
4662
let sample = sampleControl.addSample(
4763
new Sample('example', 'Example', 'This is an example sample showing hand-crafted GeoJSON that mocks OpenMapTiles data. (<a href="https://github.com/adamfranco/OpenMapSamples/blob/main/lib/SampleData/ExampleSampleData.js">source</a>)', [-100.85664, 39.71282], 7)
4864
);

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)