In the code, lat and lng are initialized as number types, but why does it become string when you put it in an object?
I want the coordinate values to be numbers.
What can I do?
ex) lat: “35.87” -> lat: 35.87
let lat_tmp = 0;
let lng_tmp = 0;
const lat_lng = [];
let lat_tmp = 0;
let lng_tmp = 0;
let arr_tmp = [
{
lat: 0,
lng: 0,
},
];
let idx = 0;
function successFunction(data) {
var allRows = data.split(/r?n|r/);
for (var singleRow = 1; singleRow < allRows.length; singleRow++) {
var rowCells = allRows[singleRow].split(',');
for (var rowCell = 0; rowCell < rowCells.length; rowCell++) {
if (rowCell === 3) {
lat_tmp = rowCells[rowCell];
} else if (rowCell === 4) {
lng_tmp = rowCells[rowCell];
}
}
arr_tmp = [{ lat: lat_tmp, lng: lng_tmp }];
lat_lng[idx] = arr_tmp;
idx += 1;
}
console.log(lat_lng);
}