Skip to content

Commit

Permalink
fix: move marker image loading earlier in process
Browse files Browse the repository at this point in the history
* reproducible issues were observed where marker icons don't display at initial zoom, but visible at other zoom levels
  * reproducible on Android browsers
  * also in Firefox desktop with connection throttling set to "Regular 3G"
* caused by marker image not loaded in time
* in theory we can use ['styleimagemissing'](mapbox/mapbox-gl-js#7987) to handle this, but this does not work with image files loaded via callback, only for inline generated images
  • Loading branch information
madwort committed Feb 26, 2021
1 parent f26cb0d commit f71aae2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/components/utilities/map/js/dynamic.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ maps.forEach(container => {
accessToken: process.env.MAPBOX_KEY
})

mapElement.loadImage('/images/marker.png', (error, image) => {
if (!error) {
mapElement.addImage('marker', image)
}
})

mapElement.addControl(new System.NavigationControl())

mapElement.on('load', () => {
mapElement.loadImage('/images/marker.png', (error, image) => {
if (!error) {
mapElement.addImage('marker', image)
}
})

mapElement.addSource('woodlands', {
type: 'geojson',
data: {
Expand Down

0 comments on commit f71aae2

Please sign in to comment.