示例#1
0
 public static object ReverseGeoCode(string latlng, bool returnFullAddress = false)
 {
     //Initializer and  query partner server
     using (PartnerServiceRequestProcessor webRequest = new PartnerServiceRequestProcessor(new ReverseGeoCode(Application.Context.Resources.GetString(RidersApp.Resource.String.PlacesAPIKey), latlng)))
     {
         Exception exception = webRequest.GetPatnerServiceQueryException();
         //check if there was an exception in the line above
         if (exception == null)
         {
             //since there was no exception in the line above then get the response and cast to expectad wrapper object
             ReverseGeoCodeRootObject address = (ReverseGeoCodeRootObject)webRequest.ProcessPartnerServiceQueryResult();
             if (address != null)
             {
                 if (returnFullAddress == false)
                 {
                     return(address.results[0].formatted_address);
                 }
                 else
                 {
                     return(address);
                 }
             }
             else
             {
                 Console.WriteLine(">>>>>>>>  PEN " + exception.Message + " <<<<<<<<<");
                 return(null);
             };
         }
         else if (((System.Net.WebException)exception).Status == System.Net.WebExceptionStatus.SecureChannelFailure)
         {
             //since there was no exception in the line above then get the response and cast to expectad wrapper object
             ReverseGeoCodeRootObject address = (ReverseGeoCodeRootObject)webRequest.ProcessPartnerServiceQueryResult();
             if (address != null)
             {
                 if (returnFullAddress == false)
                 {
                     return(address.results[0].formatted_address);
                 }
                 else
                 {
                     return(address);
                 }
             }
             else
             {
                 Console.WriteLine(">>>>>>>>  PEN " + exception.Message + " <<<<<<<<<");
                 return(null);
             };
         }
         else
         {
             Console.WriteLine(">>>>>>>>  ULTIMATE " + exception.Message + " <<<<<<<<<");
             return(null);
         }
     }
 }
示例#2
0
 public GoogleDirectionClass GetDirectionsData(SharedPartnerDataModels.Bounds2 bounds)
 {
     //Initializer and  query partner server
     using (PartnerServiceRequestProcessor webRequest = new PartnerServiceRequestProcessor(
                new Directions(Application.Context.Resources.GetString(RidersApp.Resource.String.PlacesAPIKey), new SharedPartnerDataModels.Location(bounds.northeast), new SharedPartnerDataModels.Location(bounds.southwest))))
     {
         Exception            exception  = webRequest.GetPatnerServiceQueryException();
         GoogleDirectionClass directions = null;
         if (exception is null)
         {
             directions = (GoogleDirectionClass)webRequest.ProcessPartnerServiceQueryResult();
         }
         return(directions);
     }
 }