Bug 60397 - Xamarin.Forms.Maps GetPositionsForAddressAsync geocoder returns wrong lat/long
Summary: Xamarin.Forms.Maps GetPositionsForAddressAsync geocoder returns wrong lat/long
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.4.0
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2017-10-26 15:26 UTC by Teryn
Modified: 2017-11-13 20:10 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Current Location of Columbia, SC (56.20 KB, image/png)
2017-11-02 04:50 UTC, Teryn
Current Location of St. Louis, MO (56.81 KB, image/png)
2017-11-02 04:51 UTC, Teryn
Current location of Wichita, KS (54.81 KB, image/png)
2017-11-02 04:51 UTC, Teryn
Current Location of Ireland (54.43 KB, image/png)
2017-11-02 04:51 UTC, Teryn

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and 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 Links.

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.

Related Links:

Description Teryn 2017-10-26 15:26:33 UTC
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".

	IEnumerable<Position> locations;
	var geoCoder = new Geocoder();

	if (IsSearchTextNumeric)
		locations = await geoCoder.GetPositionsForAddressAsync(SelectedLocation.ZipCode);
		await geoCoder.GetPositionsForAddressAsync(SelectedLocation.CityState);

	SearchedPosition = locations.FirstOrDefault();
Comment 1 Paul DiPietro [MSFT] 2017-11-01 18:16:29 UTC
Is this happening on any platform in particular and can you upload a reproduction?
Comment 2 Teryn 2017-11-02 04:49:55 UTC
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.
Comment 3 Teryn 2017-11-02 04:50:37 UTC
Created attachment 25537 [details]
Current Location of Columbia, SC
Comment 4 Teryn 2017-11-02 04:51:00 UTC
Created attachment 25538 [details]
Current Location of St. Louis, MO
Comment 5 Teryn 2017-11-02 04:51:22 UTC
Created attachment 25539 [details]
Current location of Wichita, KS
Comment 6 Teryn 2017-11-02 04:51:47 UTC
Created attachment 25540 [details]
Current Location of Ireland
Comment 7 Teryn 2017-11-13 17:23:01 UTC
Have attached a sample repo and screenshots showing the issue.
Comment 8 Paul DiPietro [MSFT] 2017-11-13 19:37:53 UTC
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.
Comment 9 Teryn 2017-11-13 19:46:05 UTC
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.
Comment 10 Paul DiPietro [MSFT] 2017-11-13 20:10:12 UTC
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.