update other libs
This commit is contained in:
parent
e4ae9b5533
commit
aa1e051cfd
31 changed files with 679 additions and 719 deletions
|
|
@ -1,5 +1,3 @@
|
|||
/*global L: true */
|
||||
|
||||
L.GPX = L.FeatureGroup.extend({
|
||||
initialize: function(gpx, options) {
|
||||
L.Util.setOptions(this, options);
|
||||
|
|
@ -12,8 +10,8 @@ L.GPX = L.FeatureGroup.extend({
|
|||
},
|
||||
|
||||
loadXML: function(url, cb, options, async) {
|
||||
if (async == undefined) async = this.options.async;
|
||||
if (options == undefined) options = this.options;
|
||||
if (async === undefined) async = this.options.async;
|
||||
if (options === undefined) options = this.options;
|
||||
|
||||
var req = new window.XMLHttpRequest();
|
||||
req.open('GET', url, async);
|
||||
|
|
@ -21,17 +19,17 @@ L.GPX = L.FeatureGroup.extend({
|
|||
req.overrideMimeType('text/xml'); // unsupported by IE
|
||||
} catch(e) {}
|
||||
req.onreadystatechange = function() {
|
||||
if (req.readyState != 4) return;
|
||||
if(req.status == 200) cb(req.responseXML, options);
|
||||
if (req.readyState !== 4) return;
|
||||
if(req.status === 200) cb(req.responseXML, options);
|
||||
};
|
||||
req.send(null);
|
||||
},
|
||||
|
||||
_humanLen: function(l) {
|
||||
if (l < 2000)
|
||||
return l.toFixed(0) + " m";
|
||||
return l.toFixed(0) + ' m';
|
||||
else
|
||||
return (l/1000).toFixed(1) + " km";
|
||||
return (l/1000).toFixed(1) + ' km';
|
||||
},
|
||||
|
||||
_polylineLen: function(line)//line is a L.Polyline()
|
||||
|
|
@ -49,7 +47,7 @@ L.GPX = L.FeatureGroup.extend({
|
|||
|
||||
addGPX: function(url, options, async) {
|
||||
var _this = this;
|
||||
var cb = function(gpx, options) { _this._addGPX(gpx, options) };
|
||||
var cb = function(gpx, options) { _this._addGPX(gpx, options); };
|
||||
this.loadXML(url, cb, options, async);
|
||||
},
|
||||
|
||||
|
|
@ -57,7 +55,7 @@ L.GPX = L.FeatureGroup.extend({
|
|||
var layers = this.parseGPX(gpx, options);
|
||||
if (!layers) return;
|
||||
this.addLayer(layers);
|
||||
this.fire("loaded");
|
||||
this.fire('loaded');
|
||||
},
|
||||
|
||||
parseGPX: function(xml, options) {
|
||||
|
|
@ -76,12 +74,12 @@ L.GPX = L.FeatureGroup.extend({
|
|||
}
|
||||
|
||||
el = xml.getElementsByTagName('wpt');
|
||||
if (options.display_wpt != false) {
|
||||
if (options.display_wpt !== false) {
|
||||
for (i = 0; i < el.length; i++) {
|
||||
var l = this.parse_wpt(el[i], xml, options);
|
||||
if (!l) continue;
|
||||
if (this.parse_name(el[i], l)) named = true;
|
||||
layers.push(l);
|
||||
var marker = this.parse_wpt(el[i], xml, options);
|
||||
if (!marker) continue;
|
||||
if (this.parse_name(el[i], marker)) named = true;
|
||||
layers.push(marker);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -94,7 +92,7 @@ L.GPX = L.FeatureGroup.extend({
|
|||
},
|
||||
|
||||
parse_name: function(xml, layer) {
|
||||
var i, el, txt="", name, descr="", len=0;
|
||||
var i, el, txt='', name, descr='', len=0;
|
||||
el = xml.getElementsByTagName('name');
|
||||
if (el.length)
|
||||
name = el[0].childNodes[0].nodeValue;
|
||||
|
|
@ -107,8 +105,8 @@ L.GPX = L.FeatureGroup.extend({
|
|||
if(layer instanceof L.Path)
|
||||
len = this._polylineLen(layer);
|
||||
|
||||
if (name) txt += "<h2>" + name + "</h2>" + descr;
|
||||
if (len) txt += "<p>" + this._humanLen(len) + "</p>";
|
||||
if (name) txt += '<h2>' + name + '</h2>' + descr;
|
||||
if (len) txt += '<p>' + this._humanLen(len) + '</p>';
|
||||
|
||||
if (layer && layer._popup === undefined) layer.bindPopup(txt);
|
||||
return txt;
|
||||
|
|
@ -130,7 +128,7 @@ L.GPX = L.FeatureGroup.extend({
|
|||
coords.push(ll);
|
||||
}
|
||||
var l = [new L.Polyline(coords, options)];
|
||||
this.fire('addline', {line:l})
|
||||
this.fire('addline', {line:l});
|
||||
return l;
|
||||
},
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue