Implements Custom Tile Layer

#1121 adds default tile layer and allows user to pass a tile object to map
This commit is contained in:
William Lima
2024-05-13 12:51:28 -01:00
parent a4e60540ae
commit a6047a9341
2 changed files with 18 additions and 4 deletions

View File

@@ -14,6 +14,11 @@ import 'leaflet/dist/leaflet.css';
import * as L from 'leaflet';
export type MapProps = {
tile?: {
attribution?: string;
url: string;
data?: any;
};
layers: {
data: GeospatialData;
name: string;
@@ -37,6 +42,11 @@ export type MapProps = {
};
export function Map({
tile = {
url: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
attribution:
'&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
},
layers = [
{
data: null,
@@ -144,10 +154,7 @@ export function Map({
map.target.fitBounds(layerToZoomBounds);
}}
>
<TileLayer
attribution='&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
/>
<TileLayer url={tile.url} attribution={tile.attribution} {...tile.data} />
<LayersControl position="bottomright">
{layers.map((layer) => {
const data = layersData.find(