update other libs

This commit is contained in:
Norbert Renner 2014-05-14 16:01:20 +02:00
parent e4ae9b5533
commit aa1e051cfd
31 changed files with 679 additions and 719 deletions

View file

@ -1,11 +1,11 @@
{
"name": "leaflet-gpx",
"homepage": "https://github.com/mpetazzoni/leaflet-gpx",
"_release": "f0622fa76e",
"_release": "ad9d5adf0a",
"_resolution": {
"type": "branch",
"branch": "master",
"commit": "f0622fa76ec80639b530a2348a7b291ed05a4418"
"commit": "ad9d5adf0ae5450bc5bc60e1e86307beb7667772"
},
"_source": "git://github.com/mpetazzoni/leaflet-gpx.git",
"_target": "*",

View file

@ -60,6 +60,7 @@ so in the 'loaded' event handler, calling one of the following methods on the
* `get_moving_time()`: returns the moving time, in milliseconds
* `get_total_time()`: returns the total track time, in milliseconds
* `get_moving_pace()`: returns the average moving pace in milliseconds per km
* `get_moving_speed()`: returns the average moving speed in km per hour
* `get_elevation_gain()`: returns the cumulative elevation gain, in meters
* `get_elevation_loss()`: returns the cumulative elevation loss, in meters
* `get_average_hr()`: returns the average heart rate (if available)
@ -68,8 +69,10 @@ If you're not a fan of the metric system, you also have the following methods
at your disposal:
* `get_distance_imp()`: returns the total track distance in miles
* `get_moving_pace_imp()`: returns the average moving pace in milliseconds per
mile
* `get_moving_pace_imp()`: returns the average moving pace in milliseconds per
hour
* `get_moving_speed()`: returns the average moving pace in miles per
hour
The reason why these methods return milliseconds is that you have at your
disposal a nice helper method to format a duration in milliseconds into a cool
@ -89,6 +92,15 @@ the distance is either in kilometers or in miles and the elevation in meters of
feet, depending on whether you use the `_imp` variant or not. Heart rate,
obviously, doesn't change.
You can reload remote gpx file every 5 seconds with:
```javascript
var gpxLayer = new L.GPX(gpxFile);
setInterval(function() {
gpxLayer.reload();
},5000);
```
About marker icons
------------------
@ -124,3 +136,12 @@ new L.GPX(url, {
map.fitBounds(e.target.getBounds());
}).addTo(map);
```
Caveats
-------
* Distance calculation is relatively accurate, but elevation change
calculation is not topographically adjusted, so the total elevation
gain/loss/change might appear inaccurate in some situations.
* Currently doesn't seem to work in IE8/9. See #9 and #11 for
discussion.

View file

@ -107,12 +107,17 @@ L.GPX = L.FeatureGroup.extend({
return s;
},
// Public methods
to_miles: function(v) { return v / 1.60934; },
to_ft: function(v) { return v * 3.28084; },
m_to_km: function(v) { return v / 1000; },
m_to_mi: function(v) { return v / 1609.34; },
get_name: function() { return this._info.name; },
get_desc: function() { return this._info.desc; },
get_author: function() { return this._info.author; },
get_copyright: function() { return this._info.copyright; },
get_desc: function() { return this._info.desc; },
get_distance: function() { return this._info.length; },
get_distance_imp: function() { return this.to_miles(this.m_to_km(this.get_distance())); },
@ -123,6 +128,9 @@ L.GPX = L.FeatureGroup.extend({
get_moving_pace: function() { return this.get_moving_time() / this.m_to_km(this.get_distance()); },
get_moving_pace_imp: function() { return this.get_moving_time() / this.get_distance_imp(); },
get_moving_speed: function() { return this.m_to_km(this.get_distance()) / (this.get_moving_time() / (3600 * 1000)) ; },
get_moving_speed_imp:function() { return this.to_miles(this.m_to_km(this.get_distance())) / (this.get_moving_time() / (3600 * 1000)) ; },
get_elevation_gain: function() { return this._info.elevation.gain; },
get_elevation_loss: function() { return this._info.elevation.loss; },
@ -157,8 +165,12 @@ L.GPX = L.FeatureGroup.extend({
});
},
// Private methods
reload: function() {
this.clearLayers();
this._parse(this._gpx, this.options, this.options.async);
},
// Private methods
_merge_objs: function(a, b) {
var _ = {};
for (var attr in a) { _[attr] = a[attr]; }
@ -214,6 +226,18 @@ L.GPX = L.FeatureGroup.extend({
if (name.length > 0) {
this._info.name = name[0].textContent;
}
var desc = xml.getElementsByTagName('desc');
if (desc.length > 0) {
this._info.desc = desc[0].textContent;
}
var author = xml.getElementsByTagName('author');
if (author.length > 0) {
this._info.author = author[0].textContent;
}
var copyright = xml.getElementsByTagName('copyright');
if (copyright.length > 0) {
this._info.copyright = copyright[0].textContent;
}
for (j = 0; j < tags.length; j++) {
el = xml.getElementsByTagName(tags[j][0]);
@ -333,5 +357,5 @@ L.GPX = L.FeatureGroup.extend({
_deg2rad: function(deg) {
return deg * Math.PI / 180;
},
}
});