1

On the web page where the map shows (using Mapbox GL) and I want to add legend. The icons in the mapbox map are in a sprite with the details in JSON. I can see the PNG sprite and JSON in the browser console. The JSON looks like:

"airport-15": { "width": 42, "height": 42, "x": 76, "y": 300, "pixelRatio": 2, "visible": true }

What's the best way to create a CSS class for the marker icons? For performance reasons I'm hoping to avoid loading the PNG image a second time.
.icon-airport-15 {...}

Mapbox sprite documentation

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.