Commit e99be101e4dbbc45fc84980cb6ba2c31e3b150e0

Authored by Andrea Petta
1 parent 10349394

leafletjs

datalets/leafletjs-datalet/leafletjs-datalet.html
@@ -85,42 +85,41 @@ Example: @@ -85,42 +85,41 @@ Example:
85 attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors' 85 attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors'
86 }).addTo(this._component.map); 86 }).addTo(this._component.map);
87 87
88 -// setTimeout(function() {  
89 88
90 - 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';
91 90
92 - var coordinates = [];  
93 - var isArray = t.data[0].data[0].constructor === Array; 91 + var coordinates = [];
  92 + var isArray = t.data[0].data[0].constructor === Array;
94 93
95 - for(var i=0; i<t.data[0].data.length; i++)  
96 - {  
97 - if(isArray)  
98 - coordinates.push([parseFloat(t.data[0].data[i][0]), parseFloat(t.data[0].data[i][1])]);  
99 - else  
100 - coordinates.push([parseFloat(t.data[0].data[i]), parseFloat(t.data[1].data[i])]); 94 + for(var i=0; i<t.data[0].data.length; i++)
  95 + {
  96 + if(isArray)
  97 + coordinates.push([parseFloat(t.data[0].data[i][0]), parseFloat(t.data[0].data[i][1])]);
  98 + else
  99 + coordinates.push([parseFloat(t.data[0].data[i]), parseFloat(t.data[1].data[i])]);
101 100
102 - var marker = L.marker([coordinates[i][0], coordinates[i][1]]).addTo(t._component.map); 101 + var marker = L.marker([coordinates[i][0], coordinates[i][1]]).addTo(t._component.map);
103 102
104 - if(t.data.length > 2) 103 + if(t.data.length > 2)
  104 + {
  105 + var popupText = "";
  106 + for(var j=2; j<t.data.length; j++)
105 { 107 {
106 - var popupText = "";  
107 - for(var j=2; j<t.data.length; j++)  
108 - {  
109 - 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})+)(/(.)*)?(\\?(.)*)?")))  
110 - popupText += '<image height="100" width="100" src="' + t.data[j].data[i] + '" /><br/>';  
111 - else  
112 - popupText += '<span>' + t.data[j].data[i] + '</span><br/>'  
113 - }  
114 -  
115 - var popup = L.popup().setContent(popupText);  
116 - marker.bindPopup(popup); 108 + 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})+)(/(.)*)?(\\?(.)*)?")))
  109 + popupText += '<image height="100" width="100" src="' + t.data[j].data[i] + '" /><br/>';
  110 + else
  111 + popupText += '<span>' + t.data[j].data[i] + '</span><br/>'
117 } 112 }
  113 +
  114 + var popup = L.popup().setContent(popupText);
  115 + marker.bindPopup(popup);
118 } 116 }
  117 + }
  118 +
  119 + t._component.map._onResize();
  120 + t._component.map.invalidateSize(false);
  121 + t._component.map.fitBounds(coordinates);
119 122
120 - t._component.map._onResize();  
121 - t._component.map.invalidateSize(false);  
122 - t._component.map.fitBounds(coordinates);  
123 -// }, 0)  
124 } 123 }
125 }; 124 };
126 125
@@ -172,8 +171,7 @@ Example: @@ -172,8 +171,7 @@ Example:
172 */ 171 */
173 ready: function(){ 172 ready: function(){
174 this.behavior = $.extend(true, {}, BaseDataletBehavior, WorkcycleBehavior, AjaxJsonAlasqlBehavior, leafletjsBehavior); 173 this.behavior = $.extend(true, {}, BaseDataletBehavior, WorkcycleBehavior, AjaxJsonAlasqlBehavior, leafletjsBehavior);
175 -// this.behavior.init(this);  
176 - this.async(function(){this.behavior.init(this)},0); 174 + this.async(function(){this.behavior.init(this)},100);
177 } 175 }
178 }); 176 });
179 </script> 177 </script>