Register  |  Login
ThinkGeo - GPS Tracking and Mapping Solutions  |  Home  |  Cygnus Track  |   Code Community

Discussion Forums

The online community for users of Map Suite GIS components

RSS Feed Available AddThis - Bookmarking and Sharing Button Printer Friendly

PrevPrev NextNext

Map Suite Web Edition 4.0 QuickStart Guide

Posted by ThinkGeo on 11-18-2008 12:48 PM

The Map Suite Web Edition illustrated QuickStart Guide will guide you through the process of creating a sample application and will help you become familiar with Map Suite. This edition of the QuickStart Guide supports Web Edition 4.0.0.0 and higher.

Download Sample Code From This Exercise

Welcome to Map Suite™ Web Edition from ThinkGeo, a full-featured mapping control that makes it easy for any Microsoft .NET developer to add mapping functionality to a Microsoft .NET application quickly and efficiently. Using the intuitive object model, even developers inexperienced in Geographic Information Systems (GIS) can have fully functional maps working in minutes.

The purpose of this guide is to help you quickly get started building your own spatially aware applications. Like any new software, there is some learning to be done along the way.

How do we start to learn how to take advantage of the power of Map Suite? The best way is to make a sample application with it.

(For the purposes of this guide, let's assume we have installed the Map Suite Web Edition 4.0 to the default folder "C:\Program Files\ThinkGeo\Map Suite Web Full Edition 4.0\")

Setting up the Environment

Let's start with a new ASP.NET Web Site in Visual Studio.NET 2008 IDE and call it "HelloWorld" (see Figure 1). Set the Templates to ".NET Framework 3.5" for the project.

(If you are using Visual Studio.NET 2005, you need to install both VS2005 SP1 and Ajax Extension 1.0 for ASP.NET 2.0, and then create an ASP.NET AjaxEnabled Web Application.)

Screenshot

Screenshot

Figure 1. Creating a new project in Visual Studio.NET 2008 IDE.

The website is created in a new solution called "HelloWorld". The wizard creates several files including a Web form called Default.aspx.

Adding the Map Control to the Visual Studio.NET IDE Toolbox

1. When you first open the Visual Studio.NET IDE after installing Map Suite, you may not see the control in the Toolbox. You will need to follow these steps to add the control.

Hover over the Toolbox and right click anywhere on the list of controls. You will get a pop-up menu. Select "Choose Items..."

Screenshot

2. The Choose Toolbox Items dialogue will appear. You will need to select the ".NET Framework Components" tab and then click the "Browse..." button. Finally, navigate to the "C:\Program Files\ThinkGeo\Map Suite Web Full Edition 4.0\Developer Reference\Web Edition" folder and select the WebEdition.dll.

Screenshot

3. You should now have the Map Control available in your Toolbox as shown in Figure 2 below.

Screenshot

Figure 2. The Map Control in the Toolbox window.

Adding the Map Control to your Web Form

We need to add MapSuiteCore.dll to the reference. Right-click the project in Solution Explorer and select "Add Reference...", navigate to the "C:\Program Files\ThinkGeo\Map Suite Web Full Edition 4.0\Developer Reference\Web Edition" folder and select MapSuiteCore.dll.

Screenshot

Draw the Map control on the web form by clicking on the Map Control object in the Toolbox and then dragging and dropping (using the left mouse button) to the size you desire. You can leave the name of the Map control set to Map1. This is the control that our map will display in.

Please note: If you are using Visual Studio.NET 2005, you need to remove the default ScriptManager first.

Screenshot

Now that we have MapSuiteCore.dll referenced and a Map Control added. We are ready for adding the code.

Map Suite Web "Hello World" Sample

After this section, you will be able to draw a map with Map Suite Web Edition using your own data. At the very beginning, let's have a look at the data and the important objects we will use.

Shapefiles

Map Suite Web Edition 4.0 supports multiple kinds of data sources, such as SQL Server 2008, Postgre, Oracle, etc. Here we will provide an introduction to Shapefiles which we will use in this Quick Start Guide.

Simply put, Shapefiles are used by Map Suite to provide data that we will use to draw our map. Shapefiles store binary vector coordinates to be used by the component. They have a .shp extension. Shapefiles also come with two supplementary files that help Map Suite to work with the data.

The first supplementary file is called the .shx file. Its purpose is to provide a simple index of the main Shapefile. It tells the Map Suite component when to start reading binary data and when to stop. It is much like a directory for reading the binary data, sort of a lookup mechanism.

The second supplementary file is the .dbf file. This file holds tabular data associated with the main Shapefile. For example, the Shapefile may have the coordinates for a line to be drawn that represents a road. The .dbf file may have information to tell you what the name of the road is or what type of road it is, such as county road, state road, interstate highway, etc.

All three files need to reside in the same directory as the main Shapefile (.shp), but the Map Suite component only expects you to designate the name and file path of the main Shapefile. Next, when we discuss layer, you will start understanding a little more about how maps are constructed in Map Suite using the shape data.

ShapeFileFeatureLayers

A ShapeFileFeatureLayer in a map correlates to a single Shapefile, such as networks of roads. You can think of layers much like actual terrain in the real world. The bare earth might be a layer and has either physically defined boundaries, such as a fence around a military installation, or legal boundaries, such as the border of a country. Another layer on top of that might be roads that are built upon the bare earth. It is important to understand this when working with layers, as they need to be added in the logical order you might expect so that they can be visualized correctly from above. In other words, you would not want to lay down roads and then cover them with earth, because they could not be seen or used by vehicles.

How do we create and add layers? First, you should know that there are three types of styles that layers represent. As mentioned above, it follows logically that you would create and add layers based on how they should be viewed, so naturally you might start with some polygons, such as the outline of a country and all of the regions within it. You might then lay down lines that represent rivers and roads and then finally you might lay down points like cities or places of interest. Again, keep in mind that logic will dictate what works best. For instance, laying down roads and then rivers would put rivers on top of roads when it should more than likely be the other way around (the exception here might be a tunnel!).

Map

A Map object is the highest level object that encompasses layers and some other objects. For now, you can think of a Map as a set of layers, which can render each layer and present you with a map based on actions performed, such as moving in and out, or panning across the surface to view another part of the map.

Styles

Shapefiles provide the data, but Styles are the way you color and draw them. You can specify the color of the country, the width of a road, the shape (triangle, circle, cross etc) of a point, and so on.

Map Suite has many preset Styles built in, including predefined Styles for roads, rivers, cities, countries, and more. This makes it easier to create great looking maps without a lot of hassle.

PresetZoomLevels

Styles define the way we visually represent the data, while ZoomLevels define the situation in which we want to display them. The reason why we need ZoomLevels is because we may want to display a small town when we are zoomed into a state, but we definitely don't want to display that town when we are zoomed out and looking at the entire country.

We have provided the 20 most common scales, from ZoomLevel01 to ZoomLevel20, at which you may want to change the way your data looks. What is scale? Scale indicates how much the given area has been reduced. If a road is 10,000 inches long in the real world and a map depicts this length as 1 inch on the screen, then we say the scale of this map is 1:10,000. Now let's say ZoomLevel02 uses a scale of 1:500 and ZoomLevel03 uses a scale of 1:1200. This means the map with a current scale of 1:1000 matches ZoomLevel03, the ZoomLevel whose scale is the closest to that.

PresetZoomLevels has a very useful property called "ZoomLevel.ApplyUntilZoomLevel", which you can very easily use to extend your ZoomLevels. Let's say you want a particular Style to be visible at ZoomLevel03 through ZoomLevel10. To make that work, we can simply code as follows:

worldLayer.ZoomLevelSet.ZoomLevel03.DefaultAreaStyle = AreaStyles.Country1;
worldLayer.ZoomLevelSet.ZoomLevel03.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level10;

Map Suite Web "Hello World"

In creating our "Hello World" sample application, our first step is to set a reference to the Map Suite Core workspace at the very top of our code, as we will use many classes within that. We do this so that we do not have to use the fully qualified name of the Map Suite classes throughout our code. Setting a reference to the Map Suite workspace can be done in the "code-behind" of the Form by selecting the Form and hitting the F7 function key. Set the reference like this:

using ThinkGeo.MapSuite.Core;

Now let's look at a code sample to bring this concept to fruition. We'll look at Shapefiles relating to the entire world. In our example, we have one such Shapefile:

  • The borders of every country in the world (cntry02.shp)

(NOTE: The data used in this sample can be found in the installation folder under Samples\CSharp Samples\SampleData\World. Figure 3 shows that folder.)

Screenshot

Figure 3. The data used in this sample.

Our next step is to define and add our layers. All of our sample code is placed in the Page_Load event of the web form. We also will want to put in a check for whether the page is posting back. This is so our Map control can load and render the data only once, during initial load, instead of repeatedly every time a post back to the web server is made. For the sample application we are making here, this check is not actually needed, as there will not be any PostBack in this application. Still, this is a good coding habit for a Web project, so let's put in the code to check for post backs in first. Then, we'll put our other code inside that structure.


protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            // Set the Map Unit. The reason for setting it to DecimalDegrees is that is what the shapefile's unit of measure is inherently in.
            Map1.MapUnit = GeographyUnit.DecimalDegree;

            // We create a new Layer and pass the path to a Shapefile into its constructor.
            ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(@"C:\Program Files\ThinkGeo\Map Suite Web Full Edition 4.0\Samples\CSharp Samples\SampleData\World\cntry02.shp");
            
            // Set the worldLayer with a preset Style, as AreaStyles.Country1 has YellowGreen background and black border, our worldLayer will have the same render style. 
            worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1;
            
            // This setting will apply from ZoonLevel01 to ZoomLevel20, that means we can see the world the same style with ZoomLevel01 all the time no matter how far we zoom out/in.
            worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            
            // We need to add the world layer to map's Static Overlay.
            Map1.StaticOverlay.Layers.Add(worldLayer);
            
            // Set a proper extent for the map, that's the place you want it to display.
            Map1.CurrentExtent = new RectangleShape(5, 78, 30, 26);
        }
    }

If you compile and run what you have now, your map should look like the one below. (See Figure 4).

Screenshot

Figure 4. A simple map of Europe.

So what has occurred here? We have created a layer and added it to the Map, and the Map has rendered it according to its default style parameters. Also, we have used ZoomLevel to display the map the way we want.

NOTE: It is important that the MapUnit property of a Map object be set using the GeographyUnit Enumeration. This is because Shapefiles only store binary vector coordinates, which can be in DecimalDegree, feet, meters, etc., and our map has no idea about what the unit of measurement is until we set it. This information is normally found somewhere in the documentation or within the supplemental data file as discussed in the section on Shapefiles.

Navigate the Map

With the above code, not only can you display a map, but you can also navigate it. You can pan by dragging the map, zoom in by double-clicking, track zoom in by drawing a rectangle with your left mouse button mouse while holding the shift key, or zoom in and out by using the mouse wheel. Very powerful for just couple lines of code, isn't it?

That was an easy start! Now, let's add another Shapefile to the sample so that we will have a total of two layers:

  1. The borders of every country in the world (cntry02.shp)
  2. The capitals of the world countries (capital.shp)

protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
             Map1.MapUnit = GeographyUnit.DecimalDegree;
            
             ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(@"C:\Program Files\ThinkGeo\Map Suite Web Full Edition 4.0\Samples\CSharp Samples\SampleData\World\cntry02.shp");
             worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1;
             worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            
             ShapeFileFeatureLayer capitalLayer = new ShapeFileFeatureLayer(@"C:\Program Files\ThinkGeo\Map Suite Web Full Edition 4.0\Samples\CSharp Samples\SampleData\World\capital.shp");
             // Similarly, we use the presetPointStyle for cities.
             capitalLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.Capital3;
             // These settings will apply from ZoonLevel01 to ZoomLevel20, that means we can see city symbols the same style with ZoomLevel01 all the time no matter how far we zoom out/in.
             capitalLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            
             // We need to add both of the new layers to the Map's Static Overlay.
             Map1.StaticOverlay.Layers.Add(worldLayer);
             Map1.StaticOverlay.Layers.Add(capitalLayer);
            
             Map1.CurrentExtent = new RectangleShape(5, 78, 30, 26);
        }
    }

The result is as follows(Figure 5):

Screenshot

Figure 5. Europe map with 2 layers.

How to Use the TextStyle

TextStyle

The TextStyle is used to label items on map. As every Shapefile has a related .dbf file, which includes descriptions for every record, the most common way to use the TextStyle is for labeling. For example, the Shapefile containing capitals of the world has a corresponding .dbf file that contains the field "CITY_NAME". We can use this field to label the cities on our map.

Screenshot

Map Suite has many TextStyles built in, which will help us quickly design attractive labels for the cities on our map. We can just pick the TextStyle we like and use it.


protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Map1.MapUnit = GeographyUnit.DecimalDegree;
            
            ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(@"C:\Program Files\ThinkGeo\Map Suite Web Full Edition 4.0\Samples\CSharp Samples\SampleData\World\cntry02.shp");
            worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1;
            worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            
            ShapeFileFeatureLayer capitalLayer = new ShapeFileFeatureLayer(@"C:\Program Files\ThinkGeo\Map Suite Web Full Edition 4.0\Samples\CSharp Samples\SampleData\World\capital.shp");
            capitalLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.Capital3;
            capitalLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            
            // We create a new Layer for labeling the capitals.
            ShapeFileFeatureLayer capitalLabelLayer = new ShapeFileFeatureLayer(@"C:\Program Files\ThinkGeo\Map Suite Web Full Edition 4.0\Samples\CSharp Samples\SampleData\World\capital.shp");
            // We use the preset TextStyle. Here we passed in the “CITY_NAME”, which is the name of the field we want to label on map.
            capitalLabelLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.Capital3("CITY_NAME");
            capitalLabelLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            // As the map is drawn by tiles, it needs to draw on the margin to make sure the text is complete after we joining the tiles together.
            // Change the number to another one (for example 0) and you can see the difference.
            capitalLabelLayer.DrawingMarginPercentage = 50;
            
            Map1.StaticOverlay.Layers.Add(worldLayer);
            Map1.StaticOverlay.Layers.Add(capitalLayer);
            // Add the label layer to Map.
            Map1.StaticOverlay.Layers.Add(capitalLabelLayer);
            
            Map1.CurrentExtent = new RectangleShape(5, 78, 30, 26);
            
            // Set the background color to make the map beautiful.
            Map1.MapBackground.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean);
        }
    }

The result is as follows (Figure 6):

Screenshot

Figure 6. Europe map with TextStyle.

Now that we know how to render text and render symbols, let's define two different ZoomLevels in one single layer, and create our own custom Style and TextStyle.


protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Map1.MapUnit = GeographyUnit.DecimalDegree;
            
            ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(@"C:\Program Files\ThinkGeo\Map Suite Web Full Edition 4.0\Samples\CSharp Samples\SampleData\World\cntry02.shp");
            worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1;
            worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            
            ShapeFileFeatureLayer capitalLayer = new ShapeFileFeatureLayer(@"C:\Program Files\ThinkGeo\Map Suite Web Full Edition 4.0\Samples\CSharp Samples\SampleData\World\capital.shp");
            // We can customize our own Style. Here we passed in a color and a size.
            capitalLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.CreateSimpleCircleStyle(GeoColor.StandardColors.White, 7, GeoColor.StandardColors.Brown);
            // The Style we set here is available from ZoomLevel01 to ZoomLevel05. That means if we zoom in a bit more, the appearance we set here will not be visible anymore.
            capitalLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level05;
            
            capitalLayer.ZoomLevelSet.ZoomLevel06.DefaultPointStyle = PointStyles.Capital3;
            // The Style we set here is available from ZoomLevel06 to ZoomLevel20. That means if we zoom out a bit more, the appearance we set here will not be visible any more.
            capitalLayer.ZoomLevelSet.ZoomLevel06.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            
            ShapeFileFeatureLayer capitalLabelLayer = new ShapeFileFeatureLayer(@"C:\Program Files\ThinkGeo\Map Suite Web Full Edition 4.0\Samples\CSharp Samples\SampleData\World\capital.shp");
            // We can customize our own TextStyle. Here we passed in the font, the size, the style and the color.
            capitalLabelLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.CreateSimpleTextStyle("CITY_NAME", "Arial", 8, DrawingFontStyles.Italic, GeoColor.StandardColors.Black, 3, 3);
            // The TextStyle we set here is available from ZoomLevel01 to ZoomLevel05. 
            capitalLabelLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level05;
            
            capitalLabelLayer.ZoomLevelSet.ZoomLevel06.DefaultTextStyle = TextStyles.Capital3("CITY_NAME");
            // The TextStyle we set here is available from ZoomLevel06 to ZoomLevel20. 
            capitalLabelLayer.ZoomLevelSet.ZoomLevel06.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            
            capitalLabelLayer.DrawingMarginPercentage = 50;
            
            Map1.StaticOverlay.Layers.Add(worldLayer);
            Map1.StaticOverlay.Layers.Add(capitalLayer);
            Map1.StaticOverlay.Layers.Add(capitalLabelLayer);
            
            Map1.CurrentExtent = new RectangleShape(5, 78, 30, 26);
            
            // Set the background color to make the map beautiful.
            Map1.MapBackground.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean);
        }
    }

Can you imagine what the map will look like now? Figure 7 below is the result. At first it looks the same as it did in Figure 6. Now zoom in, and watch the map change to resemble Figure 8 as you do.

Screenshot

Figure 7. European cities with two ZoomLevels, before zooming in.

Screenshot

Figure 8. European cities with two ZoomLevels, after zooming in.

Using the Map in an Update Panel

If you put the map within an update panel, you can take advantage of AJAX. To make this clearer, we will walk you through a sample.

First, let's add a marker on the map. Our first step is to add a reference to the Map Suite WebEdition namespace at the very top of our code:

using ThinkGeo.MapSuite.WebEdition;

Next, drag a button to the page and leave the name set to the default "Button1". Double-click that button and write the following code in the Button1_Click method:


protected void Button1_Click(object sender, EventArgs e)
    {
        if (!Map1.MarkerOverlay.Features.Contains("Marker"))
        {
            // Add a new feature as a marker
            Map1.MarkerOverlay.Features.Add("Marker", new Feature(0, 52));

            // Set the marker style, and make it available all over the zoomlevels.
            Map1.MarkerOverlay.ZoomLevelSet.ZoomLevel01.DefaultMarkerStyle.WebImage = new WebImage("../../theme/default/img/marker_blue.gif", 21, 25);
            Map1.MarkerOverlay.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
        }
    }

Let's run the application and click the button. You will see a marker appear near London. (Figure 9)

Screenshot

Figure 9. Add a marker to the map.

We have now added a marker to the map; however, you will find that the map flickers every time you click the button.

The following code in Default.aspx shows how we can put the map control and the button within an update panel to solve the flickering problem. You can also put the button outside the update panel; see the following sets of example code for details:

Aspx code 1: Put both the map control and button into the update panel.

<body>
    <form> id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <cc1:Map ID="Map1" runat="server" Height="600px" Width="800px">
            </cc1:Map>
            <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
        </ContentTemplate>
    </asp:UpdatePanel>
    </form>
</body>

Aspx code 2: Put only map in an update panel.

<body>
    <form> id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
            <cc1:Map ID="Map1" runat="server" Height="600px" Width="800px">
            </cc1:Map>
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
        </Triggers>
    </asp:UpdatePanel>
    <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
    </form>
</body>

Summary

You now know the basics of using Map Suite Web Edition and are able to start adding this functionality into your own applications. Let's recap what we have learned about the object relationships and how the pieces of Map Suite work together:

  1. It is of the utmost importance that the units of measurement (feet, meters, decimal degrees, etc.) be set properly for the map, based on the requirements of your data.
  2. Shapefiles (and other data sources like Oracle, Postgre, SQL 2008, etc.) provide the data used by Map Suite to render a map.
  3. A Map is the basic class that contains all of the other objects that are used to define how the map will be rendered.
  4. A Map has one-to-many Layers. A Layer contains the data (from shapefile or other data sources) for drawing.
  5. A layer can have one-to-many ZoomLevels. ZoomLevels help to define ranges of when a layer should be shown or hidden.

If you have questions about anything covered in this QuickStart Guide, the ThinkGeo Support Team is ready and available to help. If we can be of any assistance, please contact us using one of the methods below:

Free Discussion Forums: ThinkGeo Discussion Forums
Pre-Sales & Customer Support: ThinkGeo Customer Portal
Support Phone: 1-866-847-7510
1-785-727-4133 (Outside North America)
Web Site: http://thinkgeo.com

Download Sample Code From This Exercise



20 Comments

theoUser is Offline
01-28-2010 03:30 AM
Avatar
I tried on Visual Studio 2005 and Map Suite Evalution 3.0, yet nothing shows up when I start without debugging.


JohnnyUser is Offline
01-29-2010 01:22 AM
Avatar
Theo,

We created a sample following the quick start description on VS 2005 and all works fine, i'm wondering that maybe something wrong with shapefile path setting like code below:

// We create a new Layer and pass the path to a Shapefile into its constructor.
ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(@"C:\Program Files\ThinkGeo\Map Suite Web Full Edition 3.0\Samples\CSharp Samples\SampleData\World\cntry02.shp");

One thing should be noted that the WebEdition is based on ScriptManager, please make sure you installed asp.net ajax extension on VS2005.

Thanks,

Johnny,



AlUser is Offline
03-05-2010 07:37 PM
Avatar
When I add the Capitals layer The map displays "The record is invalid, please validate method to check the failed reason, Record index: 42" there is also a similar message for indexes 1, 4, 3, 19, 12.

When I click on the button to test the Ajax update the map is erased. I am using VS 2005 and have installed asp.net ajax extensions VS 2005.

The error is not a typo of some kind, as I have copied and pasted the code above, to make sure. (Except for the paths to the shape files, which are slightly different.)

To test the Ajax update I comment out the line that adds the Capitals to the Static Overlay.


KhalilUser is Offline
03-07-2010 10:07 PM
Avatar
Hi, Al

Maybe there is some problem about your shape file data. Please try to use the data in our installed samples. And also you could refer to the DrawFeaturesBasedOnValues sample which uses the capital shape file data and you could find its source code at "Sampels\StylesDrawFeaturesBasedOnValues.aspx.".

Thanks,
Khalil


ghadeerUser is Offline
03-19-2010 10:37 AM
Avatar
hello all....
that's really wonderful ...please i need your help in something like this issue :)
i want to expand in my application to more detailed information something like streets name buildings name to specific area
need help please......


ValUser is Offline
03-19-2010 11:44 AM
Avatar

For getting that type of detailed information, you need to get the appropriate data for your area of interest. If you need that information at the US level or for the world, you can take advantage of our product World Map Kit product :http://maps.thinkgeo.com/web/.  You can see that in many of the samples of "How Do I" apps, World Map Kit is used.

Also, you can get Google Map, MicrosoftMaps etc as you can see in the samples in the section "Data Providers" of the "How Do I" sample apps.

 



arshadUser is Offline
03-23-2010 08:14 AM
Avatar
hello.
can any body tell me how to get a country map with all roads from google maps, it then we can use it here with Map Suite..


RyanUser is Offline
03-23-2010 10:31 AM
Avatar

Arshad,

Please see the Overlays section in the evaluation download of Map Suite Web. We provide a sample that demonstrates how to connect to Google Maps and display a nationwide map. http://websamples.thinkgeo.com/



ghadeerUser is Offline
03-24-2010 05:05 PM
Avatar
hello.....
Overlay section is a very useful one but if we need also something like google earth which is more detailed...i want to expand even to the buildings locations and streets names. how do i get it please i am in the middle east (Jordan) i want to focus on Irbid city anyyy help please


KhalilUser is Offline
03-24-2010 09:08 PM
Avatar

Hi, ghadeer

We have provided four google map type for users; I guess Hybrid is what you want. Please refer to the code below:


                GoogleOverlay googleSatellite = new GoogleOverlay("Google Map Satellite");
                googleSatellite.JavaScriptLibraryUri = new Uri(ConfigurationManager.AppSettings["GoogleUri"] + "ABQIAAAAoxK_HcqphMsnUQHEwLwHlRSavkNJi0NVTgm4UDidoiIU5dUJpRQW88FufPCp0aTPraxZgZFAIUHn3Q");
                googleSatellite.GoogleMapType = GoogleMapType.Hybrid;

                Map1.CustomOverlays.Add(googleSatellite);

Thanks,
Khalil



ghadeerUser is Offline
03-28-2010 08:16 AM
Avatar
thanks khaliil ...
that's work amazingly but if i need to add my own data and the features that used in the library here how could use it be atention
(on my own country NOT USA) you are utilize these features using the DBF files and the shape file that's all for countries only i need to use it for my area ....how could i create my own to utilize these features that used
thanks


KhalilUser is Offline
03-28-2010 09:30 PM
Avatar

Hi, ghadeer

I guess that you want to use your own shape file data and maybe as well as the Google Hybrid map. Also, you could load your data into ShapeFileFeatureLayer and then you just need to use a LayerOverlay to load this layer. Here is a sample code for you, if you want to know more, please refer to our installed smaples.


                Map1.MapBackground.BackgroundBrush = new GeoSolidBrush(GeoColor.FromHtml("#94aac6"));
                Map1.MapUnit = GeographyUnit.Meter;
                Map1.CurrentExtent = new RectangleShape(-13939426.6371, 6701997.4056, -7812401.86, 2626987.386962);

                GoogleOverlay googleSatellite = new GoogleOverlay("Google Map Satellite");
                googleSatellite.JavaScriptLibraryUri = new Uri(ConfigurationManager.AppSettings["GoogleUri"]);
                googleSatellite.GoogleMapType = GoogleMapType.Hybrid;

                Map1.CustomOverlays.Add(googleSatellite);

                // If want to know more srids, please refer Projections.rtf in Documentation folder.
                Proj4Projection proj4Projection = new Proj4Projection();
                proj4Projection.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326);
                proj4Projection.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString();

                ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(MapPath("~/SampleData/world/cntry02.shp"));
                worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.FromArgb(100, 243, 239, 228), GeoColor.FromArgb(100, GeoColor.SimpleColors.Green));
                worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
                worldLayer.FeatureSource.Projection = proj4Projection;
                Map1.DynamicOverlay.Layers.Add("WorldLayer", worldLayer);

Thanks,

Khalil



nancyUser is Offline
04-03-2010 03:12 PM
Avatar
when i click to choose items the map doesnot appear


KhalilUser is Offline
04-05-2010 09:01 PM
Avatar
Hi, Nancy

It's maybe caused by various occasions. First off, please make sure that you have provided shape file data in the exact position you have specified in the app; or please check that whether you have set the width or height is 100 percent, if yes, please delete the DOCTYPE declaration. If you still have this problem, please provide us with a small sample.

Thanks,
Khalil


VcevolodUser is Offline
05-25-2010 04:30 AM
Avatar
In example FindTheFeatureTheUserClicked at click on layer World the information on the country on which click has been made is defined. How to receive such information on any informative layer. For example, the basic layer - a map of world , on pressing the button we receive a layer - capitals. As on click on capital to receive about it the information (the name, the population etc.)


JohnnyUser is Offline
05-26-2010 01:16 AM
Avatar

 Hi Vcevolod,

You could receive that information by using the QueryTools Property of FeatureLayer. Please refer to our installed samples under QueryingFeatureLayers folder for more details.

Thanks,

Johnny



VcevolodUser is Offline
05-26-2010 04:44 AM
Avatar
Hi Johnny, thanks for the answer. I looked through these examples from section QueryingFeatureLayers. All of them work on one layer. The problem is put as follows. There is a basis-map. The additional layer gets out of the menu and is located on a map. It can be badges of oil wells, metals etc. On click on a badge it is necessary to receive some information. Whether it is possible to receive this information server methods of type "Get Data When User Clicks" or it is necessary to use Ajax on the client?


JohnnyUser is Offline
05-27-2010 06:43 AM
Avatar

 Hi Vcevolod,

 
You can use Client Callback to add layers or query features information. I attached a simple sample. Please check it out and see if it meets your requirements.
 
Thanks,
Johnny
VcevolodUser is Offline
05-28-2010 04:18 AM
Avatar
Hi Johnny,

Thanks for an example. All is clear.
With the best regards, Vcevolod.


JohnnyUser is Offline
05-28-2010 05:01 AM
Avatar

 Hi Vcevolod,

You are welcome. Please feel free to ask any questions.

Thanks,

Johnny



You are not authorized to post a reply.
Active Forums 4.2