Windows Phone replacing period (.) with comma (,) when concatenating Strings

14 views
Skip to first unread message

cubiq1

unread,
Sep 4, 2014, 4:10:19 PM9/4/14
to codenameone...@googlegroups.com
Hi,

I'm using the Google reverse geocoder service in my app. On Windows Phone, when using the URL below, the coordinate values contain "," instead of "." For example: 40,71453,-74,005972000000008 instead of 40.71453,-74.005972000000008

(coords is of type Location, and holds my current position.)

String url = "http://maps.googleapis.com/maps/api/geocode/json?sensor=false&latlng=" + coords.getLatitude() + "," + coords.getLongitude();

It must be something to do with the way Windows Phone concatenates or handles Strings as this fixes the problem:

String url = "http://maps.googleapis.com/maps/api/geocode/json?sensor=false&latlng=" + StringUtil.replaceAll(latitude, ",", ".") + "," + StringUtil.replaceAll(longitude, ",", ".");

This literally took me hours of debugging as it only occurs on hardware (Lumia 520).

I hope this is of some help.

Cheers

cubiq1

unread,
Sep 4, 2014, 4:12:29 PM9/4/14
to codenameone...@googlegroups.com
Apologies, the solution is as follows:

String latitude = String.valueOf(coords.getLatitude());
String longitude = String.valueOf(coords.getLongitude());
Reply all
Reply to author
Forward
0 new messages