PaulLeCam / react-leaflet

React components for Leaflet maps
https://react-leaflet.js.org
Other
5.19k stars 887 forks source link

How to custom the request header in TileLayer ? #1080

Closed IHsunChen closed 6 months ago

IHsunChen commented 1 year ago

I have searched google and did not find any usable answer. Can someone help me ?

AhXianGL commented 1 year ago

From the source code perspective of LeafLet Tilelayer, which extends Gridlayer, the tileLayer request is sent via the img HTML tag with its src property as the request's url. you can create a class extends the tileLayer and overrides TileLayer's createTile().

Notion: You're trying to do X, and you thought of solution Y. So you're asking about solution Y, without even mentioning > X. The problem is, there might be a better solution, but we can't know that unless you describe what X is, see "X Y problem"