public void Done(Object context, Response response) { if (context is GClientGeocoder) { GClientGeocoder geoCoder = (GClientGeocoder)context; SearchResponse(geoCoder, response); } }
public void ReadProgress(Object context, int bytes, int total) { if (context is GClientGeocoder) { GClientGeocoder geoCoder = (GClientGeocoder)context; geoCoder._listener.readProgress(bytes, total); } }
private static void SearchResponse(GClientGeocoder geoCoder, Response response) { MapPoint[] mapPoints = null; Exception ex = response.GetException(); if (ex != null || response.GetCode() != HttpStatusCode.OK) { if (geoCoder._listener != null) { geoCoder._listener.done(geoCoder._searchAddress, null); } return; } try { Result result = response.GetResult(); result.GetAsString("name"); int resultCount = result.GetSizeOfArray("Placemark"); if (resultCount > 0) { mapPoints = new MapPoint[resultCount]; for (int i = 0; i < resultCount; i++) { mapPoints[i] = new MapPoint { Name = result.GetAsString("Placemark[" + i + "].address") }; string location = result.GetAsString("Placemark[" + i + "].Point.coordinates"); GeoLatLng latLng = MapLayer.FromStringToLatLng(location); mapPoints[i].SetPoint(latLng); } if (geoCoder._addressCache.Count > 24) { int j = 0; ICollection keys = geoCoder._addressCache.Keys; foreach (string key1 in keys) { geoCoder._addressCache.Remove(key1); j++; if (j > 12) { break; } } } geoCoder._addressCache.Add(mapPoints[0].Name, mapPoints[0]); } } catch (Exception) { } if (geoCoder._listener != null) { geoCoder._listener.done(geoCoder._searchAddress, mapPoints); } }
private static void SearchResponse(GClientGeocoder geoCoder, Response response) { MapPoint[] mapPoints = null; Exception ex = response.GetException(); if (ex != null || response.GetCode() != HttpStatusCode.OK) { if (geoCoder._listener != null) { geoCoder._listener.done(geoCoder._searchAddress, null); } return; } try { Result result = response.GetResult(); result.GetAsString("name"); int resultCount = result.GetSizeOfArray("Placemark"); if (resultCount > 0) { mapPoints = new MapPoint[resultCount]; for (int i = 0; i < resultCount; i++) { mapPoints[i] = new MapPoint { Name = result.GetAsString("Placemark[" + i + "].address") }; string location = result.GetAsString("Placemark[" + i + "].Point.coordinates"); GeoLatLng latLng = MapLayer.FromStringToLatLng(location); mapPoints[i].SetPoint(latLng); } if (geoCoder._addressCache.Count > 24) { int j = 0; ICollection keys = geoCoder._addressCache.Keys; foreach (string key1 in keys) { geoCoder._addressCache.Remove(key1); j++; if (j > 12) break; } } geoCoder._addressCache.Add(mapPoints[0].Name, mapPoints[0]); } } catch (Exception) { } if (geoCoder._listener != null) { geoCoder._listener.done(geoCoder._searchAddress, mapPoints); } }