钛 - 添加数字时的问题
我使用forwardGeocoder 获取纬度值,并将获得的纬度值与十进制数相加。看看下面的代码。
Ti.Geolocation.forwardGeocoder(textField.value, function(e) {
var a = e.latitude;
var b = 0.1;
var c = a+b;
Ti.API.info('result c: '+c);
});
结果显示
[INFO] result c: 40.7145500.1
问题是,给定的值没有添加到纬度值中,它只是与字符串一起打印。
当我尝试减法时,效果很好。当我尝试使用 a
和 b
的自定义值时,效果很好。
Ti.Geolocation.forwardGeocoder(textField.value, function(e) {
var a = 0.1;
var b = 0.1;
var c = a+b;
Ti.API.info('result c: '+c);
});
结果显示
[INFO] result c: 0.2
那么,如何在获得的纬度上添加一个数字呢?帮我解决这个问题。提前致谢。
I am getting a latitude value using forwardGeocoder and I am adding the obtained latitude value with a decimal number. Have a look at the below code.
Ti.Geolocation.forwardGeocoder(textField.value, function(e) {
var a = e.latitude;
var b = 0.1;
var c = a+b;
Ti.API.info('result c: '+c);
});
The result shows
[INFO] result c: 40.7145500.1
The problem is, the given value is not added to the latitude value, it is just printed along with the sting.
When I tried subtraction, it worked fine. When I tried using custom values for a
and b
, it worked fine.
Ti.Geolocation.forwardGeocoder(textField.value, function(e) {
var a = 0.1;
var b = 0.1;
var c = a+b;
Ti.API.info('result c: '+c);
});
The result shows
[INFO] result c: 0.2
So, how could I add a number to the obtained latitude? Help me to solve this issue. Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来
e.latitude
是一个字符串,JavaScript 正在将Number
转换为字符串并将其连接起来。试试这个:
It looks like
e.latitude
is a string, and JavaScript is converting theNumber
to a string and concatenating it.Try this: