Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
This bug is in the Xamarin.Forms.Maps nuget package. We are trying to get a latitude and longitude for a given city, state or zip code. We noticed that if our current location is within the United States, we get back a correct lat/long, 34.009286/-81.037094. When testing our application from a location outside of the United States we noticed that passing in "Columbia, SC" to the geocoder method "GetPositiionsForAddressAsync" method returns a lat/long of 3.481683/-76.6186344. This location is in Colombia South America and not in the United States. Below is the code we are doing, with the SelectedLocation.CityState variable being "Columbia, SC".
var geoCoder = new Geocoder();
locations = await geoCoder.GetPositionsForAddressAsync(SelectedLocation.ZipCode);
SearchedPosition = locations.FirstOrDefault();
Is this happening on any platform in particular and can you upload a reproduction?
I've done some more checking and I can only seem to recreate it on iOS, so Android does not have the same issue as best as I can tell. I've also narrowed down that it does actually happen in the USA as well, but in further locations. If I set the device's location to locations such as Columbia, SC or St. Louis, MO, then I get the correct lat/long back. If I set my current location to Wichita, KS, I get back a Colombia, South America lat/long. Below are the locations I was using to test with as well as the results:
current location: 33.9896 -81.0659 near Columbia, SC
38.516739, -90.097282 near St. Louis, MO
returns: 34.009286, -81.037094 Columbia, SC USA
current location: 37.682503, -97.551730 near Wichita, KS
53.4129, -8.2439 Ireland
returns: 3.481683, -76.6186344 Colombia, South America
I've built a test repo that you can find here: https://github.com/teryngull/TestColumbia
I've also uploaded some screenshots of iOS showing the current locations lat/longs as well as the results.
Let me know if you need any other info.
Created attachment 25537 [details]
Current Location of Columbia, SC
Created attachment 25538 [details]
Current Location of St. Louis, MO
Created attachment 25539 [details]
Current location of Wichita, KS
Created attachment 25540 [details]
Current Location of Ireland
Have attached a sample repo and screenshots showing the issue.
This is normal behavior which XF.Maps should be having no effect on; map results vary based on the location being searched from -- outside of the US, searching for "Columbia, SC, USA" should return the expected result. A good example would be the wildly varying results if you searched for "1st Avenue" or "Main Street" instead.
So, I see how adding USA to the query gets it to work. I don't believe that it should come back with a Colombia, South America lat/long if you are in the United States. That is what my test proved - that if you set your location to Kansas, or further west, it comes back as Colombia, South America as well. To me, if you're in America passing in Columbia, SC with or without USA, it should return the South Carolina lat/long, not South America.
I understand your concern, but unfortunately this is not really under our control so I don't expect any changes to be made here because it could affect other users' expectations as well. I suggest simply passing a specific query for your needs which solves the problem with minimal effort.