c# - ReverseGeocodeQuery does not return correct information -
i created class reverse geocode.
public static class reversegeocoding { public static observablecollection<string> addresses = new observablecollection<string>(); public static string address; public static task<mapaddress> doreversegeocodingasync( geocoordinate location ) { mapaddress mapaddress = null; var reversegeocode = new reversegeocodequery { geocoordinate = new geocoordinate( location.latitude, location.longitude ) }; var tcs = new taskcompletionsource<mapaddress>(); eventhandler<querycompletedeventargs<system.collections.generic.ilist<maplocation>>> handler = null; handler = ( sender, args ) => { if ( args.error != null ) { tcs.setexception( args.error ); } else if ( args.cancelled ) { tcs.setcanceled(); } else { if ( args.result.count > 0 ) { var firstordefault = args.result.firstordefault(); if ( firstordefault != null ) { mapaddress = firstordefault.information.address; } } reversegeocode.querycompleted -= handler; tcs.setresult( mapaddress ); } }; reversegeocode.querycompleted += handler; reversegeocode.queryasync(); return tcs.task; } }
as call first (35, -112 example) country , country code (usa) shown. second time calling function data returned full expected (williams, az 86046).
any idea doing wrong here?
investigating more issue found out following:
the location (geocoordinate) taken center of map on page. if map zoomed (zoomlevel) less 10, find issue happening, , if map zoomed more 10 works ok. not sure why happening. idea? else noticed that?
Comments
Post a Comment