Subversion Repositories eFlore/Applications.moissonnage

Rev

Rev 28 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 28 Rev 31
Line 23... Line 23...
23
 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
23
 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
24
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
 * 
25
 * 
26
 */
26
 */
Line -... Line 27...
-
 
27
 
-
 
28
// Adaptation Alexandre GALIBERT :
-
 
29
//   - Define fill opacity for polygons at 0 for transparent rendering
-
 
30
//   - Disable creation of icons for KML elements
-
 
31
//   - Specific beahaviour to add an array of files by their urls. A variable will define
-
 
32
//     the status of the processing (BUSY or READY) and managed with a counter for the number
-
 
33
//     of files remaining to parse. Once all files parsed, the map zooms on KML spatial elements
-
 
34
 
-
 
35
const KML_READY = 0;
-
 
36
const KML_BUSY = 1;
Line 27... Line 37...
27
 
37
 
28
 
38
 
29
L.KML = L.FeatureGroup.extend({
39
L.KML = L.FeatureGroup.extend({
30
	options: {
40
	options: {
Line 31... Line 41...
31
		async: true
41
		async: true
32
	},
42
	},
33
 
43
 
-
 
44
	initialize: function(kml, options) {
-
 
45
		L.Util.setOptions(this, options);
34
	initialize: function(kml, options) {
46
		this._kml = kml;
Line 35... Line 47...
35
		L.Util.setOptions(this, options);
47
		this._status = KML_READY;
36
		this._kml = kml;
48
		this._onWaiting = 0;
37
		this._layers = {};
49
		this._layers = {};
Line 55... Line 67...
55
			if(req.status == 200) cb(req.responseXML, options);
67
			if(req.status == 200) cb(req.responseXML, options);
56
		};
68
		};
57
		req.send(null);
69
		req.send(null);
58
	},
70
	},
Line -... Line 71...
-
 
71
 
-
 
72
	addKMLFiles: function(urlList, options, async) {
-
 
73
		this._status = KML_BUSY;
-
 
74
		this._onWaiting = urlList.length;
-
 
75
		for (var index = 0; index < urlList.length; index ++) {
-
 
76
			this.addKML(urlList[index], options, async);
-
 
77
		}
-
 
78
	},
59
 
79
	
60
	addKML: function(url, options, async) {
80
	addKML: function(url, options, async) {
61
		var _this = this;
81
		var _this = this;
62
		var cb = function(gpx, options) { _this._addKML(gpx, options) };
82
		var cb = function(gpx, options) { _this._addKML(gpx, options) };
63
		this.loadXML(url, cb, options, async);
83
		this.loadXML(url, cb, options, async);
Line 73... Line 93...
73
			});
93
			});
74
			this.addLayer(layers[i]);
94
			this.addLayer(layers[i]);
75
		}
95
		}
76
		this.latLngs = L.KML.getLatLngs(xml);
96
		this.latLngs = L.KML.getLatLngs(xml);
77
		this.fire("loaded");
97
		this.fire("loaded");
-
 
98
		this._onWaiting --;
-
 
99
		if (this._onWaiting == 0) {
-
 
100
			this._status = KML_READY;
-
 
101
			this._map.fitBounds(this.getBounds());
-
 
102
		}
-
 
103
	},
-
 
104
	
-
 
105
	getStatus: function() {
-
 
106
		return this._status;
78
	},
107
	},
Line 79... Line 108...
79
 
108
 
80
	latLngs: []
109
	latLngs: []
Line 135... Line 164...
135
					if (key === 'color') {
164
					if (key === 'color') {
136
						options.opacity = parseInt(value.substring(0, 2), 16) / 255.0;
165
						options.opacity = parseInt(value.substring(0, 2), 16) / 255.0;
137
						options.color = "#" + value.substring(2, 8);
166
						options.color = "#" + value.substring(2, 8);
138
					} else if (key === 'width') {
167
					} else if (key === 'width') {
139
						options.weight = value;
168
						options.weight = value;
140
					} else if (key === 'Icon') {
169
					} /*else if (key === 'Icon') {
141
						ioptions = _parse(e);
170
						ioptions = _parse(e);
142
						if (ioptions.href) { options.href = ioptions.href; }
171
						if (ioptions.href) { options.href = ioptions.href; }
143
					} else if (key === 'href') {
172
					}*/ else if (key === 'href') {
144
						options.href = value;
173
						options.href = value;
145
					}
174
					}
146
				}
175
				}
147
			}
176
			}
-
 
177
			options.fillOpacity = 0;
148
			return options;
178
			return options;
149
		}
179
		}
Line 150... Line 180...
150
 
180
 
151
		for (var i = 0; i < sl.length; i++) {
181
		for (var i = 0; i < sl.length; i++) {