User Tools

Site Tools


map_suite_web_for_webforms_quick_start_guide

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
map_suite_web_for_webforms_quick_start_guide [2017/02/22 04:53]
tgwikiupdate [Adding the Map Control to your Web Form]
map_suite_web_for_webforms_quick_start_guide [2017/03/15 11:20] (current)
tgwikiupdate
Line 2: Line 2:
  
  
-<div msgbox>​The Map Suite Web QuickStart ​Guide will guide you through the process of creating a sample application and will help you become familiar with Map Suite.</​div>​+<div msgbox>​The Map Suite Web Quickstart ​Guide will guide you through the process of creating a sample application and will help you become familiar with Map Suite.</​div>​
  
 Welcome to Map Suite™ Web 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. Welcome to Map Suite™ Web 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.
Line 16: Line 16:
 \\ \\
 ===== Setting up the Environment ===== ===== Setting up the Environment =====
-Let's start with a new ASP.NET Web Site in Microsoft Visual Studio (2015 or newer) and call it "HelloWorld" (see Figure 1). Set the Templates to ".NET Framework 4.5" for the project.+Let's start with a new ASP.NET Web Site in Microsoft Visual Studio (2015 or newer) and call it "QuickstartSample" (see Figure 1). Set the Templates to ".NET Framework 4.5" for the project.We just need to a simple template for our website, let’s select “Empty” template and do not check any other items. Click “OK” button, then a website will be created in a new solution called “QuickstartSample”.
  
-{{webedition:QSG_WebEdition2_Img01.jpg}}+{{mapsuite10:webforms:​Map_Suite_WebForms_QSG_NewProject.png}}
  
-{{mapsuite10:​web:1.png}}+{{mapsuite10:​webforms:Map_Suite_WebForms_QSG_SetProjectTemplate.png}}
 \\ \\
 //Figure 1. Creating a new project in Visual Studio.// //Figure 1. Creating a new project in Visual Studio.//
- 
-We just need to a simple template for our website, let’s select “Empty” template and do not check any other items. (See Figure 2). Click “OK” button, then a website will be created in a new solution called “HelloWorld”. 
- 
-The website is created in a new solution called "​HelloWorld"​. The wizard creates several files including a Web form called "​Default.aspx"​. 
- 
-{{mapsuite10:​web:​2.png}} 
 \\ \\
-//Figure 2. Select “Empty” project item.// 
 \\ \\
- 
-The new web forms project structure is like blow. (See Figure 3). 
- 
-{{mapsuite10:​web:​5.png}} 
- 
-//Figure 3. HelloWorld Structure.//​ 
- 
 ===== Installing ThinkGeo Web NuGet packages ===== ===== Installing ThinkGeo Web NuGet packages =====
  
 To build this sample, we need to reference several packages from NuGet manager. There are two options for you. To build this sample, we need to reference several packages from NuGet manager. There are two options for you.
  
-1.  For the beginner of MapSuite 10.0 products, we recommend to use “MapSuiteWebForWebForms-Standard” package. This package is the full featured package for developing GIS application with web forms. Please refer http://​wiki.thinkgeo.com/​wiki/​map_suite_web_for_webforms#​standard for detail.+  - For the beginner of MapSuite 10.0 products, we recommend to use “MapSuiteWebForWebForms-Standard” package. This package is the full featured package for developing GIS application with web forms. Please refer http://​wiki.thinkgeo.com/​wiki/​map_suite_web_for_webforms#​standard for detail. 
 +  - For the advanced user of MapSuite 10.0 products and want to include the least set of reference, we recommend to use “MapSuiteWebForWebForms-BareBone” package. It only depends on required packages that a basic web forms application needs. Please refer http://​wiki.thinkgeo.com/​wiki/​map_suite_web_for_webforms#​barebonefor ​detail.
  
-2. For the advanced user of MapSuite 10.0 products and want to include the least set of reference, we recommend to use “MapSuiteWebForWebForms-BareBone” package. It only depends on required packages that a basic web forms application needs. Please refer http://​wiki.thinkgeo.com/​wiki/​map_suite_web_for_webforms#​barebone for detail. 
  
- +In this sample, we choose an beginner ​way. To build this sample, we are going to reference the "MapSuiteWebForWebForms-Standard" ​ package.
-In this sample, we choose an advanced ​way. To build this sample, we are going to reference the following packages. +
- +
-1. MapSuiteWebForWebForms-BareBone +
- +
-2. ThinkGeo.MapSuite.Layers.ShapeFile +
- +
-3. ThinkGeo.MapSuite.Layers.Background+
  
 Right-click on “References” in Solution Explorer and select “Manage NuGet Packages…” ​ Right-click on “References” in Solution Explorer and select “Manage NuGet Packages…” ​
  
-{{mapsuite10:​web:4.png}}+{{mapsuite10:​webforms:Map_Suite_WebForms_QSG_NuGetManager.png}}
  
-Now that we open NuGet dialog and install the three Nuget packages (See Figure ​4).+Now that we open NuGet dialog and install the three Nuget packages (See Figure ​2).
  
-{{mapsuite10:​web:6.png}}+{{mapsuite10:​webforms:Map_Suite_WebForms_QSG_InstallMvcPackage.png}}
  
-//​Figure ​4. Install NuGet package.//+//​Figure ​2. Install NuGet package.//
  
 Now the package is installing into the project. ​ Now the package is installing into the project. ​
 +Click “OK” if the message box like the following pops up.
 +\\
 +{{mapsuite10:​webforms:​Map_Suite_WebForms_QSG_ReferenceRreview.png}}
 +\\
  
 The “NetTopologySuite” is the third part assembly, so the license acceptance is required. You can click “I Accept” to agree the license. The “NetTopologySuite” is the third part assembly, so the license acceptance is required. You can click “I Accept” to agree the license.
  
-{{mapsuite10:​web:licenseacceptance.png}}+{{mapsuite10:​webforms:Map_Suite_WebForms_QSG_PackageLicenseAcceptance.png}} 
 + 
 +\\ 
 +Since we created an empty website, there isn’t any of pages under our project, let’s create our default main page. Right-click the project, select “Add” -> “Web Form”. Created a new page called “WebForm1.aspx”.(See Figure 3) 
 + 
 +{{mapsuite10:​webforms:​Map_Suite_WebForms_QSG_AddForm.png}} 
 +\\ 
 +//Figure 3. Create Web Form.// 
 +\\
  
 Now, we have all the reference set. In the next chapter, we are going to talk about the real coding part. Now, we have all the reference set. In the next chapter, we are going to talk about the real coding part.
Line 78: Line 69:
  
  The capitals of the world countries (“~/​AppData/​WorldCapitals.shp”)  The capitals of the world countries (“~/​AppData/​WorldCapitals.shp”)
- 
-===== Adding the Map Control to the Visual Studio Toolbox ===== 
-**1.** When you first open Microsoft Visual Studio 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..."​ 
- 
-{{webedition:​QSG_WebEdition2_Img03.jpg}} 
- 
-**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 //​MapSuiteWebForWebForms-BareBone 10.0.0 NuGet package// installation folder and select the "​ThinkGeo.MapSuite.WebForms.dll“ file.  
- 
-{{webedition:​QSG_WebEdition2_Img04b.jpg}} 
- 
-**3.** You should now have the Map Control available in your Toolbox as shown below. 
- 
-{{webedition:​QSG_WebEdition2_Img05.jpg}} 
- 
  
 ===== Adding the Map Control to your Web Form ===== ===== Adding the Map Control to your Web Form =====
 +When you first open Microsoft Visual Studio after installing Map Suite, you may not see the control in the Toolbox. You will need to follow these steps to add the control.
  
-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 formYou can resize the map if you desireYou can leave the name of the Map control as "​Map1"​. Our map will display in this object.+**1.** Open “…/​QuickstartSample/​packages/​MapSuiteWebForWebForms-Standard.10.0.0/​designtime” package folder ​and drag “ThinkGeo.MapSuite.WebForms.dll” assembly to the Toolbox ​of Visual Studio.(See Figure 4)
  
-{{mapsuite10:​web:QSG_WebEdition2_Img07b.png}}+{{mapsuite10:​webforms:Map_Suite_WebForms_QSG_ControlDesigntime.png}} 
 +\\ 
 +//Figure 4. Add Map Control To Toolbox.//​ 
 +\\ 
 +**2.** 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 form. You can resize the map if you desire. You can leave the name of the Map control as "​Map1"​. Our map will display in this object.(See Figure 5)
  
 +{{mapsuite10:​webforms:​Map_Suite_WebForms_QSG_AddMapControl.png}}
 +\\
 +//Figure 5. Add Map Control To The Web From.//
 +\\
 We can also add some codes to use a map: We can also add some codes to use a map:
 <code asp> <code asp>
-<%@ Page Language="​C#"​ AutoEventWireup="​true"​ CodeBehind="​Default.aspx.cs"​ Inherits="​HelloWorld._Default" %>+<%@ Page Language="​C#"​ AutoEventWireup="​true"​ CodeBehind="​WebForm1.aspx.cs"​ Inherits="​QuickstartSample.WebForm1" %>
 <%@ Register Assembly="​ThinkGeo.MapSuite.WebForms"​ Namespace="​ThinkGeo.MapSuite.WebForms"​ TagPrefix="​cc1"​ %> <%@ Register Assembly="​ThinkGeo.MapSuite.WebForms"​ Namespace="​ThinkGeo.MapSuite.WebForms"​ TagPrefix="​cc1"​ %>
 <​!DOCTYPE html> <​!DOCTYPE html>
- +
 <html xmlns="​http://​www.w3.org/​1999/​xhtml">​ <html xmlns="​http://​www.w3.org/​1999/​xhtml">​
 <head runat="​server">​ <head runat="​server">​
-    <​title>​Hello World</​title>​+    <​title>​Quickstart</​title>​
 </​head>​ </​head>​
 <​body>​ <​body>​
Line 116: Line 100:
         <​asp:​ScriptManager ID="​ScriptManager1"​ runat="​server">​         <​asp:​ScriptManager ID="​ScriptManager1"​ runat="​server">​
         </​asp:​ScriptManager>​         </​asp:​ScriptManager>​
-        <cc1:Map ID="​Map1"​ runat="​server"​ Height="​574px" Width="​966px">+        <cc1:Map ID="​Map1"​ runat="​server"​ Height="​600px" Width="​800px">
         </​cc1:​Map>​         </​cc1:​Map>​
     </​div>​     </​div>​
Line 126: Line 110:
 Now that we have "​ThinkGeo.MapSuite.dll"​ referenced and a Map Control added. We are ready for adding the code. Now that we have "​ThinkGeo.MapSuite.dll"​ referenced and a Map Control added. We are ready for adding the code.
  
-===== Map Suite Web "Hello World" Sample ===== +===== Map Suite Web "Quickstart" 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.+After this section, you will be able to draw a map with Map Suite Web for WebForms ​using your own data. At the very beginning, let's have a look at the data and the important objects we will use.
  
-==== Map Suite Web "Hello World" ==== +==== Map Suite Web "QuickstartSample" ==== 
-In creating your "Hello World" ​sample ​application,​ your first step is to set some references at the very top of your code, as you 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 your 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. Add the references like this:+In creating your "QuickstartSample" application,​ your first step is to set some references at the very top of your code, as you 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 your 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. Add the references like this:
  
 <code csharp> <code csharp>
Line 168: Line 152:
             Map1.StaticOverlay.Layers.Add(worldLayer);​             Map1.StaticOverlay.Layers.Add(worldLayer);​
             // Set the default map extent, the unit is Decimal Degree.             // Set the default map extent, the unit is Decimal Degree.
-            Map1.CurrentExtent = new RectangleShape(5783026);+            Map1.CurrentExtent = new RectangleShape(-13470-567);
             // Set the background color.             // Set the background color.
             Map1.MapBackground = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean);​             Map1.MapBackground = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean);​
Line 175: Line 159:
 </​code>​ </​code>​
  
-If you compile and run what you have now, your map should look like the one below. (See Figure ​5).+If you compile and run what you have now, your map should look like the one below. (See Figure ​6).
  
-{{mapsuite10:​web:sample1.png}}+{{mapsuite10:​webforms:Map_Suite_WebForms_QSG_ShowAreaStyle.png}}
 \\ \\
-//​Figure ​5. A sample map of Europe.//+//​Figure ​6. A sample map of Europe.//
  
 So what has occurred here? We have created a layer and added it to the map and the map has rendered according to its default style parameters. Also, we have used ZoomLevel to display the map the way that we want. So what has occurred here? We have created a layer and added it to the map and the map has rendered according to its default style parameters. Also, we have used ZoomLevel to display the map the way that we want.
Line 234: Line 218:
  
         // Set the default map extent, the unit is Decimal Degree.         // Set the default map extent, the unit is Decimal Degree.
-        Map1.CurrentExtent = new RectangleShape(5783026);+        Map1.CurrentExtent = new RectangleShape(-13470-567);
         Map1.MapBackground = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean);​         Map1.MapBackground = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean);​
     }     }
Line 240: Line 224:
 </​code>​ </​code>​
  
-The result is as follows(Figure ​6):+The result is as follows(Figure ​7):
  
-{{mapsuite10:​web:sample2.png}}+{{mapsuite10:​webforms:Map_Suite_WebForms_QSG_ShowPointStyle.png}}
 \\ \\
-//​Figure ​6. Map of Europe with 2 layers.//+//​Figure ​7. Map of Europe with 2 layers.//
  
 ===== How to Use the TextStyle ===== ===== How to Use the TextStyle =====
Line 250: Line 234:
 A TextStyle is used to label items on map. As every ShapeFile has a related .dbf file that includes descriptions for every record, the most common way to use TextStyle is for labeling. For example, WorldCapital ShapeFile'​​s corresponding .dbf file contains the field "​​CITY_NAME"​​. We can use this field to label the cities on our map. A TextStyle is used to label items on map. As every ShapeFile has a related .dbf file that includes descriptions for every record, the most common way to use TextStyle is for labeling. For example, WorldCapital ShapeFile'​​s corresponding .dbf file contains the field "​​CITY_NAME"​​. We can use this field to label the cities on our map.
  
-{{mapsuite10:​web:sample3.png}}+{{mapsuite10:​webforms:Map_Suite_WebForms_QSG_DBFDetails.png}}
  
 Map Suite has many TextStyles built in to help us quickly design attractive labels for the cities on our map. We can just pick the TextStyle we like and use it. Map Suite has many TextStyles built in to help us quickly design attractive labels for the cities on our map. We can just pick the TextStyle we like and use it.
Line 304: Line 288:
         Map1.StaticOverlay.Layers.Add(worldLayer);​         Map1.StaticOverlay.Layers.Add(worldLayer);​
         Map1.StaticOverlay.Layers.Add(capitalLayer);​         Map1.StaticOverlay.Layers.Add(capitalLayer);​
 +        Map1.StaticOverlay.Layers.Add(capitalLabelLayer);​
  
         // Set the default map extent, the unit is Decimal Degree.         // Set the default map extent, the unit is Decimal Degree.
-        Map1.CurrentExtent = new RectangleShape(5783026);+        Map1.CurrentExtent = new RectangleShape(-13470-567);
         // Set the background color.         // Set the background color.
         Map1.MapBackground = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean);​         Map1.MapBackground = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean);​
Line 313: Line 298:
 </​code>​ </​code>​
  
-The result is as follows (Figure ​7):+The result is as follows (Figure ​8):
  
-{{webedition:QSG_WebEdition2_Img12.jpg}}+{{mapsuite10:webforms:​Map_Suite_WebForms_QSG_ShowTextStyle.png}}
 \\ \\
-//​Figure ​7. Map of Europe with a TextStyle.//​+//​Figure ​8. Map of Europe with a 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. 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.
Line 380: Line 365:
         Map1.StaticOverlay.Layers.Add(capitalLabelLayer);​         Map1.StaticOverlay.Layers.Add(capitalLabelLayer);​
  
-        Map1.CurrentExtent = new RectangleShape(5783026);+        Map1.CurrentExtent = new RectangleShape(-13470-567);
  
         // Set the background color to make the map beautiful.         // Set the background color to make the map beautiful.
Line 388: Line 373:
 </​code>​ </​code>​
  
-Can you imagine what the map will look like now? Figure 9 below is the result. At first it looks the same as it did in Figure ​7. Now zoom in, and watch the map change to resemble Figure ​as you do.+Can you imagine what the map will look like now? Figure 9 below is the result. At first it looks the same as it did in Figure ​8. Now zoom in, and watch the map change to resemble Figure ​10 as you do.
  
-{{webedition:QSG_WebEdition2_Img13.jpg}}+{{mapsuite10:webforms:​Map_Suite_WebForms_QSG_ShowLowZoomLevel.png}}
 \\ \\
-//​Figure ​8. A map of European cities with two ZoomLevels, before zooming in.//+//​Figure ​9. A map of European cities with two ZoomLevels, before zooming in.//
  
-{{webedition:QSG_WebEdition2_Img14.jpg}}+{{mapsuite10:webforms:​Map_Suite_WebForms_QSG_ShowHighZoomLevel.png}}
 \\ \\
-//​Figure ​9. The same map with two ZoomLevels, after zooming in.//+//​Figure ​10. The same map with two ZoomLevels, after zooming in.//
  
 ==== Using the Map in an Update Panel ==== ==== 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. 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 ''​MapSuite.WebEdition''​ namespace at the very top of our code:+First, let's add a marker on the map. Our first step is to add a reference to the ''​ThinkGeo.MapSuite.WebForms''​ namespace at the very top of our code:
  
 <code csharp> <code csharp>
Line 415: Line 400:
     {     {
         // Add a new feature as a marker         // Add a new feature as a marker
-        Map1.MarkerOverlay.FeatureSource.InternalFeatures.Add("​Marker",​ new Feature(052));+        Map1.MarkerOverlay.FeatureSource.InternalFeatures.Add("​Marker",​ new Feature(-10040));
  
         // Set the marker style, and make it available all over the zoomlevels.         // Set the marker style, and make it available all over the zoomlevels.
Line 426: Line 411:
 Let's run the application and click the button. You will see a marker appear near London. (Figure 11) Let's run the application and click the button. You will see a marker appear near London. (Figure 11)
  
-{{webedition:QSG_WebEdition2_Img15.jpg}}+{{mapsuite10:webforms:​Map_Suite_WebForms_QSG_ShowMarkerFeature.png}}
 \\ \\
 //Figure 11. Add a marker to the map.// //Figure 11. Add a marker to the map.//
map_suite_web_for_webforms_quick_start_guide.1487739199.txt.gz · Last modified: 2017/02/22 04:53 by tgwikiupdate