-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
77 lines (65 loc) · 1.52 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
66
67
68
69
70
71
72
73
74
75
import 'ol/ol.css';
import {Tile as TileLayer, Vector as VectorLayer} from 'ol/layer.js';
import Feature from 'ol/Feature';
import Map from 'ol/Map';
import OSM from 'ol/source/OSM';
import VectorSource from 'ol/source/Vector';
import Point from 'ol/geom/Point';
import WKT from 'ol/format/WKT';
import View from 'ol/View';
import {Circle, Fill, Stroke, Style, Text} from 'ol/style';
import {fromLonLat, toLonLat} from 'ol/proj';
const base = new TileLayer({
type: 'base',
visible: true,
source: new OSM()
});
const format = new WKT();
const linestring = format.readFeature(gpsPath, {
dataProjection: 'EPSG:4326',
featureProjection: 'EPSG:3857',
});
const point = new Feature({
geometry: new Point(fromLonLat([lon, lat]))
});
const fill = new Fill({
color: 'rgba(255,51,51,0.2)'
});
const stroke = new Stroke({
color: 'rgba(255,51,51,0.7)',
width: 3
});
const styles = [
new Style({
image: new Circle({
fill: fill,
stroke: stroke,
radius: 15
}),
fill: fill,
stroke, stroke
}),
new Style({
image: new Circle({
fill: fill,
stroke: stroke,
radius: 15
}),
fill: fill,
stroke, stroke
})
];
const vector = new VectorLayer({
source: new VectorSource({
features: [linestring, point],
}),
style: styles
});
const map = new Map({
layers: [base, vector],
target: 'map',
view: new View({
center: fromLonLat([lon, lat]),
zoom: 16,
}),
});