aboutsummaryrefslogtreecommitdiff
path: root/modern/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-03-18 23:08:18 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2020-03-18 23:08:18 -0700
commit09e0ddc2e567cd38fb1196d3f6e73f48dadc435a (patch)
tree779ef392335323f5dc2542ec5be1f531d3f6b3ce /modern/src
parent3d05383151ad7ce44c6297fc46bf5bf8457db7c6 (diff)
downloadtrackermap-web-09e0ddc2e567cd38fb1196d3f6e73f48dadc435a.tar.gz
trackermap-web-09e0ddc2e567cd38fb1196d3f6e73f48dadc435a.tar.bz2
trackermap-web-09e0ddc2e567cd38fb1196d3f6e73f48dadc435a.zip
Remove leaflet dependency
Diffstat (limited to 'modern/src')
-rw-r--r--modern/src/leaflet/DivIcon.js99
1 files changed, 0 insertions, 99 deletions
diff --git a/modern/src/leaflet/DivIcon.js b/modern/src/leaflet/DivIcon.js
deleted file mode 100644
index 6673c56f..00000000
--- a/modern/src/leaflet/DivIcon.js
+++ /dev/null
@@ -1,99 +0,0 @@
-import React, {Component} from 'react';
-import {render} from 'react-dom';
-import {DivIcon, marker} from 'leaflet';
-import {MapLayer, withLeaflet} from 'react-leaflet';
-import PropTypes from 'prop-types';
-
-function createContextProvider(context) {
- class ContextProvider extends Component {
- getChildContext() {
- return context;
- }
-
- render() {
- return this.props.children;
- }
- }
-
- ContextProvider.childContextTypes = {};
- Object.keys(context).forEach(key => {
- ContextProvider.childContextTypes[key] = PropTypes.any;
- });
- return ContextProvider;
-}
-
-export class Divicon extends MapLayer {
- static propTypes = {
- opacity: PropTypes.number,
- zIndexOffset: PropTypes.number,
- }
-
- static childContextTypes = {
- popupContainer: PropTypes.object,
- }
-
- getChildContext() {
- return {
- popupContainer: this.leafletElement,
- }
- }
-
- // See https://github.com/PaulLeCam/react-leaflet/issues/275
- createLeafletElement(newProps) {
- const {map: _map, layerContainer: _lc, position, ...props} = newProps;
- this.icon = new DivIcon(props);
- return marker(position, {icon: this.icon, ...props});
- }
-
- updateLeafletElement(fromProps, toProps) {
- if (toProps.position !== fromProps.position) {
- this.leafletElement.setLatLng(toProps.position);
- }
- if (toProps.zIndexOffset !== fromProps.zIndexOffset) {
- this.leafletElement.setZIndexOffset(toProps.zIndexOffset);
- }
- if (toProps.opacity !== fromProps.opacity) {
- this.leafletElement.setOpacity(toProps.opacity);
- }
- if (toProps.draggable !== fromProps.draggable) {
- if (toProps.draggable) {
- this.leafletElement.dragging.enable();
- }
- else {
- this.leafletElement.dragging.disable();
- }
- }
- }
-
- componentDidMount() {
- super.componentDidMount();
- this.renderComponent();
- }
-
- componentDidUpdate(fromProps) {
- this.renderComponent();
- this.updateLeafletElement(fromProps, this.props);
- }
-
- renderComponent = () => {
- const ContextProvider = createContextProvider({...this.context, ...this.getChildContext()});
- const container = this.leafletElement._icon;
- const component = (
- <ContextProvider>
- {this.props.children}
- </ContextProvider>
- );
- if (container) {
- render(
- component,
- container
- );
- }
- }
-
- render() {
- return null;
- }
-}
-
-export default withLeaflet(Divicon)