离子: - 将字符串转换为latlng在最后附加更多数字?
问题描述:
我想将字符串转换为latlng假设字符串是23.097278,72.446139我想将它转换为latlng,当我拆分字符串时我得到的结果是我想要的,但是当我转换为latlng时它会在坐标末尾附加一些数字 例如 centerPoint:(23.081295,72.49794399999996),到目前为止我所做的是在plz下面帮我解决它。离子: - 将字符串转换为latlng在最后附加更多数字?
temp="23.097278,72.446139";
let temp1 = temp.split(',');
let coordinatesLat = temp1[0];
let coordinatesLong = temp1[1];
console.log("temp1 : " +coordinatesLong);
let centerPoint = new google.maps.LatLng(coordinatesLat, coordinatesLong);
console.log("centerPoint : " +centerPoint);
在日志
temp1 : 72.497944
centerPoint : (23.081295, 72.49794399999996)
答
尝试转换输出到浮动
变种latDouble = parseFloat(LAT); var longDouble = parseFloat(long);
无法使用此代码 –