Style not found error when displaying date-valued features in local time zone in Mapbox GL JS
0 reputation · 08 Mar 2021, 03:26 UTC
0 reputation · 08 Mar 2021, 03:26 UTC
When building a Mapbox GL JS map that visualizes temporal data, developers must ensure two independent concerns: the style URL remains valid to avoid the "Style not found" error, and date‑valued feature properties are shown in the desired local time zone. The library does not provide a built‑in expression for time‑zone conversion, so timestamps must be adjusted before they are used in data‑driven styles or before they are added to the GeoJSON source. However, it is unclear whether conversion should happen upstream (when preparing the source) or downstream (inside style expressions), and how to keep the style URL unchanged while performing client‑side date manipulation. This uncertainty raises questions about the safest workflow to prevent both styling failures and incorrect temporal displays.
What is the recommended point in the data pipeline to apply manual time‑zone conversion to feature timestamps? How can developers confirm that the style URL stays valid when the source is updated with converted timestamps? Are there patterns that guarantee correct local‑time rendering without triggering a "Style not found" error?
35275 reputation · 08 Mar 2021, 06:59 UTC
Where to convert timestamps? Convert them in the data‑preparation phase, i.e. before you call map.addSource or source.setData. The style URL is independent of the source data, so changing the source cannot invalidate the style.
How to confirm the style URL stays valid? Verify the style request in the Network tab (HTTP 200). The style URL must be a valid mapbox://styles/… identifier and your access token must have the styles:read scope. Updating the source never triggers a style fetch, so no new error will appear unless the style URL itself is wrong.
Patterns that guarantee correct local‑time rendering without style errors:
2026-10-14T12:00:00Z).luxon or Date.prototype.toLocaleString with timeZone).map.addSource or source.setData.get and format it with to-string or string concatenation. No time‑zone logic is needed in the expression.const sourceData = {
type: 'FeatureCollection',
features: originalFeatures.map(f => ({
...f,
properties: {
...f.properties,
localTime: luxon.DateTime.fromISO(f.properties.utcTime, {zone: 'America/New_York'}).toLocaleString(luxon.DateTime.DATETIME_SHORT)
}
}))
};
map.addSource('events', {type: 'geojson', data: sourceData});
map.addLayer({
id: 'event-label',
type: 'symbol',
source: 'events',
layout: {
'text-field': ['get', 'localTime'],
'text-size': 12
}
});
localTime property of a few features before setData to ensure it is already in the desired format.mapbox://styles/mapbox/streets-v12) and see if the error persists.Does your style URL contain a custom style ID that might have been deleted or renamed? If the style error persists after confirming the URL, please share the exact style ID and the token’s scopes. That information will help pinpoint whether the issue is with the style itself or with the data pipeline.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.