Share via


LocationServiceSoap.GetNearbyCategories Method

Gets Find Nearby categories based on the current user's (the original submitter of the request) culture.

Public Function GetNearbyCategories ()

      _ As LocationServiceSoap.FindNearbyCategory()
[C#]
public LocationServiceSoap.FindNearbyCategory[] GetNearbyCategories ();

Remarks

A null value is returned when no Find Nearby categories are found. When matching Find Nearby categories for the current user's culture are found, an array of FindNearbyCategory objects are returned.

The search process uses the caller's culture in the following ways:

Specific culture match—If a Find Nearby category has a DisplayName property defined for the caller’s culture, that DisplayName property and the corresponding DisplayDescription property are returned.

Neutral culture match—If there is no exact match for the caller’s specific culture, the neutral culture (language) of caller’s culture is used to find the matching DisplayName and DisplayDescription properties. For example if the caller’s specific culture is “de-DE”, the caller's neutral culture is “de”. If the Find Nearby category has no DisplayName property defined for “de-DE” but it has a DisplayName property for “de”, that DisplayName property and its corresponding DisplayDescription are returned.

Default match—If the specific and neutral culture searches fail to find DisplayName and DisplayDescription properties, the DisplayName and DisplayDescription properties for the DefaultCulture property of the Find Nearby category are returned.

The returned array is sorted alphabetically in ascending order based on the DisplayName property of the Find Nearby category localized names property (i.e., FindNearbyCategoryName.DisplayName). The caller’s culture is used to sort the array.

This method accepts the following SOAP headers:

UserInfoLocationHeader—Used to establish the current user's (the user that is invoking the location service) specific information, such as culture and default distance unit. When this SOAP header is not provided, the current user's default culture is applied. For more information, see UserInfoLocationHeader Class.
Note Setting the DefaultDistanceUnit property of the UserInfoLocationHeader does not affect the GetNearbyCategories method.

ClientIdHeader—Not used with MapPoint Location Server 1.0.

Because this is a Web service, all exceptions appear as SOAP exceptions. For more information, see the SoapException.Detail property.

Example

 
[Visual Basic]
    'Create a LocationServiceSoap proxy instance.
    Dim MyLocationService As New LocationServiceSoap
    'Create and add the credentials required to access the Web service.
    Dim MyCredentials As New NetworkCredential("user", "password", "DOMAIN")
    MyLocationService.Credentials = MyCredentials

    Try
        'Get the NearByCategories
        Dim MyFindNearbyCategories As FindNearbyCategory() = MyLocationService.GetNearbyCategories()
        Dim MyFindNearbyCategory As FindNearbyCategory
        For Each MyFindNearbyCategory In MyFindNearbyCategories
            Console.WriteLine(MyFindNearbyCategory.KeyName)
        Next

    Catch MyException As SoapException

        'Your exception processing goes here.
        If ((Not MyException.Detail Is Nothing) And (Not MyException.Detail("Type") Is Nothing)) Then
            MessageBox.Show(MyException.Detail("Type").InnerText)
        End If
    End Try

 
[C#]
  //Create a LocationServiceSoap proxy instance.
  LocationServiceSoap MyLocationService = new LocationServiceSoap();
  //Create and add the credentials required to access the Web service.
  NetworkCredential MyCredentials = new NetworkCredential("user", "password", "DOMAIN");
  MyLocationService.Credentials = MyCredentials;

  //Get the NearByCategories
  try
  {
   FindNearbyCategory[] MyFindNearbyCategories  = MyLocationService.GetNearbyCategories();

   foreach(FindNearbyCategory MyFindNearbyCategory in MyFindNearbyCategories)
   {
    Console.WriteLine(MyFindNearbyCategory.KeyName);
   }
  }
  catch(SoapException MyException)
  {
   //Your exception processing goes here.
   if (MyException.Detail != null && MyException.Detail["Type"] != null)
    MessageBox.Show(MyException.Detail["Type"].InnerText);
  }
  finally
  {
   //Your cleanup goes here
   MyLocationService = null;
  }
 
  
 

See Also

Location Service Class  |  FindNearbyCategory Class  |  UserInfoLocationHeader Class  |  Culture Definition  |  Find Nearby Category Definition  |  Using Soap Headers