Skip to content

Commit 4c29f84

Browse files
Merge pull request allenhwkim#1 from sebas-nicholls/sebas-nicholls-patch-bug-511
Fixed bug allenhwkim#511
2 parents dd4b047 + 4027d17 commit 4c29f84

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

services/attr2-map-options.js

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,26 @@
4040
}
4141
return JSON.parse(jsonizeFilter(input));
4242
};
43-
43+
4444
var getLatLng = function(input) {
4545
var output = input;
46-
if (input[0].constructor == Array) { // [[1,2],[3,4]]
47-
output = input.map(function(el) {
48-
return new google.maps.LatLng(el[0], el[1]);
49-
});
50-
} else if(!isNaN(parseFloat(input[0])) && isFinite(input[0])) {
46+
if (input[0].constructor == Array) {
47+
if ((input[0][0].constructor == Array && input[0][0].length == 2) || input[0][0].constructor == Object) {
48+
var preoutput;
49+
var outputArray = [];
50+
for (var i = 0; i < input.length; i++) {
51+
preoutput = input[i].map(function(el){
52+
return new google.maps.LatLng(el[0], el[1]);
53+
});
54+
outputArray.push(preoutput);
55+
}
56+
output = outputArray;
57+
} else {
58+
output = input.map(function(el) {
59+
return new google.maps.LatLng(el[0], el[1]);
60+
});
61+
}
62+
} else if (!isNaN(parseFloat(input[0])) && isFinite(input[0])) {
5163
output = new google.maps.LatLng(output[0], output[1]);
5264
}
5365
return output;
@@ -61,11 +73,16 @@
6173
try { // 2. JSON?
6274
var output = getJSON(input);
6375
if (output instanceof Array) {
64-
// [{a:1}] : not lat/lng ones
6576
if (output[0].constructor == Object) {
6677
output = output;
67-
} else { // [[1,2],[3,4]] or [1,2]
68-
output = getLatLng(output);
78+
} else if (output[0] instanceof Array) {
79+
if (output[0][0].constructor == Object) {
80+
output = output;
81+
} else {
82+
output = getLatLng(output);
83+
}
84+
} else {
85+
output = getLatLng(output);
6986
}
7087
}
7188
// JSON is an object (not array or null)

0 commit comments

Comments
 (0)