diff --git a/examples/Spinner.tsx b/examples/Spinner.tsx
index 909d542..e2bec6f 100644
--- a/examples/Spinner.tsx
+++ b/examples/Spinner.tsx
@@ -5,13 +5,19 @@ import spinnerIcon from './svg/pacman.svg';
import 'ol/ol.css';
export default function Layers(): JSX.Element {
- const [loading, setLoading] = React.useState(0);
+ const [loading, setLoading] = React.useState(true);
+ const showSpinner = React.useCallback(() => setLoading(true), [setLoading]);
+ const hideSpinner = React.useCallback(() => setLoading(false), [setLoading]);
+ const origin = React.useMemo(() => ({center: fromLonLat([2.364, 48.82]), zoom: 4}), []);
return (
-
{loading} Loading...
-
extends React.PureComponent
{
debug('installing handler', this, p, newEvents[p]);
const prop = this.getHandlerProp(p);
if (!prop) throw new Error('Internal error');
- handlers[p] = (e: unknown) => this.props[prop].call(this, e);
+ handlers[p] = (e: unknown) => {
+ debug('handling event', e, this, this.props[prop]);
+ return this.props[prop].call(this, e);
+ };
for (const source of eventSources) source.on(p as OLEvent, handlers[p]);
this.incrementHandlers(p);
}
diff --git a/src/RMap.tsx b/src/RMap.tsx
index 6980251..c85cd2e 100644
--- a/src/RMap.tsx
+++ b/src/RMap.tsx
@@ -8,6 +8,7 @@ import {ProjectionLike} from 'ol/proj';
import {RContext} from './context';
import {RlayersBase} from './REvent';
+import debug from './debug';
/** Center and zoom level */
export type RView = {
@@ -78,6 +79,12 @@ export interface RMapProps extends PropsWithChildren extends RlayersBase {
protected refresh(prevProps?: RLayerTileProps): void {
super.refresh(prevProps);
if (prevProps?.tileGrid !== this.props.tileGrid || prevProps?.url !== this.props.url) {
+ debug('replacing source', this);
this.createSource();
this.ol.setSource(this.source);
this.attachOldEventHandlers(this.source);
diff --git a/webpack.config.ts b/webpack.config.ts
index a314e80..37030f5 100644
--- a/webpack.config.ts
+++ b/webpack.config.ts
@@ -23,8 +23,13 @@ const webpackConfig = (env): webpack.Configuration => {
path: path.join(__dirname, '/docs'),
filename: 'bundle.js'
},
- // https://github.com/TypeStrong/ts-loader/issues/751
- ignoreWarnings: [{message: /export .* was not found in/}],
+ ignoreWarnings: [
+ // https://github.com/TypeStrong/ts-loader/issues/751
+ {message: /export .* was not found in/},
+ // OpenLayers + React + rlayers is simply big
+ {message: /asset size exceeds/},
+ {message: /recommended size limit/}
+ ],
module: {
rules: [
{