WorldMap Template


 

Overview

The WorldMap template allows you to incorporate a world map into your ASP.NET application. The template uses freely available public domain data from VMAP0 and Natural Earth Data. The template uses map caching and requires only a few lines of code. It  has the following structure:

 

/App_Code/WorldMap.cs - the C# source code of the template

/App_Code/WorldMap.vb - the VB source code of the template (WorldMap.zip)

/App_Data/WorldMap - the map data directory
/TileCache - the tile cache directory

 

Downloading the Template

A sample project that demonstrates the template is available at:

 

http://www.vdsgeo.com/download/WorldMapTemplate.zip

 

The project includes the template code and map data. To run the project, add a reference to the AspMap assemblies (or copy the AspMap assemblies into the Bin folder of the project).

Incorporating the Template into Your Project
  1. Copy the WorldMap.cs file to the /App_Code directory of your ASP.NET application.

  2. Copy the WorldMap directory to the /App_Data directory of your application.

  3. Create a /TileCache directory at the root directory of your application. If you run your application under IIS, grant the IUSR account read/write/modify permissions for the /TileCache directory to let AspMap manage the tile images in the directory.

  4. Add a Map control into your ASP.NET project as described in the AspMap documentation.

  5. Add the following code to the Page_Load method (see the Default.aspx.cs file of the sample project): 

 

[C#]
protected void Page_Load(object sender, EventArgs e)
{
        Map1.MapUnit = MeasureUnit.Degree;
        Map1.BackColor = Color.FromArgb(165, 191, 221);
        Map1.ImageOpacity = 0.5;
        Map1.ImageFormat = ImageFormat.Png;

        Map1.ZoomLevels.Add(220000000);
        Map1.ZoomLevels.Add(110000000);
        Map1.ZoomLevels.Add(55000000);
        Map1.ZoomLevels.Add(27500000);
        Map1.ZoomLevels.Add(13750000);
        Map1.ZoomLevels.Add(6875000);
        Map1.ZoomLevels.Add(3437500);
        Map1.ZoomLevels.Add(1718750);
        Map1.ZoomLevels.Add(859375);
     
        WorldMap worldMap = new WorldMap("~/TileCache", 1000);

        AspMap.Web.TileLayer tileLayer = worldMap.CreateTileLayer(Map1);

        if (tileLayer != null)
        {
            Map1.AddLayer(tileLayer);
        }
}

[VB.NET]
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
        Map1.MapUnit = MeasureUnit.Degree
        Map1.BackColor = Color.FromArgb(165, 191, 221)
        Map1.ImageOpacity = 0.5
        Map1.ImageFormat = ImageFormat.Png

        Map1.ZoomLevels.Add(220000000)
        Map1.ZoomLevels.Add(110000000)
        Map1.ZoomLevels.Add(55000000)
        Map1.ZoomLevels.Add(27500000)
        Map1.ZoomLevels.Add(13750000)
        Map1.ZoomLevels.Add(6875000)
        Map1.ZoomLevels.Add(3437500)
        Map1.ZoomLevels.Add(1718750)
        Map1.ZoomLevels.Add(859375)

        Dim worldMap As WorldMap = New WorldMap("~/TileCache", 1000)

        Dim tileLayer As AspMap.Web.TileLayer = worldMap.CreateTileLayer(Map1)

        If tileLayer IsNot Nothing Then
                Map1.AddLayer(tileLayer)
        End If
End Sub
© 2018 VDS Technologies
Converted from CHM to HTML with chm2web Standard 2.85 (unicode)