Commit 0f7c7050a0545b58c3a8f2a71e52024a9347d9aa

Authored by Andrea Petta
1 parent 15167bf3

plugin update

datalets/leafletjs-geojson-datalet/leafletjs-geojson-datalet.html
@@ -64,7 +64,7 @@ Example: @@ -64,7 +64,7 @@ Example:
64 64
65 <script> 65 <script>
66 66
67 - var leafletjsBehavior = { 67 + var leafletjsgeojsonBehavior = {
68 68
69 /** 69 /**
70 * Read markers coordinates from the data object and add the marker to the map. 70 * Read markers coordinates from the data object and add the marker to the map.
@@ -88,52 +88,11 @@ Example: @@ -88,52 +88,11 @@ Example:
88 88
89 L.Icon.Default.imagePath = 'http://services.routetopa.eu/DEEalerProvider/COMPONENTS/datalets/leafletjs-datalet/leafletsjs/images'; 89 L.Icon.Default.imagePath = 'http://services.routetopa.eu/DEEalerProvider/COMPONENTS/datalets/leafletjs-datalet/leafletsjs/images';
90 90
91 - var coordinates = [];  
92 - var coordinates_index = 0;  
93 - var isArray = t.data[0].data[0].constructor === Array;  
94 -  
95 - for(var i=0; i<t.data[0].data.length; i++)  
96 - {  
97 - if(isArray)  
98 - {  
99 - if(!isNaN(t.data[0].data[i][0]) && !isNaN(t.data[0].data[i][1]))  
100 - coordinates.push([parseFloat(t.data[0].data[i][0]), parseFloat(t.data[0].data[i][1])]);  
101 - else  
102 - continue;  
103 - }  
104 - else  
105 - {  
106 - if(!isNaN(t.data[0].data[i]) && !isNaN(t.data[1].data[i]))  
107 - coordinates.push([parseFloat(t.data[0].data[i]), parseFloat(t.data[1].data[i])]);  
108 - else  
109 - continue;  
110 - }  
111 -  
112 - var marker = L.marker([coordinates[coordinates_index][0], coordinates[coordinates_index][1]]).addTo(t._component.map);  
113 - coordinates_index++;  
114 -  
115 - if(t.data.length > 2)  
116 - {  
117 - var popupText = "";  
118 - for(var j=2; j<t.data.length; j++)  
119 - {  
120 - if(typeof t.data[j] != 'undefined' && typeof t.data[j].data[i] != 'undefined')  
121 - {  
122 - if (t.data[j].data[i].toString().match(new RegExp("^(http[s]?:\\/\\/(www\\.)?|ftp:\\/\\/(www\\.)?|www\\.){1}([0-9A-Za-z-\\.@:%_\+~#=]+)+((\\.[a-zA-Z]{2,3})+)(/(.)*)?(\\?(.)*)?")))  
123 - popupText += '<image height="100" width="100" src="' + t.data[j].data[i] + '" /><br/>';  
124 - else  
125 - popupText += '<span>' + t.data[j].name + ' : ' + t.data[j].data[i] + '</span><br/>'  
126 - }  
127 - }  
128 -  
129 - var popup = L.popup().setContent(popupText);  
130 - marker.bindPopup(popup);  
131 - }  
132 - } 91 + var geoJsonLayer = L.geoJson(t.data[0].data).addTo(t._component.map);
133 92
134 t._component.map._onResize(); 93 t._component.map._onResize();
135 t._component.map.invalidateSize(false); 94 t._component.map.invalidateSize(false);
136 - t._component.map.fitBounds(coordinates); 95 + t._component.map.fitBounds(geoJsonLayer);
137 96
138 } 97 }
139 }; 98 };
@@ -197,7 +156,7 @@ Example: @@ -197,7 +156,7 @@ Example:
197 * @method ready 156 * @method ready
198 */ 157 */
199 ready: function(){ 158 ready: function(){
200 - this.behavior = $.extend(true, {}, BaseDataletBehavior, WorkcycleBehavior, AjaxJsonAlasqlBehavior, leafletjsBehavior); 159 + this.behavior = $.extend(true, {}, BaseDataletBehavior, WorkcycleBehavior, AjaxJsonAlasqlBehavior, leafletjsgeojsonBehavior);
201 this.async(function(){this.behavior.init(this)},100); 160 this.async(function(){this.behavior.init(this)},100);
202 } 161 }
203 }); 162 });