-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
65 lines (55 loc) · 1.35 KB
/
main.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
import './style.css';
import { Map, View } from 'ol';
import TileLayer from 'ol/layer/Tile';
import OSM from 'ol/source/OSM';
import LineString from 'ol/geom/LineString';
import VectorSource from 'ol/source/Vector';
import VectorLayer from 'ol/layer/Vector';
import Feature from 'ol/Feature';
import Style from 'ol/style/Style';
import Stroke from 'ol/style/Stroke';
import Fill from 'ol/style/Fill';
import CanvasLayer from './canvasLayer'
var layer = new VectorLayer({
source: new VectorSource(),
style: new Style({
stroke: new Stroke({
color: '#FFEB3B',
width: 2
}),
fill: new Fill({
color: '#7b7f838a'
})
})
})
var tile = new TileLayer({
source: new OSM(),
})
var map = new Map({
layers: [tile, layer
],
target: 'map',
view: new View({
projection: 'EPSG:4326',
center: [104, 30],
zoom: 1
})
});
var randomFeatures = [];
for (var i = 0; i < 100000; i++) {
var anchor = new Feature({
geometry: new LineString([[Math.random() * 180, Math.random() * 160 - 80], [Math.random() * 180, Math.random() * 160 - 80], [Math.random() * 180, Math.random() * 160 - 80]])
});
randomFeatures.push(anchor)
}
var lineStyle = new Style({
stroke: new Stroke({
color: [255, 0, 0, 0.5],
width: 0.1
}),
});
var cvLayer = new CanvasLayer({
map: map,
style: lineStyle
})
cvLayer.showData(randomFeatures)