File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -298,21 +298,29 @@ class BaseMap extends Component {
298298 < LayersControl position = 'topright' >
299299 { /* base layers */
300300 baseLayers && baseLayers . map ( ( layer , i ) => {
301- // Fix tile size/zoom offset: https://stackoverflow.com/a/37043490/915811
302- const retinaProps = L . Browser . retina && layer . hasRetinaSupport
301+ // If layer supports retina tiles, set tileSize and zoomOffset
302+ // (see https://stackoverflow.com/a/37043490/915811).
303+ // Otherwise, use detectRetina to request more tiles (scaled down):
304+ // https://leafletjs.com/reference-1.6.0.html#tilelayer-detectretina
305+ const retinaProps = layer . hasRetinaSupport
303306 ? { tileSize : 512 , zoomOffset : - 1 }
304- : { }
307+ : { detectRetina : true }
308+ // If Browser doesn't support retina, remove @2x from URL so that
309+ // retina tiles are not requested.
310+ const url = L . Browser . retina
311+ ? layer . url
312+ : layer . url . replace ( '@2x' , '' )
305313 return (
306314 < LayersControl . BaseLayer
307315 name = { layer . name }
308316 checked = { i === 0 }
309317 key = { i } >
310318 < TileLayer
311- url = { layer . url }
319+ url = { url }
312320 attribution = { layer . attribution }
313321 maxZoom = { layer . maxZoom }
314322 { ...retinaProps }
315- detectRetina />
323+ />
316324 </ LayersControl . BaseLayer >
317325 )
318326 } )
You can’t perform that action at this time.
0 commit comments