-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrackViewOl.js
52 lines (42 loc) · 1.85 KB
/
trackViewOl.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
// style the vectorlayer
var styleMap = new OpenLayers.StyleMap({
'default': new OpenLayers.Style({
strokeColor: "yellow",
strokeWidth: 1.2,
strokeOpacity: 1
})
});
var track = new OpenLayers.Layer.Vector("Tracks", {styleMap: styleMap});
var trackPoints = new OpenLayers.Layer.Vector("Track points");
var wayPoints = new OpenLayers.Layer.Vector("Way points");
var routePoints = new OpenLayers.Layer.Vector("Route points");
function trackViewInit() {
map.addLayers([track, trackPoints, wayPoints, routePoints]);
}
function trackView() {
track.removeAllFeatures();
trackPoints.removeAllFeatures();
wayPoints.removeAllFeatures();
routePoints.removeAllFeatures();
var nodes = [];
for (i=0; i<api.getTrackSize(); i++) {
var loc = api.getTrackPoint(i).split(':',4);
var l = new OpenLayers.LonLat(loc[1], loc[0]).transform(defPro, map.getProjectionObject());
if (loc[2] == "0") { // track
nodes.push(new OpenLayers.Geometry.Point(l.lon, l.lat));
// trackPoints.addFeatures([new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(l.lon, l.lat), null, style_red)]);
// debug("track point " + loc);
}
if (loc[2] == "1") { // way
// wayPoints.addFeatures([new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(l.lon, l.lat), null, style_red)]);
// debug("way point " + loc);
}
if (loc[2] == "2") { // route
// routePoints.addFeatures([new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(l.lon, l.lat), null, style_red)]);
// debug("route point " + loc);
}
};
track.addFeatures([new OpenLayers.Feature.Vector(new OpenLayers.Geometry.LineString(nodes).simplify(2))]);
debug("Extent: " + track.getDataExtent());
map.zoomToExtent(track.getDataExtent());
}