UNPKG

612 BJavaScriptView Raw
1import { createElementObject, createTileLayerComponent, updateGridLayer, withPane } from '@react-leaflet/core';
2import { TileLayer as LeafletTileLayer } from 'leaflet';
3export const TileLayer = createTileLayerComponent(function createTileLayer({ url , ...options }, context) {
4 const layer = new LeafletTileLayer(url, withPane(options, context));
5 return createElementObject(layer, context);
6}, function updateTileLayer(layer, props, prevProps) {
7 updateGridLayer(layer, props, prevProps);
8 const { url } = props;
9 if (url != null && url !== prevProps.url) {
10 layer.setUrl(url);
11 }
12});