-
Notifications
You must be signed in to change notification settings - Fork 817
/
Copy pathindex.js
117 lines (105 loc) · 2.39 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import React from 'react';
import ReactDOM from 'react-dom';
import {
Redirect,
Switch,
Link,
Route,
BrowserRouter as Router
} from 'react-router-dom';
import Container from './Container';
import Simple from './components/basic';
import Marker from './components/withMarkers';
import ClickableMarkers from './components/clickableMarkers';
import GooglePlaces from './components/places';
import Autocomplete from './components/autocomplete';
import HeatMap from './components/withHeatMap';
import Polygon from './components/withPolygons';
import Polyline from './components/withPolylines';
import Rectangle from './components/withRectangle';
import CustomEvents from './components/resizeEvent';
const routes = [
{
path: '/basic',
name: 'Simple',
component: Simple
},
{
path: '/markers',
name: 'Marker',
component: Marker
},
{
path: '/clickable_markers',
name: 'Clickable markers',
component: ClickableMarkers
},
{
path: '/places',
name: 'Google places',
component: GooglePlaces
},
{
path: '/autocomplete',
name: 'Autocomplete',
component: Autocomplete
},
{
path: '/heatMap',
name: 'Heat Map',
component: HeatMap
},
{
path: '/polygons',
name: 'Polygon',
component: Polygon
},
{
path: '/polyline',
name: 'Polyline',
component: Polyline
},
{
path: '/rectangle',
name: 'Rectangle',
component: Rectangle
},
{
path: '/onResizeEvent',
name: 'Custom events',
component: CustomEvents
}
];
const createElement = (Component, route) => {
// const pathname = props.location.pathname.replace('/', '');
// const routeDef = routes[pathname];
const newProps = {
key: route.name,
route,
routes,
// pathname,
routeDef: route
// routeDef
};
return <Component {...newProps} />;
};
const Routing = (
<Router>
<Container routes={routes} />
</Router>
);
// <Route render={routeProps => createElement(Container, routeProps)} path="/">
// {Object.keys(routes).map(key => {
// const r = routes[key];
// })}
// </Route>
const mountNode = document.querySelector('#root');
if (mountNode) ReactDOM.render(Routing, mountNode);
else {
const hljs = require('highlight.js');
const codes = document.querySelectorAll('pre code');
for (let i = 0; i < codes.length; i += 1) {
const block = codes[i];
hljs.highlightBlock(block);
}
}