Implements Custom Tile Layer
#1121 adds default tile layer and allows user to pass a tile object to map
This commit is contained in:
parent
a4e60540ae
commit
a6047a9341
@ -14,6 +14,11 @@ import 'leaflet/dist/leaflet.css';
|
|||||||
import * as L from 'leaflet';
|
import * as L from 'leaflet';
|
||||||
|
|
||||||
export type MapProps = {
|
export type MapProps = {
|
||||||
|
tile?: {
|
||||||
|
attribution?: string;
|
||||||
|
url: string;
|
||||||
|
data?: any;
|
||||||
|
};
|
||||||
layers: {
|
layers: {
|
||||||
data: GeospatialData;
|
data: GeospatialData;
|
||||||
name: string;
|
name: string;
|
||||||
@ -37,6 +42,11 @@ export type MapProps = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export function Map({
|
export function Map({
|
||||||
|
tile = {
|
||||||
|
url: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
|
||||||
|
attribution:
|
||||||
|
'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
|
||||||
|
},
|
||||||
layers = [
|
layers = [
|
||||||
{
|
{
|
||||||
data: null,
|
data: null,
|
||||||
@ -144,10 +154,7 @@ export function Map({
|
|||||||
map.target.fitBounds(layerToZoomBounds);
|
map.target.fitBounds(layerToZoomBounds);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<TileLayer
|
<TileLayer url={tile.url} attribution={tile.attribution} {...tile.data} />
|
||||||
attribution='© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
|
||||||
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
|
|
||||||
/>
|
|
||||||
<LayersControl position="bottomright">
|
<LayersControl position="bottomright">
|
||||||
{layers.map((layer) => {
|
{layers.map((layer) => {
|
||||||
const data = layersData.find(
|
const data = layersData.find(
|
||||||
|
|||||||
@ -43,6 +43,13 @@ type Story = StoryObj<MapProps>;
|
|||||||
export const GeoJSONPolygons: Story = {
|
export const GeoJSONPolygons: Story = {
|
||||||
name: 'GeoJSON polygons map',
|
name: 'GeoJSON polygons map',
|
||||||
args: {
|
args: {
|
||||||
|
tile : {
|
||||||
|
url : 'https://tiles.stadiamaps.com/tiles/alidade_satellite/{z}/{x}/{y}{r}.{ext}',
|
||||||
|
attribution:'© CNES, Distribution Airbus DS, © Airbus DS, © PlanetObserver (Contains Copernicus Data) | © <a href="https://www.stadiamaps.com/" target="_blank">Stadia Maps</a> © <a href="https://openmaptiles.org/" target="_blank">OpenMapTiles</a> © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
|
||||||
|
data: {
|
||||||
|
ext: 'jpg'
|
||||||
|
}
|
||||||
|
},
|
||||||
layers: [
|
layers: [
|
||||||
{
|
{
|
||||||
data: {
|
data: {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user