admin管理员组文章数量:1127055
I am working on a UI that will have a map integration written in react. The code is very simple:
return (
<TileLayer
attribution='© <a href=";>OpenStreetMap</a> contributors'
url="https://{s}.tile.openstreetmap/{z}/{x}/{y}.png"
/>
);
However I want the source to sometimes be from a different map, the idea is that the important parts of the map can be cached and viewed even when offline (this project will only run locally)
So something like this
if(0<=x<=5 && 8<=y<=12)
return (
<TileLayer
attribution='© <a href=";>OpenStreetMap</a> contributors'
url="https://localhost/{z}/{x}/{y}.png"
/>
);
else
return (
<TileLayer
attribution='© <a href=";>OpenStreetMap</a> contributors'
url="https://{s}.tile.openstreetmap/{z}/{x}/{y}.png"
/>
);
The problem with this javascript-like pseudo code is that I don't have access to x, y and z. Is there a way to get these values when creating a request?
本文标签: javascriptHow to change leafletjs source based on locationStack Overflow
版权声明:本文标题:javascript - How to change leaflet.js source based on location - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736690317a1947891.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论