Commit 2994d9bb757d536779dfc24ca15608ed22a5f1ed
1 parent
413bc541
plugin update
Showing
1 changed file
with
30 additions
and
10 deletions
datalets/leafletjs-geojson-datalet/leafletjs-geojson-datalet.html
@@ -72,12 +72,13 @@ Example: | @@ -72,12 +72,13 @@ Example: | ||
72 | * | 72 | * |
73 | * @method transformData | 73 | * @method transformData |
74 | */ | 74 | */ |
75 | - presentData: function(){ | 75 | + presentData: function() { |
76 | 76 | ||
77 | var t = this; | 77 | var t = this; |
78 | - try{ | ||
79 | - this._component.map = L.map(this._component.$.leafletjs).setView([0, 0], 13, {reset:true}); | ||
80 | - }catch(e){} | 78 | + try { |
79 | + this._component.map = L.map(this._component.$.leafletjs).setView([0, 0], 13, {reset: true}); | ||
80 | + } catch (e) { | ||
81 | + } | ||
81 | 82 | ||
82 | 83 | ||
83 | L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { | 84 | L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { |
@@ -88,11 +89,34 @@ Example: | @@ -88,11 +89,34 @@ Example: | ||
88 | 89 | ||
89 | L.Icon.Default.imagePath = 'http://services.routetopa.eu/DEEalerProvider/COMPONENTS/datalets/leafletjs-datalet/leafletsjs/images'; | 90 | L.Icon.Default.imagePath = 'http://services.routetopa.eu/DEEalerProvider/COMPONENTS/datalets/leafletjs-datalet/leafletsjs/images'; |
90 | 91 | ||
91 | - var geoJsonLayer = L.geoJson(t.data[0].data).addTo(t._component.map); | 92 | + var bounding_box = L.geoJson(t.data[0].data); |
93 | + | ||
94 | + for (var i = 0; i < t.data[0].data.length; i++) | ||
95 | + { | ||
96 | + var geoJsonLayer = L.geoJson(t.data[0].data[i]).addTo(t._component.map); | ||
97 | + | ||
98 | + if(t.data.length > 1) | ||
99 | + { | ||
100 | + var popupText = ""; | ||
101 | + for(var j=1; j<t.data.length; j++) | ||
102 | + { | ||
103 | + if(typeof t.data[j] != 'undefined' && typeof t.data[j].data[i] != 'undefined') | ||
104 | + { | ||
105 | + 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})+)(/(.)*)?(\\?(.)*)?"))) | ||
106 | + popupText += '<image height="100" width="100" src="' + t.data[j].data[i] + '" /><br/>'; | ||
107 | + else | ||
108 | + popupText += '<span>' + t.data[j].name + ' : ' + t.data[j].data[i] + '</span><br/>' | ||
109 | + } | ||
110 | + } | ||
111 | + | ||
112 | + var popup = L.popup().setContent(popupText); | ||
113 | + geoJsonLayer.bindPopup(popup); | ||
114 | + } | ||
115 | + } | ||
92 | 116 | ||
93 | t._component.map._onResize(); | 117 | t._component.map._onResize(); |
94 | t._component.map.invalidateSize(false); | 118 | t._component.map.invalidateSize(false); |
95 | - t._component.map.fitBounds(geoJsonLayer); | 119 | + t._component.map.fitBounds(bounding_box); |
96 | 120 | ||
97 | } | 121 | } |
98 | }; | 122 | }; |
@@ -103,10 +127,6 @@ Example: | @@ -103,10 +127,6 @@ Example: | ||
103 | is : 'leafletjs-geojson-datalet', | 127 | is : 'leafletjs-geojson-datalet', |
104 | 128 | ||
105 | properties : { | 129 | properties : { |
106 | - data: { | ||
107 | - type: Array, | ||
108 | - value: undefined | ||
109 | - }, | ||
110 | /** | 130 | /** |
111 | * Store a reference to the leafletjs map object created in 'ready' callback | 131 | * Store a reference to the leafletjs map object created in 'ready' callback |
112 | * @attribute map | 132 | * @attribute map |