25,7 → 25,17 |
* |
*/ |
|
// Adaptation Alexandre GALIBERT : |
// - Define fill opacity for polygons at 0 for transparent rendering |
// - Disable creation of icons for KML elements |
// - Specific beahaviour to add an array of files by their urls. A variable will define |
// the status of the processing (BUSY or READY) and managed with a counter for the number |
// of files remaining to parse. Once all files parsed, the map zooms on KML spatial elements |
|
const KML_READY = 0; |
const KML_BUSY = 1; |
|
|
L.KML = L.FeatureGroup.extend({ |
options: { |
async: true |
34,6 → 44,8 |
initialize: function(kml, options) { |
L.Util.setOptions(this, options); |
this._kml = kml; |
this._status = KML_READY; |
this._onWaiting = 0; |
this._layers = {}; |
|
if (kml) { |
57,6 → 69,14 |
req.send(null); |
}, |
|
addKMLFiles: function(urlList, options, async) { |
this._status = KML_BUSY; |
this._onWaiting = urlList.length; |
for (var index = 0; index < urlList.length; index ++) { |
this.addKML(urlList[index], options, async); |
} |
}, |
|
addKML: function(url, options, async) { |
var _this = this; |
var cb = function(gpx, options) { _this._addKML(gpx, options) }; |
75,8 → 95,17 |
} |
this.latLngs = L.KML.getLatLngs(xml); |
this.fire("loaded"); |
this._onWaiting --; |
if (this._onWaiting == 0) { |
this._status = KML_READY; |
this._map.fitBounds(this.getBounds()); |
} |
}, |
|
getStatus: function() { |
return this._status; |
}, |
|
latLngs: [] |
}); |
|
137,14 → 166,15 |
options.color = "#" + value.substring(2, 8); |
} else if (key === 'width') { |
options.weight = value; |
} else if (key === 'Icon') { |
} /*else if (key === 'Icon') { |
ioptions = _parse(e); |
if (ioptions.href) { options.href = ioptions.href; } |
} else if (key === 'href') { |
}*/ else if (key === 'href') { |
options.href = value; |
} |
} |
} |
options.fillOpacity = 0; |
return options; |
} |
|