comparison js/datasourceLoader.js @ 0:b57c7821382f

initial
author Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
date Thu, 28 May 2015 10:28:12 +0200
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:b57c7821382f
1 var DataSourceLoader = function(type, source, description) {
2 this.Type = type;
3 this.Source = source;
4 this.Description = description;
5
6 this.loadDataset = function() {
7 if (this.Type == "kml") {
8 var mpiwg_geobrowser_kmlFile = GeoTemConfig.getKml(this.Source);
9 var dataSet = new Dataset(GeoTemConfig.loadKml(mpiwg_geobrowser_kmlFile), this.Description);
10 GeoTemConfig.addDataset(dataSet);
11 }
12 else if (this.Type == "mysql") {
13 function stringToXML(text){
14 if (window.ActiveXObject){
15 var doc = new ActiveXObject("Microsoft.XMLDOM");
16 doc.async = "false";
17 doc.loadXML(text);
18 } else {
19 var parser = new DOMParser();
20 var doc = parser.parseFromString(text, "text/xml");
21 }
22 return doc;
23 }
24 var mpiwg_geobrowser_kmlFile = stringToXML(this.Source);
25 var dataSet = new Dataset(GeoTemConfig.loadKml(mpiwg_geobrowser_kmlFile), this.Description);
26 GeoTemConfig.addDataset(dataSet);
27 }
28 else if (this.Type == "json") {
29 var dataSet = new Dataset(GeoTemConfig.loadJson(this.Source), this.Description);
30 GeoTemConfig.addDataset(dataSet);
31 }
32 }
33 }