GeocodeQuery - GeoCoordinate property

时光总嘲笑我的痴心妄想 提交于 2019-12-22 12:17:11

问题


Can somebody explain me difference between these pieces of code? What is the role of GeoCoordinate property in GeocodeQuery?

#1 - this works only with internet connection

GeocodeQuery geocodeQuery = new GeocodeQuery();
geocodeQuery.GeoCoordinate = new GeoCoordinate();
geocodeQuery.SearchTerm = "London";

IList<MapLocation> locations = await geocodeQuery.GetMapLocationsAsync();

#2 - this works without internet connection

// my location
Geolocator geolocator = new Geolocator();
geolocator.DesiredAccuracy = PositionAccuracy.High;

Geoposition position = await geolocator.GetGeopositionAsync();

// geocode query
GeocodeQuery geocodeQuery = new GeocodeQuery();

geocodeQuery.GeoCoordinate = position.Coordinate.ToGeoCoordinate();
geocodeQuery.SearchTerm = "London";

IList<MapLocation> locations = await geocodeQuery.GetMapLocationsAsync();

回答1:


The GeoCoordinate property is the location upon which to center the query.

The GeocodeQuery will find locations near the specified location.

I would assume that if you don't specify a location it makes a network request to try and identify your location. (Possibly by a reverse IP lookup or to attempt to obtain your current location based on public WiFi hotspot data.)
This is based on the query falling back to use current location if no location is specified.

Also note that if the user has not downloaded local (to the query center / geocoordinate) maps data then I would expect a network request to be necessary in that scenario too.
Note also that some maps data will be cached so that may impact your testing of this also.



来源:https://stackoverflow.com/questions/19139228/geocodequery-geocoordinate-property

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!