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.
It looks like
e.latitudeis a string, and JavaScript is converting theNumberto a string and concatenating it.Try this: