Common Custom data source


Purpose
This sample demonstrates how to add a custom data source to the Web Application Developer Framework (ADF). The Web ADF provides a generic framework of interfaces and classes—called the Common Data Source application programming interface (API) (the Common API)—which are implemented by all data sources in the Web ADF. The Common API is public, so it can be implemented and extended to support custom data sources. 
 
This sample contains the following projects:
  • TiledMapDataSource—Shows how to work with a custom data source that consists of a set of tiled images. The tiled images are packaged with the sample data in the WorldCache directory. The image cache is available via a public virtual directory (defined in the WorldCache.xml data source configuration file). TileFunctionality implementation generates the client (JavaScript) code necessary to generate a uniform resource locator (URL) to each cache tile. ADF JavaScript logic is used to retrieve tiles without requiring server-side logic.
  • REXMLDataSource—Shows how to create a custom data source that leverages a Web ADF graphics resource to work with feature data. In this sample, the feature data is stored as Extensible Markup Language (XML) formatted text.
  • CustomDataSourceWebApp—Shows how to work with the custom data sources in a Web application.

How to use

Data has been provided for your use with this sample. It can be found at <Your ArcGIS Developer Kit Install directory>/Samples/data/WorldCache.
If the sample has associated data, you will find that the sample's zip file includes a "data" folder alongside the language folders. However, you will need to update the sample to point to the location of the data once you have extracted all the files.

At design time
  1. Verify that the Web ADF for the .NET Framework is installed and functioning properly. For information on installing and configuring the Web ADF, consult the installation guide.
  2. In Windows Explorer, navigate to <ArcGIS install location>\DeveloperKit10.0\Samples\ServerNET. This folder contains the Common_CustomDataSource with CSharp and VBNet folders.
  3. Open the folder of the language you're going to use—CSharp or VBNet—and copy the Common_CustomDataSource_<language> folder to c:\inetpub\wwwroot. The <language> variable can be either CSharp or VBNet.
  4. In Windows Explorer, navigate to c:\inetput\wwwroot\Common_CustomDataSource_<language>. There are multiple application directories in this folder. All projects are available in the Common_CustomDataSource_<language><vs_version>.sln solution. The <vs_version> references the Visual Studio version of the solution, either 2008 or 2010.
  5. Start Microsoft Visual Studio and open the appropriate solution.
  6. Build the tiled map data source project by following the steps in the Working with the TiledMapDataSource_<language> class library project section below.
  7. Build the REXML map data source project by following the steps in the Working with the REXMLDataSource_<language> class library project section below.
  8. Open the Web project to use the custom data sources. See the Working with the CustomDataSourceWebApp_<language> Web project section below for instructions on using the Web project with the custom data sources.
  9. Save the project.
  10. Click the Debug drop-down menu and click Start Debugging.

Working with the TiledMapDataSource_<language> class library project
  1. In the Solution Explorer window, right-click the TiledMapDataSource_<language> folder and select Build. The TiledMapDataSource_<language>.dll is created in the TiledMapDataSource_<language>\bin\Debug or the TiledMapDataSource_<language>\bin\Release folder.
  2. Add the assembly to GAC. This can be done at Visual studio 2008 command prompt. command is : gacutil -i <PATH_TO_THE_DLL>
  3. In Windows Explorer, navigate to the c:\inetput\wwwroot\Common_CustomDataSource_<language>\TiledMapDataSource_<language>\ADFConfigFile folder, and copy the ESRI.ArcGIS.ADF.Web.DataSources.TiledMap_<language>.config file to the <ArcGIS Install>\DotNet directory. When creating a Web ADF application in Visual Studio, the Web ADF reads this config file to determine the type of resources the data source provides. The resource manager controls that work with this resource type include the custom data source in the list of valid data source options. In this sample, the custom data source is a MapResource, so it will be available in the list of data sources for a MapResourceManager.

Working with the REXMLDataSource_<language> class library project
  1. In the Solution Explorer window, right-click the REXMLDataSource_<language> folder and select Build. The REXMLDataSource_<language>.dll is created in the REXMLDataSource_<language>\bin\Debug or the REXMLDataSource_<language>\bin\Release folder.
  2. Add the assembly to GAC. This can be done at Visual studio 2008 command prompt. command is : gacutil -i <PATH_TO_THE_DLL>
  3. In Windows Explorer, navigate to the c:\inetput\wwwroot\Common_CustomDataSource_<language>\REXMLDataSource_<language>\ADFConfigFile folder, and copy the ESRI.ArcGIS.ADF.Web.DataSources.REXML_<language>.config file to the <ArcGIS Install>\DotNet directory. This custom data source is a MapResource, so it will be available in the list of data sources for a MapResourceManager.

Working with the CustomDataSourceWebApp_<language> Web project
  1. Add the TiledMapDataSource_<language> and REXMLDataSource_<language> projects as references to the Web project.
  2. In the Solution Explorer window, expand the CustomDataSourceWebApp_<language> Web project, and open the Default_TileMapData.aspx page in Design view.
  3. Activate the MapResourceManager control and open the MapResourceItem collection editor. Three resource items have been added: ADF GraphicsLayer, Other DataSource, and Custom TiledMap DataSource.
  4. Open the Custom TiledMap DataSource resource item definition, and confirm that the data source type is set to TiledMap <language> and that the data source definition points to: C:/Inetpub/wwwroot/Common_CustomDataSource_<language>/CustomDataSource_<language>/TiledMapDataSource_<language>/DataSourceDefinitions/WorldCache.xml. The WorldCache.xml file contains layer information for the cache data included with this sample, such as the public virtual directory, spatial reference, full extent, and scale levels.
  5. Open the Other DataSource resource definition, set it to a valid map service (ArcGIS Server, ArcIMS and so forth), and change the background color of the resource to be transparent. For additional information, see the MapResourceManager control help.
  6. The ADF GraphicsLayer resource is used to draw graphic points—defined in a comma delimited text file—on top of the other map resources. This is not related to the custom tiled data source and merely provides an example of how to upload client data and display it in a Web ADF map.
  7. In the Solution Explorer window, under the CustomDataSourceWebApp_<language> Web project, open the Default_REXMLData.aspx page in Design view.
  8. Activate the MapResourceManager control and open the MapResourceItem collection editor. Two resource items have been added: REXML Resource and Other Map Resource.
  9. Open the REXML Resource item definition, and confirm that the data source type is set to REXML Data <language> and that the data source definition points to C:/Inetpub/wwwroot/Common_CustomDataSource_<language>/CustomDataSource_<language>/REXMLDataSource_<language>/DataSourceDefinitions/rexml_point_wgs84.xml. The rexml_point_wgs84.xml file contains feature geometry and renderer information in XML format. The feature geometry consists of three points in the WGS84 coordinate system. The points are located in the Western U.S.
  10. Open the Other Map Resource resource definition and set it to a valid map service (ArcGIS Server, ArcIMS and so forth) that contains map data in WGS84 in the Western U.S. For additional information, see the MapResourceManager control help.

At run time
  1. Browse to the Tiled Map Web page (for example, http://localhost/Common_CustomDataSource_CSharp/CustomDataSourceWebApp_CSharp/Default_TileMapData.aspx). A map containing cached map tiles is displayed. If another resource has been added on top of the cached resource, set its background to transparent (see the At design time section for instructions).
  2. Use the navigation tools to pan and zoom the map.
  3. To upload custom data points to the Web application, click the Browse button and navigate to a text file provided in C:\Inetpub\wwwroot\Common_CustomDataSource_<language>\CustomDataSourceWebApp_<language>\userdata\coords_wgs84.txt.
  4. Select the file and click OK.
  5. Select the color and symbol type to use when rendering the points.
  6. Click the Upload button. Four points are rendered on the map near the Western U.S.
  7. Browse to the REXML Web page (for example, http://localhost/Common_CustomDataSource_CSharp/CustomDataSourceWebApp_CSharp/Default_REXMLData.aspx). The custom REXML data source is displayed in the map as three points, rendered as green stars in the Western U.S.

Common_CustomDataSource_CSharp\REXMLDataSource_CSharp\REXMLDataSource_CSharp.csproj REXMLDataSource project file.
Common_CustomDataSource_CSharp\REXMLDataSource_CSharp\GISDataSource.cs REXMLDataSource implementation of IGISDataSource.
Common_CustomDataSource_CSharp\REXMLDataSource_CSharp\MapFunctionality.cs REXMLDataSource implementation of IMapFunctionality.
Common_CustomDataSource_CSharp\REXMLDataSource_CSharp\QueryFunctionality.cs REXMLDataSource implementation of IQueryFunctionality.
Common_CustomDataSource_CSharp\REXMLDataSource_CSharp\MapInformation.cs REXMLDataSource extends MapInformation.
Common_CustomDataSource_CSharp\REXMLDataSource_CSharp\MapResource.cs REXMLDataSource implementation of IMapResource.
Common_CustomDataSource_CSharp\REXMLDataSource_CSharp\MapTocFunctionality.cs REXMLDataSource implementation of IMapTocFunctionality.
Common_CustomDataSource_CSharp\REXMLDataSource_CSharp\Design\DataSourceDefinitionEditorFormREXML.cs Design-time form for navigating to a REXML file on disk.
Common_CustomDataSource_CSharp\REXMLDataSource_CSharp\ADFConfigFile\ESRI.ArcGIS.ADF.Web.DataSources.REXMLData_CSharp.config Custom REXML data source configuration.
Common_CustomDataSource_CSharp\REXMLDataSource_CSharp\DataSourceDefinitions\rexml_point_mercator.xml Custom REXML data in the World_Mercator coordinate system.
Common_CustomDataSource_CSharp\REXMLDataSource_CSharp\DataSourceDefinitions\rexml_point_wgs84.xml Custom REXML data in the WGS84 coordinate system.
Common_CustomDataSource_CSharp\TiledMapDataSource_CSharp\TiledMapDataSource_CSharp.csproj TiledMapDataSource project file.
Common_CustomDataSource_CSharp\TiledMapDataSource_CSharp\GISDataSource.cs TiledMapDataSource implementation of IGISDataSource.
Common_CustomDataSource_CSharp\TiledMapDataSource_CSharp\MapFunctionality.cs TiledMapDataSource implementation of IMapFunctionality.
Common_CustomDataSource_CSharp\TiledMapDataSource_CSharp\MapInformation.cs TiledMapDataSource extends MapInformation.
Common_CustomDataSource_CSharp\TiledMapDataSource_CSharp\MapResource.cs TiledMapDataSource implementation of IMapResource.
Common_CustomDataSource_CSharp\TiledMapDataSource_CSharp\MapTocFunctionality.cs TiledMapDataSource implementation of IMapTocFunctionality.
Common_CustomDataSource_CSharp\TiledMapDataSource_CSharp\TileCacheInfo.cs TiledMapDataSource extends TileCacheInfo.
Common_CustomDataSource_CSharp\TiledMapDataSource_CSharp\TileAccessInfo.cs Used to store cache tile access properties.
Common_CustomDataSource_CSharp\TiledMapDataSource_CSharp\TileAccessMethod.cs Enumeration defining how cached tiles can be accessed.
Common_CustomDataSource_CSharp\TiledMapDataSource_CSharp\TileFunctionality.cs TiledMapDataSource implementation of ITileFunctionality.
Common_CustomDataSource_CSharp\TiledMapDataSource_CSharp\Design\DataSourceDefinitionEditorFormTiledMap.cs Design-time form for navigating to a tile information file on disk.
Common_CustomDataSource_CSharp\TiledMapDataSource_CSharp\ADFConfigFile\ESRI.ArcGIS.ADF.Web.DataSources.TiledMap_CSharp.config Custom Tiled Map data source configuration.
Common_CustomDataSource_CSharp\CustomDataSourceWebApp_CSharp\Default_REXMLData.aspx Web page that contains Web ADF controls that consume the custom REXML data source.
Common_CustomDataSource_CSharp\CustomDataSourceWebApp_CSharp\Default_REXMLData.aspx.cs Code file for Web page that contains the REXML data source.
Common_CustomDataSource_CSharp\CustomDataSourceWebApp_CSharp\Default_TileMapData.aspx Web page that contains Web ADF controls that consume the custom Tiled Map data source.
Common_CustomDataSource_CSharp\CustomDataSourceWebApp_CSharp\Default_TileMapData.aspx.cs Code file for Web page that contains the Tiled Map data source.
Download the C# files
Common_CustomDataSource_VBNet\REXMLDataSource_VBNet\REXMLDataSource_VBNet.vbproj REXMLDataSource project file.
Common_CustomDataSource_VBNet\REXMLDataSource_VBNet\GISDataSource.vb REXMLDataSource implementation of IGISDataSource.
Common_CustomDataSource_VBNet\REXMLDataSource_VBNet\MapFunctionality.vb REXMLDataSource implementation of IMapFunctionality.
Common_CustomDataSource_VBNet\REXMLDataSource_VBNet\QueryFunctionality.vb REXMLDataSource implementation of IQueryFunctionality.
Common_CustomDataSource_VBNet\REXMLDataSource_VBNet\MapInformation.vb REXMLDataSource extends MapInformation.
Common_CustomDataSource_VBNet\REXMLDataSource_VBNet\MapResource.vb REXMLDataSource implementation of IMapResource.
Common_CustomDataSource_VBNet\REXMLDataSource_VBNet\MapTocFunctionality.vb REXMLDataSource implementation of IMapTocFunctionality.
Common_CustomDataSource_VBNet\REXMLDataSource_VBNet\ADFConfigFile\ESRI.ArcGIS.ADF.Web.DataSources.REXMLData_VBNet.config Custom REXML data source configuration.
Common_CustomDataSource_VBNet\REXMLDataSource_VBNet\DataSourceDefinitions\rexml_point_mercator.xml Custom REXML data in the World_Mercator coordinate system.
Common_CustomDataSource_VBNet\REXMLDataSource_VBNet\DataSourceDefinitions\rexml_point_wgs84.xml Custom REXML data in the WGS84 coordinate system.
Common_CustomDataSource_VBNet\TiledMapDataSource_VBNet\TiledMapDataSource_VBNet.vbproj TiledMapDataSource project file.
Common_CustomDataSource_VBNet\TiledMapDataSource_VBNet\GISDataSource.vb TiledMapDataSource implementation of IGISDataSource.
Common_CustomDataSource_VBNet\TiledMapDataSource_VBNet\MapFunctionality.vb TiledMapDataSource implementation of IMapFunctionality.
Common_CustomDataSource_VBNet\TiledMapDataSource_VBNet\MapInformation.vb TiledMapDataSource extends MapInformation.
Common_CustomDataSource_VBNet\TiledMapDataSource_VBNet\MapResource.vb TiledMapDataSource implementation of IMapResource.
Common_CustomDataSource_VBNet\TiledMapDataSource_VBNet\MapTocFunctionality.vb TiledMapDataSource implementation of IMapTocFunctionality.
Common_CustomDataSource_VBNet\TiledMapDataSource_VBNet\TileCacheInfo.vb TiledMapDataSource extends TileCacheInfo.
Common_CustomDataSource_VBNet\TiledMapDataSource_VBNet\TileAccessInfo.vb Used to store cache tile access properties.
Common_CustomDataSource_VBNet\TiledMapDataSource_VBNet\TileAccessMethod.vb Enumeration defining how cached tiles can be accessed.
Common_CustomDataSource_VBNet\TiledMapDataSource_VBNet\TileFunctionality.vb TiledMapDataSource implementation of ITileFunctionality.
Common_CustomDataSource_VBNet\TiledMapDataSource_VBNet\ADFConfigFile\ESRI.ArcGIS.ADF.Web.DataSources.TiledMap_VBNet.config Custom Tiled Map data source configuration.
Common_CustomDataSource_VBNet\CustomDataSourceWebApp_VBNet\Default_REXMLData.aspx Web page that contains Web ADF controls that consume the custom REXML data source.
Common_CustomDataSource_VBNet\CustomDataSourceWebApp_VBNet\Default_REXMLData.aspx.vb Code file for Web page that contains the REXML data source.
Common_CustomDataSource_VBNet\CustomDataSourceWebApp_VBNet\Default_TileMapData.aspx Web page that contains Web ADF controls that consume the custom Tiled Map data source.
Common_CustomDataSource_VBNet\CustomDataSourceWebApp_VBNet\Default_TileMapData.aspx.vb Code file for Web page that contains the Tiled Map data source.
Download the VB.NET files

Download the files for all languages