HOWTO.md 13.2 KB
Newer Older
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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
HOWTO 

Utiliser ce projet pour faire une carte interactive avec OpenLayers et des graphiques interactifs avec d3.js et nvd3 comme composants de REACT


- [1. Installation](#1-installation)
  - [1.1. Dezipper](#11-dezipper)
  - [1.2. WITH NPM](#12-with-npm)
    - [1.2.1. Installer node et npm](#121-installer-node-et-npm)
    - [1.2.2. Installer les dépendances pour la compilation](#122-installer-les-dépendances-pour-la-compilation)
      - [1.2.2.1. ndv3 et d3](#1221-ndv3-et-d3)
    - [1.2.3. Builder](#123-builder)
    - [1.2.4. Tester en local](#124-tester-en-local)
- [2. Debug](#2-debug)
  - [2.1. OL](#21-ol)
    - [2.1.1. ne pas monter deux fois la carte](#211-ne-pas-monter-deux-fois-la-carte)
    - [Flux4 à tester aussi](#flux4-à-tester-aussi)
- [3. Ressources Web](#3-ressources-web)
  - [3.1. Pour webpack et la config du build](#31-pour-webpack-et-la-config-du-build)
  - [3.2. UI](#32-ui)
  - [3.3. Javascript](#33-javascript)
  - [3.4. REACT](#34-react)
  - [3.5. REACT Avec D3.js](#35-react-avec-d3js)
  - [3.6. Pour OpenLayers](#36-pour-openlayers)
  - [3.7. Bootstrap](#37-bootstrap)
  - [3.8. Opensource ou free software (logiciel libre)](#38-opensource-ou-free-software-logiciel-libre)
  - [3.9. Suite](#39-suite)

# 1. Installation


## 1.1. Dezipper 

dézipper le fichier layer_v2

lancer CMD dans Windows et se placer dans le répertoire dézippé : 
`cd C:\yourpath\...\layer_v2`

## 1.2. WITH NPM

### 1.2.1. Installer node et npm

`node -v`

v12.14.1

`npm -v`

6.13.4

Mettre à jour npm : 
`npm install -g npm`


### 1.2.2. Installer les dépendances pour la compilation

Elles sont données dans le fichier package.json
```js
 "dependencies": {
    "colormap": "^2.3.1",
    "copy-webpack-plugin": "^5.1.1",
    "css-loader": "^3.4.2",
    "html-webpack-plugin": "^4.0.1",
    "ol": "^6.2.1",
    "ol-ext": "^3.1.11",
    "ol-hashed": "^2.0.0",
    "ol-layerswitcher": "^3.5.0",
    "style-loader": "^1.1.3",
    "webpack": "^4.42.1",
    "webpack-dev-server": "^3.10.3"
  },
  "devDependencies": {
    "parcel-bundler": "^1.12.4",
    "webpack-cli": "^3.3.11"
  }
```

Donc il faut les installer une par une :

`npm install ol`

`npm install --save-dev parcel-bundler`

`npm install webpack`
etc.

npm install react-proxy-loader --save-dev


`npm install react-scripts`

```
npm install react-scripts
npm install --save i18next
npm install --save react-i18next 
npm install react-i18next@legacy i18next --save
npm install react react-dom

npm install d3v3 

```

#### 1.2.2.1. ndv3 et d3 
Ne pas faire `npm install d3v4`

NVD3 is recommended to go with d3.js version 3.5.3 and later, but NOT d3 4.x yet. f(layerswitcher et barchart)
- https://www.npmjs.com/package/nvd3
- https://github.com/novus/nvd3/issues/1582
npm load d3 before nvd3

npm uninstall webpack-dev-server
npm uninstall webpack-cli
npm uninstall d3v4

/*"webpack-dev-server": "^3.10.3"*/
/*"webpack-cli": "^3.3.11"*/

npm install d3v4@3.4.4
"d3v4": "^3.4.4",
No matching version found for d3v4@^3.4.4.


npm list
```
npm ERR! peer dep missing: hammerjs@^2.0.0, required by @progress/kendo-react-charts@3.13.0
npm ERR! peer dep missing: popper.js@^1.16.0, required by bootstrap@4.4.1
npm ERR! peer dep missing: typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta, required by tsutils@3.17.1
npm ERR! peer dep missing: typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta, required by tsutils@3.17.1
```


### 1.2.3. Builder

Grâce à **webpack.config.js**,  le build prépare un fichier **layerswitcher.bundle.js** qui sera le point d'entrée de l'application et contiendra aussi les fichiers de styles ol.css importés via la page **layerswitcher.js**.

```js
//entête de layerswitcher.js
import css from './layerswitcher.css';
import './ol-layerswitcher.css';
import 'ol/ol.css';
```

Il copie aussi les fichiers de données dans data, et indique que la page HTML sera layerswitcher.html

```js
//dans webpack.config.js
new HtmlPlugin({
      title:'Alphaportic - openlayers part',
      filename:'layerswitcher.html',
      template: 'src/layerswitcher.html'
    })
```
La commande à lancer : 
`npm run build`

```sh
Hash: 81312c6954da91df64cc
Version: webpack 4.42.1
Time: 4666ms
Built at: 2020-03-24 17:31:31
                      Asset      Size  Chunks                          Chunk Names
            data/ports.json   514 KiB          [emitted]        [big]
      data/portsref.geojson   642 KiB          [emitted]        [big]
    layerswitcher.bundle.js   328 KiB       0  [emitted]        [big]  main
layerswitcher.bundle.js.map  1.84 MiB       0  [emitted] [dev]         main
         layerswitcher.html  1.12 KiB          [emitted]
Entrypoint main [big] = layerswitcher.bundle.js layerswitcher.bundle.js.map
[35] ./src/layerswitcher.css 569 bytes {0} [built]
[36] ./node_modules/css-loader/dist/cjs.js!./src/layerswitcher.css 1.55 KiB {0} [built]
[37] ./src/ol-layerswitcher.css 572 bytes {0} [built]
[38] ./node_modules/css-loader/dist/cjs.js!./src/ol-layerswitcher.css 4.45 KiB {0} [built]
[42] ./src/layerswitcher.js + 177 modules 1.23 MiB {0} [built]
     | ./src/layerswitcher.js 18.7 KiB [built]
     |     + 177 hidden modules
    + 150 hidden modules
```



### 1.2.4. Tester en local

`npm start`

http://localhost:3000/layerswitcher.html

# 2. Debug 

## 2.1. OL

src\Components\OL\layerswitcher.js

### 2.1.1. ne pas monter deux fois la carte
l 281 src\Components\OL\layerswitcher.js
      Dans readAndStoreDataPerPort()
        //that.componentDidMount();
        

### Flux4 à tester aussi
l 510
    var flux4 = this.props.t("menu.flux4"); //All

l 705
```js
      if (flow.localeCompare(flux0) === 0 | flow.localeCompare(flux4) === 0 ){
          portstyle = new Style({
            image: new Circle({
              radius: getSize(feature),
              fill: new Fill({ color: symbolfillcolor }),
              stroke: new Stroke({ color: "#000000" }),
            }),
            geometry: function (feature) {
              return feature.getGeometry();
            },
          });
```

Il manquait un port par défaut dans le niveau store : 
l15  src\store\reducer.js
```js
    idport: MAP.DEFAULT_PORT, //identifiant du port analysé
```

---

# 3. Ressources Web


## 3.1. Pour webpack et la config du build
- https://webpack.js.org/concepts/configuration#using-other-configuration-languages 
- https://webpack.js.org/concepts/configuration/#simple-configuration

package.json : 
- https://flaviocopes.com/package-json/

Node
- https://60devs.com/npm-install-specific-version.html
- https://www.sitepoint.com/beginners-guide-node-package-manager/
- 

## 3.2. UI
- http://glossaire.infowebmaster.fr/breadcrumb/
- https://goodui.org/ 

**Material-ui**
- https://medium.com/creative-tims-blog/12-absolute-principles-of-material-design-2ce7cc98d615
- https://github.com/mui-org/material-ui

**Envato design**
- https://tutsplus.com/?utm_source=forums&utm_medium=promos&utm_campaign=tuts_forums-headernav_our_products&utm_content=headernav&_ga=2.230974495.100481333.1585482204-507835756.1585482204
- https://webdesign.tutsplus.com/categories/ui-design?_ga=2.189228075.100481333.1585482204-507835756.1585482204
- https://webdesign.tutsplus.com/
  

## 3.3. Javascript
- https://code.jquery.com/
- https://getbootstrap.com/docs/4.1/layout/grid/
- http://www.webweaver.nu/html-tips/favicon.shtml

- http://bl.ocks.org/mbostock/9535021
- https://bl.ocks.org/iamkevinv/0a24e9126cd2fa6b283c6f2d774b69a2

- https://putaindecode.io/fr/articles/js/es2015/const-let-var/


**Autocompletion**
- https://openclassrooms.com/fr/courses/510018-decouvrez-la-puissance-de-jquery-ui/510016-lautocompletion

**Free photos stock**
- https://stocksnap.io/

**Colors**
- https://medium.com/creative-tims-blog/practical-color-generators-for-webmasters-a47248ffda9a
- http://paletton.com/#uid=1000u0kllllaFw0g0qFqFg0w0aF

favicon : 
- http://favicon.htmlkit.com/favicon/

**font**
```html
<div>Font made from <a href="http://www.onlinewebfonts.com">oNline Web Fonts</a>is licensed by CC BY 3.0</div>
```
- https://www.onlinewebfonts.com/download/1a045963159927274c92b0444fb83c17

**geojson**
- https://blog.mastermaps.com/2012/11/how-to-minify-geojson-files.html
- https://mapshaper.org/
- https://makina-corpus.com/blog/metier/2014/reduire-le-poids-dun-geojson
- https://blog.mastermaps.com/2012/11/how-to-minify-geojson-files.html

**CORS**
**https://stackoverflow.com/questions/43262121/trying-to-use-fetch-and-pass-in-mode-no-cors**

**JSON**
- https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Objets_globaux/JSON/stringify 
  

## 3.4. REACT

- https://fr.reactjs.org/docs/forwarding-refs.html
- https://towardsdatascience.com/passing-data-between-react-components-parent-children-siblings-a64f89e24ecf
- https://stackoverflow.com/questions/54314945/reactjs-how-to-use-ref-inside-map-function 

- **https://developer.okta.com/blog/2018/12/20/crud-app-with-python-flask-react**
- https://medium.com/code-divoire/cr%C3%A9ation-dune-application-web-avec-python-et-react-partie-1-backend-b5efb8a6a0c5
- 

## 3.5. REACT Avec D3.js

- https://medium.com/@Elijah_Meeks/interactive-applications-with-react-d3-f76f7b3ebc71
- https://www.freecodecamp.org/news/how-to-get-started-with-d3-and-react-c7da74a5bd9f/
- https://github.com/novus/nvd3/issues/1582#issuecomment-209690887
- https://codesandbox.io/s/3y4qyno486?file=/src/index.js:637-651 
- https://github.com/d3/d3/wiki#linear
- https://nvd3-community.github.io/nvd3/examples/documentation.html#multiBarChart 
- https://www.d3indepth.com/scales/ 
- https://www.npmjs.com/package/nvd3 
- https://github.com/NuCivic/react-nvd3 
- https://github.com/novus/nvd3/blob/master/examples/documentation.html

  
-  https://aspenmesh.io/using-d3-in-react-a-pattern-for-using-data-visualization-at-scale/
-  https://github.com/novus/nvd3/issues/1219
-  https://www.youtube.com/watch?v=5FEzELkLsYw 
-  https://medium.com/@PepsRyuu/why-i-no-longer-use-d3-js-b8288f306c9a 

## 3.6. Pour OpenLayers

- https://github.com/openlayers/workshop/releases
- https://openlayers.org/en/latest/doc/tutorials/bundle.html
- https://openlayers.org/workshop/fr/
- https://openlayers.org/workshop/en/deploying/
- https://openlayers.org/en/latest/apidoc/module-ol_layer_Layer-Layer.html#getZIndex
- https://openlayers.org/workshop/fr/vector/style-intro.html
- https://openlayers.org/en/latest/examples/vector-labels.html
- https://maputnik.github.io/editor/#6.96/46.111/-0.107
- https://openlayers.org/en/latest/examples/polygon-styles.html
- https://openlayers.org/en/latest/examples/icon.html
- https://openlayers.org/workshop/fr/basics/resources.html
- **https://openlayers.org/en/latest/apidoc/**

**LayerSwitcher** en particulier
- https://openlayers.org/3rd-party/
- https://openlayers.org/en/latest/apidoc/module-ol_layer_Layer-Layer.html#getZIndex
- http://dev.openlayers.org/docs/files/OpenLayers/Control/LayerSwitcher-js.html
- http://raw.githack.com/walkermatt/ol-layerswitcher/master/examples/select-groups.html
- https://openlayers.org/workshop/fr/controls/modify.html

- http://dev.openlayers.org/examples/click.html
- https://gis.stackexchange.com/questions/252946/what-are-the-possible-listeners-and-event-types-for-an-openlayers-map-ol-map
- https://gis.stackexchange.com/questions/346098/openlayers-6-1-1-add-layer-to-existing-layer-group-in-ol-layerswitcher
- https://openlayers.org/en/master/examples/custom-controls.html
- https://geoservices.ign.fr/documentation/exemples/ol-control-layerSwitcher.html
- **https://github.com/walkermatt/ol-layerswitcher**
- **http://raw.githack.com/walkermatt/ol-layerswitcher/master/examples/select-groups.js**


**OL avec react**
- https://github.com/allenhwkim/react-openlayers/issues/43
- https://dominoc925.blogspot.com/2019/10/simple-example-of-reactjs-and.html
- https://taylor.callsen.me/using-reactflux-with-openlayers-3-and-other-third-party-libraries/ 
- **https://stackoverflow.com/questions/52216011/cant-display-a-vertor-layer-using-openlayer-in-react**


- https://stackoverflow.com/questions/31758081/loading-json-data-from-local-file-into-react-js


## 3.7. Bootstrap

- https://startbootstrap.com/bootstrap-resources/
- https://www.tutorialrepublic.com/twitter-bootstrap-tutorial/ 
- https://medium.com/creative-tims-blog/working-on-the-best-bootstrap-resources-44791f0e18f8

Boostrap or Foundation ?
- https://blog.teamtreehouse.com/use-bootstrap-or-foundation

Bootstrap Bay
- https://bootstrapbay.com/?irgwc=1


- https://bootstrapbay.com/theme/datta-able-free-reactjs-admin-dashboard-template-BFD950F
- http://lite.codedthemes.com/datta-able/react/default/dashboard/default
- http://lite.codedthemes.com


- https://bootstrapbay.com/theme/adminkit-web-ui-kit-dashboard-template-B69F880
- https://demo.adminkit.io/tables-bootstrap.html


Creative Tim
- https://www.creative-tim.com/product/get-shit-done-kit
- https://www.creative-tim.com/templates/free


## 3.8. Opensource ou free software (logiciel libre)

- https://siecledigital.fr/2019/10/28/3-mythes-open-source/
- https://www.gnu.org/philosophy/open-source-misses-the-point.fr.html

- https://www.scamadviser.com/check-website/bootstrapbay.com
Sitejabber, Resellerrating and Trustpilot 


## 3.9. Suite

Laboratoire L3i, Université de La Rochelle, La Rochelle, France
https://github.com/LinkedPasts/linked-places