|
180 | 180 |
|
181 | 181 | for(var gtype in params.geom) { |
182 | 182 | var val = params.geom[gtype]; |
| 183 | + var coordinates = []; |
| 184 | + var itemClone; |
| 185 | + var paths; |
183 | 186 |
|
184 | 187 | // Geometry parameter specified as: {Point: 'coords'} |
185 | 188 | if(typeof val === 'string' && item.hasOwnProperty(val)) { |
|
225 | 228 |
|
226 | 229 | // Geometry parameter specified as: {Point: ['container.lat', 'container.lng', 'container.alt']} |
227 | 230 | else if(Array.isArray(val) && isNested(val[0]) && isNested(val[1]) && isNested(val[2])){ |
228 | | - var coordinates = []; |
229 | 231 | for (var i = 0; i < val.length; i++) { // i.e. 0 and 1 |
230 | | - var paths = val[i].split('.'); |
231 | | - var itemClone = item; |
| 232 | + paths = val[i].split('.'); |
| 233 | + itemClone = item; |
232 | 234 | for (var j = 0; j < paths.length; j++) { |
233 | 235 | if (itemClone == undefined || !itemClone.hasOwnProperty(paths[j])) { |
234 | 236 | return false; |
|
243 | 245 |
|
244 | 246 | // Geometry parameter specified as: {Point: ['container.lat', 'container.lng']} |
245 | 247 | else if(Array.isArray(val) && isNested(val[0]) && isNested(val[1])){ |
246 | | - var coordinates = []; |
247 | | - for (var i = 0; i < val.length; i++) { // i.e. 0 and 1 |
248 | | - var paths = val[i].split('.'); |
249 | | - var itemClone = item; |
250 | | - for (var j = 0; j < paths.length; j++) { |
251 | | - if (itemClone == undefined || !itemClone.hasOwnProperty(paths[j])) { |
| 248 | + for (var k = 0; k < val.length; k++) { // i.e. 0 and 1 |
| 249 | + paths = val[k].split('.'); |
| 250 | + itemClone = item; |
| 251 | + for (var l = 0; l < paths.length; l++) { |
| 252 | + if (itemClone == undefined || !itemClone.hasOwnProperty(paths[l])) { |
252 | 253 | return false; |
253 | 254 | } |
254 | | - itemClone = itemClone[paths[j]]; // Iterate deeper into the object |
| 255 | + itemClone = itemClone[paths[l]]; // Iterate deeper into the object |
255 | 256 | } |
256 | | - coordinates[i] = itemClone; |
| 257 | + coordinates[k] = itemClone; |
257 | 258 | } |
258 | 259 | geom.type = gtype; |
259 | 260 | geom.coordinates = [Number(coordinates[1]), Number(coordinates[0])]; |
|
0 commit comments