ServerAPI.AddNearbyCategory Method

Adds a Find Nearby category to MapPoint Location Server.

Public Sub AddNearbyCategory (category As Microsoft.MapPoint.LocationServer.Types.FindNearbyCategory)

[C#]
public AddNearbyCategory (Microsoft.MapPoint.LocationServer.Types.FindNearbyCategory category);

Parameters

  • category
    Adds an instance of the FindNearbyCategory class. While adding a new category, the following rules must be followed:

    The category KeyName property must not be null, must be unique and less than or equal to the maximum allowed length. For information about the maximum length of the KeyName property, see MapPoint Location Server Parameter Lengths.

    The category DefaultCulture property must not be null, and less than or equal to the maximum allowed length. The maximum allowed length of the DefaultCulture property is defined in the MapPoint Location Server Parameter Lengths document. The DefaultCulture property must follow the standard culture definition.
    Also, there must be a Find Nearby category name matching the default culture.

Remarks

If an attempt is made to add a Find Nearby category that already exists, a FindNearbyCategoryAlreadyExistsException exception is thrown.

Example

 
[Visual Basic]
    'Create a new instance of the ServerAPI class
    Dim MyServerAPI As New ServerAPI
    Try
        'Initialize the database connection for ServerAPI operations
        MyServerAPI.Initialize("Your SQL Server Name", "LocationServerDB")

        'Create a FindNearbyCategory instance
        Dim category As New FindNearbyCategory
        'Set the default culture
        category.DefaultCulture = "en-US"
        'Set the Distance Units
        category.DistanceUnit = DistanceUnit.Mile
        'Set the Key Name
        category.KeyName = "MyDiningPlaces"

        'Set the names for Localization. In this case we have to localized names
        'The following name is for English (US)
        Dim MyFindNearbyCategoryNames(1) As FindNearbyCategoryName
        MyFindNearbyCategoryNames(0) = New FindNearbyCategoryName
        MyFindNearbyCategoryNames(0).Culture = "en-US"
        MyFindNearbyCategoryNames(0).DisplayName = "My Dining Places"
        MyFindNearbyCategoryNames(0).DisplayDescription = "My Dining Places"
        'The following name is for German (Germany)
        MyFindNearbyCategoryNames(1) = New FindNearbyCategoryName
        MyFindNearbyCategoryNames(1).Culture = "de-DE"
        MyFindNearbyCategoryNames(1).DisplayName = "Meine Speisenden Pl?tze"
        MyFindNearbyCategoryNames(1).DisplayDescription = "Meine Speisenden Pl?tze"

        'Assign the localized names to the category instance
        category.Names = MyFindNearbyCategoryNames

        'Create a FindNearbySpecification
        Dim MyFindNearbyCategorySpecification As New FindNearbySpecification
        MyFindNearbyCategorySpecification.DataSourceName = "NavTech.NA"
        MyFindNearbyCategorySpecification.Filter = New FindFilter
        MyFindNearbyCategorySpecification.Filter.EntityTypeName = "SIC3578"
        'Assign the FindNearbySpecification to the category
        category.FindNearbySpecification = MyFindNearbyCategorySpecification

        'Now add the category
        MyServerAPI.AddNearbyCategory(category)

    Catch MyException As Exception
        'Process your exceptions here
        Console.WriteLine(MyException.GetType().Name)

    Finally
        'Do cleanup
        MyServerAPI = Nothing
    End Try

 
[C#]
  //Create a new instance of the ServerAPI class
  ServerAPI MyServerAPI = new ServerAPI();
  try
  {
   //Initialize the database connection for ServerAPI operations
   MyServerAPI.Initialize("Your SQL Server Name", "LocationServerDB");

   //Create a FindNearbyCategory instance
   FindNearbyCategory category = new FindNearbyCategory();
   //Set the default culture
   category.DefaultCulture = "en-US";
   //Set the Distance Units
   category.DistanceUnit = DistanceUnit.Mile;
   //Set the Key Name
   category.KeyName = "MyDiningPlaces";

   //Set the names for Localization. In this case we have to localized names
   //The following name is for English (US)
   FindNearbyCategoryName[] MyFindNearbyCategoryNames = new FindNearbyCategoryName[2];

   MyFindNearbyCategoryNames[0] = new FindNearbyCategoryName();
   MyFindNearbyCategoryNames[0].Culture = "en-US";
   MyFindNearbyCategoryNames[0].DisplayName = "My Dining Places";
   MyFindNearbyCategoryNames[0].DisplayDescription = "My Dining Places";
   //The following name is for German (Germany)
   MyFindNearbyCategoryNames[1] = new FindNearbyCategoryName();
   MyFindNearbyCategoryNames[1].Culture = "de-DE";
   MyFindNearbyCategoryNames[1].DisplayName = "Meine Speisenden Pl?tze";
   MyFindNearbyCategoryNames[1].DisplayDescription = "Meine Speisenden Pl?tze";

   //Assign the localized names to the category instance
   category.Names = MyFindNearbyCategoryNames;

   //Create a FindNearbySpecification
   FindNearbySpecification MyFindNearbyCategorySpecification = new FindNearbySpecification();
   MyFindNearbyCategorySpecification.DataSourceName = "NavTech.NA";
   MyFindNearbyCategorySpecification.Filter = new FindFilter();
   MyFindNearbyCategorySpecification.Filter.EntityTypeName = "SIC3578";
   //Assign the FindNearbySpecification to the category
   category.FindNearbySpecification = MyFindNearbyCategorySpecification;

   //Now add the category
   MyServerAPI.AddNearbyCategory(category);
    
  }
  catch(Exception MyException)
  {
   //Process your exceptions here
   Console.WriteLine(MyException.GetType().Name);
  }
  finally
  {
   //Do cleanup
   MyServerAPI = null;
  }    

  
 

See Also

FindNearbyCategory Class  |  FindNearbyCategoryAlreadyExistsException Class  |  Microsoft.MapPoint.LocationServer.Management  |  ServerAPI Class  |  ServerAPI Members  |  ServerAPIException Class