这是我的组件
import React, { PropTypes } from 'react';
import { MapLayer } from 'react-leaflet';
import L from 'leaflet';
import './collision.js';
export default class LayerGroupCollision extends MapLayer {
static childContextTypes = {
layerContainer: PropTypes.shape({
addLayer: PropTypes.func.isRequired,
removeLayer: PropTypes.func.isRequired,
})
}
getChildContext() {
return {
layerContainer: this.leafletElement,
}
}
createLeafletElement() {
var t = L.layerGroup.collision({ margin: 20 }, this.getOptions());
this.layerContainer.addLayer(t);
return t;
}
componentDidMount() {
const {map} = this.context;
map.on("zoomend", this._onZoomEnd);
}
componentWillUnmount() {
const {map} = this.context;
map.off("zoomend", this._onZoomEnd);
}
}
但这不起作用,我只是得到标记。在缩放时我得到错误
未捕获的类型错误:无法读取未定义的属性“调用”
at NewClass.fire (leaflet-src.js:587) at NewClass._moveEnd (leaflet-src.js:3432) at NewClass.<anonymous> (leaflet-src.js:3869)
有什么建议吗?