When developing the Bing Maps Wrapper service for the WP7Contrib we weren't aware of the importance of the instance of the CultureInfo class used to format the geo-coordinate data when building the URL parameters.
This was for the simple reason, being based in the UK we were relying on the default culture, which happens to be 'en-US' and this culture formats decimal numbers in the required format for calls to the Bing Maps REST API. The documentation on MSDN does state this, but does not make it very clear.
Show below is the formatting for a couple of different cultures, what you'll see is the formatting for the Lat & Long for the Netherlands & Russian cultures is different to the rest. They both use commas as the decimal point.
When the Lat & Long are used to format the URL parameter they need to be in InvariantCulture so that your URL looks like the following:
If I force the Bing Maps Service to use the Netherlands culture with the code shown below (taken from inside the service class):
Then I get the following output in visual studio; What's interesting is the Bing Maps server doesn't return an error code (it still returns a status code of 200) even though the location data is formatted incorrectly. This is why I have added the boolean checks 'HasSucceeded' & 'HasLocations' to the result class.
So now when formatting floating point numbers for use with the Bings Maps API we use the following style inside the Bing Maps Wrapper service:
Thanks to Derek Lakin for pointing this one out, you can see multi-culture Bing Maps REST API requests being used in his WP7 app 'Car Finder'.
This was for the simple reason, being based in the UK we were relying on the default culture, which happens to be 'en-US' and this culture formats decimal numbers in the required format for calls to the Bing Maps REST API. The documentation on MSDN does state this, but does not make it very clear.
Show below is the formatting for a couple of different cultures, what you'll see is the formatting for the Lat & Long for the Netherlands & Russian cultures is different to the rest. They both use commas as the decimal point.
When the Lat & Long are used to format the URL parameter they need to be in InvariantCulture so that your URL looks like the following:
If I force the Bing Maps Service to use the Netherlands culture with the code shown below (taken from inside the service class):
Then I get the following output in visual studio; What's interesting is the Bing Maps server doesn't return an error code (it still returns a status code of 200) even though the location data is formatted incorrectly. This is why I have added the boolean checks 'HasSucceeded' & 'HasLocations' to the result class.
So now when formatting floating point numbers for use with the Bings Maps API we use the following style inside the Bing Maps Wrapper service:
Thanks to Derek Lakin for pointing this one out, you can see multi-culture Bing Maps REST API requests being used in his WP7 app 'Car Finder'.
Comments
Post a Comment