forked from socib/Leaflet.TimeDimension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example9.js
81 lines (69 loc) · 2.07 KB
/
example9.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
76
77
78
79
80
81
var startDate = new Date();
startDate.setUTCHours(0, 0, 0, 0);
var map = L.map('map', {
zoom: 12,
fullscreenControl: true,
center: [39.3, 4]
});
// start of TimeDimension manual instantiation
var timeDimension = new L.TimeDimension({
period: "PT5M",
});
// helper to share the timeDimension object between all layers
map.timeDimension = timeDimension;
// otherwise you have to set the 'timeDimension' option on all layers.
var player = new L.TimeDimension.Player({
transitionTime: 100,
loop: false,
startOver:true
}, timeDimension);
var timeDimensionControlOptions = {
player: player,
timeDimension: timeDimension,
position: 'bottomleft',
autoPlay: true,
minSpeed: 1,
speedStep: 0.5,
maxSpeed: 15,
timeSliderDragUpdate: true
};
var timeDimensionControl = new L.Control.TimeDimension(timeDimensionControlOptions);
map.addControl(timeDimensionControl);
var icon = L.icon({
iconUrl: 'img/running.png',
iconSize: [22, 22],
iconAnchor: [5, 25]
});
var customLayer = L.geoJson(null, {
pointToLayer: function (feature, latLng) {
if (feature.properties.hasOwnProperty('last')) {
return new L.Marker(latLng, {
icon: icon
});
}
return L.circleMarker(latLng);
}
});
var gpxLayer = omnivore.gpx('data/running_mallorca.gpx', null, customLayer).on('ready', function() {
map.fitBounds(gpxLayer.getBounds(), {
paddingBottomRight: [40, 40]
});
});
var gpxTimeLayer = L.timeDimension.layer.geoJson(gpxLayer, {
updateTimeDimension: true,
addlastPoint: true,
waitForReady: true
});
var kmlLayer = omnivore.kml('data/easy_currents_track.kml');
var kmlTimeLayer = L.timeDimension.layer.geoJson(kmlLayer, {
updateTimeDimension: true,
addlastPoint: true,
waitForReady: true
});
var overlayMaps = {
"GPX Layer": gpxTimeLayer,
"KML Layer": kmlTimeLayer
};
var baseLayers = getCommonBaseLayers(map); // see baselayers.js
L.control.layers(baseLayers, overlayMaps).addTo(map);
gpxTimeLayer.addTo(map);