-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
212 lines (190 loc) · 13.7 KB
/
index.html
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<title>COVID-19 Confirmed Cases wit Kepler.gl</title>
<!--Uber Font-->
<link rel="stylesheet" href="css/superfine.css">
<!--MapBox css-->
<link href="css/mapbox-gl.css" rel="stylesheet">
<!-- Load React/Redux -->
<script src="js/react.production.min.js" crossorigin></script>
<script src="js/react-dom.production.min.js" crossorigin></script>
<script src="js/redux.js" crossorigin></script>
<script src="js/react-redux.min.js" crossorigin></script>
<script src="js/styled-components.min.js" crossorigin></script>
<!-- Load Kepler.gl -->
<script src="js/keplergl.min.js" crossorigin></script>
<script src="confirmed.js" crossorigin></script>
<style type="text/css">
body {margin: 0; padding: 0; overflow: hidden;}
</style>
<!--MapBox token-->
<script>
/**
* Provide your MapBox Token
**/
const MAPBOX_TOKEN = 'pk.eyJ1IjoiaWJyYWhpbXNhcmljaWNlayIsImEiOiJjOTY5MzE2YzVkMmY4ZjkxNDZiOWNkMGQ4MDJiZTE3MCJ9.BnJGGOoXAdwicB9shSV_Qg';
const WARNING_MESSAGE = 'Please Provide a Mapbox Token in order to use Kepler.gl. Edit this file and fill out MAPBOX_TOKEN with your access key';
</script>
<!-- GA: Delete this as you wish, However to pat ourselves on the back, we only track anonymous pageview to understand how many people are using kepler.gl. -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-64694404-19', {
'storage': 'none',
'clientId': localStorage.getItem('ga:clientId')
});
ga(function(tracker) {
localStorage.setItem('ga:clientId', tracker.get('clientId'));
});
ga('set', 'checkProtocolTask', null); // Disable file protocol checking.
ga('set', 'checkStorageTask', null); // Disable cookie storage checking.
ga('set', 'historyImportTask', null); // Disable history checking (requires reading from cookies).
ga('set', 'page', 'keplergl-html');
ga('send', 'pageview');
</script>
</head>
<body>
<!-- We will put our React component inside this div. -->
<div id="app">
<!-- Kepler.gl map will be placed here-->
</div>
<!-- Load our React component. -->
<script>
/* Validate Mapbox Token */
if ((MAPBOX_TOKEN || '') === '' || MAPBOX_TOKEN === 'PROVIDE_MAPBOX_TOKEN') {
alert(WARNING_MESSAGE);
}
/** STORE **/
const reducers = (function createReducers(redux, keplerGl) {
return redux.combineReducers({
// mount keplerGl reducer
keplerGl: keplerGl.keplerGlReducer.initialState({
uiState: {
readOnly: false,
currentModal: null
}
})
});
}(Redux, KeplerGl));
const middleWares = (function createMiddlewares(keplerGl) {
return keplerGl.enhanceReduxMiddleware([
// Add other middlewares here
]);
}(KeplerGl));
const enhancers = (function craeteEnhancers(redux, middles) {
return redux.applyMiddleware(...middles);
}(Redux, middleWares));
const store = (function createStore(redux, enhancers) {
const initialState = {};
return redux.createStore(
reducers,
initialState,
redux.compose(enhancers)
);
}(Redux, enhancers));
/** END STORE **/
/** COMPONENTS **/
var KeplerElement = (function makeKeplerElement(react, keplerGl, mapboxToken) {
var LogoSvg = function LogoSvg() {
return react.createElement(
"div",
{ className: "logo-container", style: {position: 'fixed', zIndex: 10000, padding: '4px'} },
react.createElement(
"svg",
{
className: "kepler_gl__logo",
width: "107px",
height: "21px",
viewBox: "0 0 124 24"
},
react.createElement(
"g",
{ transform: "translate(13.500000, 13.500000) rotate(45.000000) translate(-13.500000, -13.500000) translate(4.000000, 4.000000)" },
react.createElement("rect", { x: "0", y: "6", transform: "matrix(2.535181e-06 1 -1 2.535181e-06 18.1107 6.0369)", fill: "#535C6C", width: "12.1", height: "12.1" }),
react.createElement("rect", { x: "6", y: "0", transform: "matrix(2.535182e-06 1 -1 2.535182e-06 18.1107 -6.0369)", fill:"#1FBAD6", width: "12.1", height: "12.1" })
),
react.createElement(
"g",
{},
react.createElement("path", { fill:"#1FBAD6", d: "M39,8.7h2.2l-2.8,4.2l2.9,5.1H39l-2.4-4.2h-1.3V18h-2V5l2-0.1v7.3h1.3L39,8.7z" }),
react.createElement("path", { fill:"#1FBAD6", d: "M42.4,13.3c0-1.5,0.4-2.7,1.1-3.5s1.8-1.2,3.1-1.2c1.3,0,2.2,0.4,2.8,1.1c0.6,0.7,0.9,1.8,0.9,3.3 c0,0.4,0,0.8,0,1.1h-5.8c0,1.6,0.8,2.4,2.4,2.4c1,0,2-0.2,2.9-0.6l0.2,1.7c-0.4,0.2-0.9,0.4-1.4,0.5s-1.1,0.2-1.7,0.2 c-1.5,0-2.6-0.4-3.3-1.2C42.8,16.1,42.4,14.9,42.4,13.3z M46.6,10.1c-0.7,0-1.2,0.2-1.5,0.5c-0.4,0.4-0.6,0.9-0.6,1.7h4 c0-0.8-0.2-1.4-0.5-1.7S47.2,10.1,46.6,10.1z" }),
react.createElement("path", { fill:"#1FBAD6", d: "M57.1,18.2c-1,0-1.8-0.3-2.3-0.9l0,0l0,1.3v2.5h-2V8.7h1.5l0.3,0.9h0c0.3-0.3,0.7-0.6,1.2-0.7 c0.4-0.2,0.9-0.3,1.4-0.3c1.2,0,2.1,0.4,2.7,1.1c0.6,0.7,0.9,2,0.9,3.7c0,1.6-0.3,2.8-1,3.7C59.2,17.8,58.3,18.2,57.1,18.2z M56.7,10.3c-0.4,0-0.8,0.1-1.1,0.2c-0.3,0.2-0.6,0.4-0.8,0.7v4.3c0.2,0.3,0.4,0.5,0.7,0.7c0.3,0.2,0.7,0.3,1.1,0.3 c0.7,0,1.2-0.2,1.6-0.7c0.4-0.5,0.5-1.3,0.5-2.5c0-0.8-0.1-1.4-0.2-1.8s-0.4-0.7-0.7-0.9C57.6,10.4,57.2,10.3,56.7,10.3z" }),
react.createElement("path", { fill:"#1FBAD6", d: "M63.2,16V5l2-0.1v10.8c0,0.3,0.1,0.5,0.2,0.6c0.1,0.1,0.3,0.2,0.6,0.2c0.3,0,0.6,0,0.9-0.1V18 c-0.4,0.1-1,0.2-1.6,0.2c-0.8,0-1.3-0.2-1.7-0.5S63.2,16.8,63.2,16z" }),
react.createElement("path", { fill:"#1FBAD6", d: "M68.2,13.3c0-1.5,0.4-2.7,1.1-3.5c0.7-0.8,1.8-1.2,3.1-1.2c1.3,0,2.2,0.4,2.8,1.1c0.6,0.7,0.9,1.8,0.9,3.3 c0,0.4,0,0.8,0,1.1h-5.8c0,1.6,0.8,2.4,2.4,2.4c1,0,2-0.2,2.9-0.6l0.2,1.7c-0.4,0.2-0.9,0.4-1.4,0.5s-1.1,0.2-1.7,0.2 c-1.5,0-2.6-0.4-3.3-1.2C68.6,16.1,68.2,14.9,68.2,13.3z M72.4,10.1c-0.7,0-1.2,0.2-1.5,0.5c-0.4,0.4-0.6,0.9-0.6,1.7h4 c0-0.8-0.2-1.4-0.5-1.7S73,10.1,72.4,10.1z" }),
react.createElement("path", { fill:"#1FBAD6", d: "M80.2,8.7l0.1,1.7h0c0.3-0.6,0.7-1.1,1.1-1.4c0.4-0.3,1-0.5,1.6-0.5c0.4,0,0.7,0,1,0.1l-0.1,2 c-0.3-0.1-0.7-0.2-1-0.2c-0.7,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,0-1.1,0.1-1.4,0.3c-0.3,0.2-0.4,0.6-0.4,1.2s0.1,1,0.4,1.2c0.3,0.2,0.7,0.3,1.4,0.3 c0.6,0,1.1-0.1,1.3-0.4S94.3,12,94.3,11.5z" }),
react.createElement("path", { fill:"#1FBAD6", d: "M99.4,16V5l2-0.1v10.8c0,0.3,0.1,0.5,0.2,0.6c0.1,0.1,0.3,0.2,0.6,0.2c0.3,0,0.6,0,0.9-0.1V18 c-0.4,0.1-1,0.2-1.6,0.2c-0.8,0-1.3-0.2-1.7-0.5S99.4,16.8,99.4,16z" })
)
)
);
};
return function App() {
var rootElm = react.useRef(null);
var _useState = react.useState({
width: window.innerWidth,
height: window.innerHeight
});
var windowDimension = _useState[0];
var setDimension = _useState[1];
react.useEffect(function sideEffect(){
function handleResize() {
setDimension({width: window.innerWidth, height: window.innerHeight});
};
window.addEventListener('resize', handleResize);
return function() {window.removeEventListener('resize', handleResize);};
}, []);
return react.createElement(
'div',
{style: {position: 'absolute', left: 0, width: '100vw', height: '100vh'}},
react.createElement(keplerGl.KeplerGl, {
mapboxApiAccessToken: mapboxToken,
id: "map",
width: windowDimension.width,
height: windowDimension.height
})
)
}
}(React, KeplerGl, MAPBOX_TOKEN));
const app = (function createReactReduxProvider(react, reactRedux, KeplerElement) {
return react.createElement(
reactRedux.Provider,
{store},
react.createElement(KeplerElement, null)
)
}(React, ReactRedux, KeplerElement));
/** END COMPONENTS **/
/** Render **/
(function render(react, reactDOM, app) {
reactDOM.render(app, document.getElementById('app'));
}(React, ReactDOM, app));
</script>
<!-- The next script will show how to interact directly with Kepler map store -->
<script>
/**
* Customize map.
* In the following section you can use the store object to dispatch Kepler.gl actions
* to add new data and customize behavior
*/
(function customize(keplerGl, store) {
const datasets = [{"version":"v1","data":{"id":"kg5fid42","label":"confirmed.json","color":[0,92,255],"allData": mapData,"fields":[{"name":"province","type":"string","format":"","analyzerType":"STRING"},{"name":"region","type":"string","format":"","analyzerType":"STRING"},{"name":"lat","type":"real","format":"","analyzerType":"FLOAT"},{"name":"lon","type":"real","format":"","analyzerType":"FLOAT"},{"name":"date","type":"timestamp","format":"YYYY-M-DTHH:mm:ss.SSSS","analyzerType":"DATETIME"},{"name":"value","type":"integer","format":"","analyzerType":"INT"}]}}];
const config = {"version":"v1","config":{"visState":{"filters":[{"dataId":["kg5fid42"],"id":"89ha2wex9","name":["date"],"type":"timeRange","value":[1579640400000,1579757834000],"enlarged":true,"plotType":"histogram","yAxis":null}],"layers":[{"id":"9h1tna","type":"point","config":{"dataId":"kg5fid42","label":"Confirmed","color":[77,193,156],"columns":{"lat":"lat","lng":"lon","altitude":null},"isVisible":true,"visConfig":{"radius":10,"fixedRadius":false,"opacity":0.8,"outline":false,"thickness":2,"strokeColor":null,"colorRange":{"name":"ColorBrewer OrRd-6","type":"sequential","category":"ColorBrewer","colors":["#fef0d9","#fdd49e","#fdbb84","#fc8d59","#e34a33","#b30000"]},"strokeColorRange":{"name":"Global Warming","type":"sequential","category":"Uber","colors":["#5A1846","#900C3F","#C70039","#E3611C","#F1920E","#FFC300"]},"radiusRange":[0,18.75],"filled":true},"textLabel":[{"field":null,"color":[255,255,255],"size":18,"offset":[0,0],"anchor":"start","alignment":"center"}]},"visualChannels":{"colorField":{"name":"value","type":"integer"},"colorScale":"quantize","strokeColorField":null,"strokeColorScale":"quantile","sizeField":{"name":"value","type":"integer"},"sizeScale":"sqrt"}}],"interactionConfig":{"tooltip":{"fieldsToShow":{"kg5fid42":["province","region","date","value"]},"enabled":true},"brush":{"size":0.5,"enabled":false},"coordinate":{"enabled":false}},"layerBlending":"normal","splitMaps":[],"animationConfig":{"currentTime":null,"speed":1}},"mapState":{"bearing":0,"dragRotate":false,"latitude":3.562221243239139e-13,"longitude":-29.800070659329165,"pitch":0,"zoom":0.9307372241957015,"isSplit":false},"mapStyle":{"styleType":"dark","topLayerGroups":{},"visibleLayerGroups":{"label":true,"road":true,"border":false,"building":true,"water":true,"land":true,"3d building":false},"threeDBuildingColor":[9.665468314072013,17.18305478057247,31.1442867897876],"mapStyles":{}}}};
const loadedData = keplerGl.KeplerGlSchema.load(
datasets,
config
);
store.dispatch(keplerGl.addDataToMap({
datasets: loadedData.datasets,
config: loadedData.config,
options: {
centerMap: false
}
}));
}(KeplerGl, store))
</script>
</body>
</html>