User Tools

Site Tools


thinkgeo_desktop_for_.net_core_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
thinkgeo_desktop_for_.net_core_quick_start_guide [2019/09/23 07:31]
tgwikiupdate [Download the Sample]
thinkgeo_desktop_for_.net_core_quick_start_guide [2019/11/11 20:36] (current)
benbai
Line 1: Line 1:
-====== ​Map Suite Quick Start Guide For Wpf ======+====== ​ThinkGeo UI Desktop for WPF Quickstart ​Guide ======
  
 <div msgbox> <div msgbox>
-**Note:** If you are using Map Suite 10.0 or previous versions of Map Suite product, please go to [[map_suite_desktop_for_wpf|MapSuite 10.0 Wiki]]. The current page is for ThinkGeo 12.0 and future versions. It has different assemblies, licensing strategy ​and ways of distributionand more. although ​the majority of previously built code should work without modification assuming the new namespaces are added. ​ For guidance on upgrading your existing code to ThinkGeo 12, please check out [[thinkgeo_12_upgrade_guide|ThinkGeo 12 Upgrade Guide]]. </​div>​+**Note:** If you are using Map Suite 10.0 or previous versions of the Map Suite product, please go to [[map_suite_desktop_for_wpf|MapSuite 10.0 Wiki]]. The current page is for ThinkGeo 12.0 and future versions. It has different assemblies, licensing strategy, methods ​of distribution and more. It is true however that the majority of previously built code should work without modification assuming the new namespaces are added. ​ For guidance on upgrading your existing code to ThinkGeo 12, please check out [[thinkgeo_12_upgrade_guide|ThinkGeo 12 Upgrade Guide]]. </​div>​
  
-Welcome to Map Suite™ 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 ThinkGeo ​UI 12.
  
-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.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.+ThinkGeo UI encompasses the Map Suite family of .NET map controls and components, delivering interactive maps, GIS and spatial analysis to your projects on Windows, Linux, Mac OS, and beyond. ThinkGeo UI controls are available in both .NET Core 3.0 and .NET Framework 4 flavors for maximum versatility. 
 + 
 +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. How do we start to learn how to take advantage of the power of ThinkGeo UI 12? The best way is to make a sample application with it.
 \\ \\
  
Line 13: Line 15:
 \\ \\
 \\ \\
 +===== Downloading ThinkGeo Product Center and Starting an Evaluation =====
 +
 +With ThinkGeo UI 12 there are two options for getting started quickly with your evaluation. Both ways require the download of our latest version of ThinkGeo Product Center which can be accessed by visiting our [[https:​https://​thinkgeo.com/​start-building-thinkgeo|website]]. ​ Once the download is complete registered users will be able to highlight the WPF tile and click "Start Evaluation"​. ​
 +
 +{{:​pc_12-2.png|}}
 +
 +\\
 +\\
 +
 +ThinkGeo Product Center also allows non-registered users the ability to sign up directly through the console. ​ So if you don't yet have an account make sure you register through Product Center to get your evaluation going.
 +
 +\\
 +\\
 +{{:​pc_12-3.png|}}
 +
 +\\
 +\\
 +
 ===== Setting up the Environment ===== ===== Setting up the Environment =====
 Let's start with a new WPF project in Microsoft Visual Studio (2019 or newer) and call it QuickstartSample (see Figure 1). We can create the project with .NET Core 3.0. Let's start with a new WPF project in Microsoft Visual Studio (2019 or newer) and call it QuickstartSample (see Figure 1). We can create the project with .NET Core 3.0.
Line 22: Line 42:
 \\ \\
  
-The project Quickstart sample is created in a new solution called Quickstart. The wizard creates a single WPF Application. Next we need to install ThinkGeo.UI.Wpf from nugget ​package server (see Figure 2-5). +The project Quickstart sample is created in a new solution called Quickstart. The wizard creates a single WPF Application. Next we need to install ThinkGeo.UI.Wpf from the Nuget package server (see Figure 2-5). 
  
 {{thinkgeo12:​screenshots:​quickstartguide:​quickstart_manage_nuget.png}} {{thinkgeo12:​screenshots:​quickstartguide:​quickstart_manage_nuget.png}}
Line 43: Line 63:
  
 ===== Adding the Map Control ===== ===== Adding the Map Control =====
-You can open your .xaml file and add reference code to refer Wpf map to your application (See Figure 5)+You can open your .xaml file and add reference code to refer WPF map to your application (See Figure 5)
  
 <code csharp> <code csharp>
Line 56: Line 76:
         Title="​MainWindow"​ Height="​600"​ Width="​800">​         Title="​MainWindow"​ Height="​600"​ Width="​800">​
     <​Grid>​     <​Grid>​
-        <​uc1:​MapView x:​Name="​mapView" Loaded="​MapViewLoaded"></​uc1:​MapView>​+        <​uc1:​MapView x:​Name="​mapView"></​uc1:​MapView>​
     </​Grid>​     </​Grid>​
 </​Window>​ </​Window>​
Line 65: Line 85:
 //Figure 5. Add Map Control to your application.//​ //Figure 5. Add Map Control to your application.//​
  
-If you have not set up a developer license, ​the ​Map Suite Product Center will pop up when you debug the app. You need to generate your developer license. For more details, please refer to http://​wiki.thinkgeo.com/​wiki/​map_suite_developer_license_guide.+If you have not set up a developer license, ​the ​ThinkGeo UI Product Center will pop up when you debug the app. You need to generate your developer license. For more details, please refer to http://​wiki.thinkgeo.com/​wiki/​map_suite_developer_license_guide.
 \\ \\
 Once the developer license is ready, run the application. Your map should look like the one below: (see Figure 6). Once the developer license is ready, run the application. Your map should look like the one below: (see Figure 6).
Line 72: Line 92:
 //Figure 6. The normal map is rendered after the developer license file has been got.// //Figure 6. The normal map is rendered after the developer license file has been got.//
  
-==== Map Suite Desktop for Wpf "​Quickstart"​ ====+==== ThinkGeo UI Desktop for WPF "​Quickstart"​ ====
 In creating our “Quickstart"​ application,​ our first step is to set references to the ThinkGeo.Core and ThinkGeo.UI.Wpf workspaces at the very top of our code, as we will use many classes within them. We do this so that we do not have to use the fully qualified name of the classes throughout our code. Setting a reference to the ThinkGeo workspace can be done in the “code-behind” of the form by selecting the form and hitting the F6 function key. Set the reference like this: In creating our “Quickstart"​ application,​ our first step is to set references to the ThinkGeo.Core and ThinkGeo.UI.Wpf workspaces at the very top of our code, as we will use many classes within them. We do this so that we do not have to use the fully qualified name of the classes throughout our code. Setting a reference to the ThinkGeo workspace can be done in the “code-behind” of the form by selecting the form and hitting the F6 function key. Set the reference like this:
  
Line 79: Line 99:
 using ThinkGeo.UI.Wpf;​ using ThinkGeo.UI.Wpf;​
 </​code>​ </​code>​
-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 (Countries02.shp) 
- 
-(NOTE: The data used in this sample can be found in the attached sample above in the “\AppData” folder) 
- 
-Our next step is to define and add our Layers. All of the following code can be placed in the ''​​MapViewLoaded''​​ event of the form. Here is the code to use for our example. ​ 
  
 +Now let's look at a code sample to bring this concept to fruition. We'll look at how to show a base map. 
 +Add "​Loaded"​ handle for Map View: 
 <code csharp> <code csharp>
-private void MapViewLoaded(object sender, RoutedEventArgs e) +<​uc1:​MapView x:​Name="​mapView" Loaded="MapViewLoaded"></uc1:​MapView>​
-+
-    // Set the Map Unit. The reason for setting it to DecimalDegrees is that is what the shapefile’s unit of measureis inherently in. +
-    ​mapView.MapUnit ​GeographyUnit.DecimalDegree;​ +
-    ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(@"AppData/​Countries02.shp"); +
-    AreaStyle areaStyle = new AreaStyle();​ +
-    areaStyle.FillBrush = new GeoSolidBrush(GeoColor.FromArgb(255,​ 233, 232, 214)); +
-    areaStyle.OutlinePen = new GeoPen(GeoColor.FromArgb(255,​ 118, 138, 69), 1); +
-    areaStyle.OutlinePen.DashStyle = LineDashStyle.Solid;​ +
-    worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = areaStyle;​ +
-    ​// This setting will apply from ZoonLevel01 to ZoomLevel20,​ that means we can see the world the same style withZoomLevel01 all the time no matter how far we zoom out/in. +
-    worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;​ +
-    // Create a new Layer Overlay to hold the layer we just created +
-    LayerOverlay layerOverlay = new LayerOverlay();​ +
-    // Add a background Layer +
-    layerOverlay.Layers.Add(new BackgroundLayer(new GeoSolidBrush(GeoColors.ShallowOcean)));​ +
-    // Add the shapefile layer to the layer overlay +
-    layerOverlay.Layers.Add(worldLayer);​ +
-    // We need to add the layerOverlay to map. +
-    mapView.Overlays.Add(layerOverlay);​ +
-    // Set a proper extent for the Map.   +
-    mapView.CurrentExtent = new RectangleShape(-134,​ 70, -56, 7); +
-    // We now need to call the Refresh() method of the Map control so that the Map can redraw based on the data tha has been provided. +
-    mapView.Refresh();​ +
-}+
 </​code>​ </​code>​
  
-You can get a normal ​map render ​(See Figure 7)+Our next step is to define and add our base map overlay. All of the following code can be placed in the ''​​MapViewLoaded''​​ event of the form. Here is the code to use for our example(see Figure 7)
  
-{{thinkgeo12:​screenshots:​quickstartguide:​quickstart_areastyle.png}} +<code csharp>​ 
-\\ +using System.Windows; 
-//Figure 7 Quickstart Run Result.//+using ThinkGeo.Core;​ 
 +using ThinkGeo.UI.Wpf;
  
-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. +namespace Quickstart
- +
-**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, you can both display a map and 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: +
- +
-  -The borders of every country in the world ("​Countries02.shp"​) +
-  -The capitals of the world countries ("​WorldCapitals.shp"​) +
- +
-<code csharp>​ +
-private void MapViewLoaded(object sender, RoutedEventArgs e)+
 { {
-    ​// Set the Map Unit. The reason for setting it to DecimalDegrees is that is what the shapefile’s unit ofmeasureis inherently in. +    ​public partial class MainWindow : Window 
-    ​mapView.MapUnit = GeographyUnit.DecimalDegree;​ +    ​{ 
-    ​ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(@"​AppData/​Countries02.shp"​); +        ​public MainWindow() 
-    ​AreaStyle areaStyle = new AreaStyle();​ +        { 
-    ​areaStyle.FillBrush = new GeoSolidBrush(GeoColor.FromArgb(255,​ 233, 232, 214)); +            ​InitializeComponent(); 
-    ​areaStyle.OutlinePen = new GeoPen(GeoColor.FromArgb(255,​ 118, 138, 69), 1); +        }
-    areaStyle.OutlinePen.DashStyle = LineDashStyle.Solid;​ +
-    worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = areaStyle;​ +
-    // This setting will apply from ZoonLevel01 to ZoomLevel20,​ that means we can see the world the same stylewithZoomLevel01 all the time no matter how far we zoom out/in. +
-    worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;​+
  
-    ShapeFileFeatureLayer capitalLayer = new ShapeFileFeatureLayer(@"​AppData/​WorldCapitals.shp"​); +        private void MapViewLoaded(object sender, RoutedEventArgs e
-    ​PointStyle pointStyle = new PointStyle();​ +        { 
-    ​pointStyle.SymbolType = PointSymbolType.Square;​ +            // Set the Map Unit
-    ​pointStyle.FillBrush ​new GeoSolidBrush(GeoColors.White); +            ​mapView.MapUnit ​GeographyUnit.Meter;
-    pointStyle.OutlinePen = new GeoPen(GeoColors.Black,​ 1); +
-    pointStyle.SymbolSize = 6;+
  
-    PointStyle stackStyle ​= new PointStyle(); +            // Add a background layer 
-    ​stackStyle.SymbolType = PointSymbolType.Square; +            var backgroundOverlay ​= new LayerOverlay(); 
-    stackStyle.FillBrush = new GeoSolidBrush(GeoColors.Maroon)+            ​backgroundOverlay.Layers.Add(new BackgroundLayer(new GeoSolidBrush(GeoColor.FromHtml("#​F0EEE8"​))));
-    stackStyle.OutlinePen = new GeoPen(GeoColors.Transparent,​ 0)+
-    stackStyle.SymbolSize = 2;+
  
-    pointStyle.CustomPointStyles.Add(stackStyle);​ +            // Add a base map overlay
-    ​capitalLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle ​pointStyle;​ +            var cloudRasterBaseMapOverlay ​new ThinkGeoCloudRasterMapsOverlay("​USlbIyO5uIMja2y0qoM21RRM6NBXUad4hjK3NBD6pD0~",​ "​f6OJsvCDDzmccnevX55nL7nXpPDXXKANe5cN6czVjCH0s8jhpCH-2A~~"​ThinkGeoCloudRasterMapsMapType.Light); 
-    // This setting also applies from ZoonLevel01 to ZoomLevel20that means we can see city symbols the same stylewith ZoomLevel01 all the time+            ​mapView.Overlays.Add(cloudRasterBaseMapOverlay);
-    ​capitalLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;+
  
-    // Create a new Layer Overlay to hold the layer we just created +            ​mapView.CurrentExtent = new RectangleShape(-2000000020000000, 20000000, -20000000); 
-    LayerOverlay layerOverlay = new LayerOverlay();​ +        } 
-    // Add a background Layer +    ​}
-    layerOverlay.Layers.Add(new BackgroundLayer(new GeoSolidBrush(GeoColors.ShallowOcean)));​ +
-    // Add the shapefile layer to the layer overlay +
-    layerOverlay.Layers.Add(worldLayer);​ +
-    // We need to add both of the new layers to the Layer OverLay.  +
-    layerOverlay.Layers.Add(capitalLayer);​ +
-    // We need to add the layerOverlay to map. +
-    mapView.Overlays.Add(layerOverlay);​ +
-    // Set a proper extent for the Map.   +
-    ​mapView.CurrentExtent = new RectangleShape(-13470, -56, 7); +
-    // We now need to call the Refresh() method of the Map control so that the Map can redraw based on the data thahas been provided. +
-    ​mapView.Refresh();​+
 } }
 </​code>​ </​code>​
  
-And the result is as follows (Figure 8):+{{thinkgeo12:screenshots:​quickstartguide:​quickstart_add_base_map_overlay.png}} 
 +//Figure 7. Add base map overlay to map view.//
  
-{{thinkgeo12:​screenshots:​quickstartguide:​quickstart_pointstyle.png}}+You can get a normal map render (See Figure 8) 
 + 
 +{{thinkgeo12:​screenshots:​quickstartguide:​quickstart_base_map_screenshot.png}}
 \\ \\
-//Figure 8. Map of Europe with 2 layers.//+//Figure 8 Quickstart Run Result.//
  
-===== How to Use GeoTextStyle ===== +**NOTE:** It is important that the "​MapUnit"​ property of a Map object be set using the "​GeographyUnit"​ enumeration,​ 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. 
-==== TextStyle ​==== + 
-TextStyles are used to label items on the map. As every ShapeFile has relative .dbf file that includes descriptions for every record, the most common way to use TextStyles is for labelingFor examplethe WorldCapitals Shapefile's corresponding .dbf file contains the field “CITY_NAME”. We can use this field to label the cities on our map.+==== Navigate the Map ==== 
 +With the above code, you can both display a map and navigate itYou can pan by dragging the map, zoom in by double-clicking,​ track zoom in by drawing ​rectangle with your left mouse button mouse while holding the shift keyor zoom in and out by using the mouse wheelVery powerful for just couple lines of codeisn't it?
  
-{{thinkgeo12:​screenshots:​quickstartguide:​quickstart_worldcapitals_dbf.png}}+That was an easy start! Now, let's add a Shapefile to the sample. The capitals of the world countries ("​WorldCapitals.shp"​).
  
-Map Suite has many TextStyles built in to help us quickly design attractive labels for the cities on our mapWe can just pick the TextStyle we like and use it.+Our next step is to define and add Shapefile layerAll of the following code can be placed in the ''​​MapViewLoaded''​​ event of the form. Here is the code to use for our example(see Figure 9)
  
 <code csharp> <code csharp>
 private void MapViewLoaded(object sender, RoutedEventArgs e) private void MapViewLoaded(object sender, RoutedEventArgs e)
 { {
-    // Set the Map Unit. The reason for setting it to DecimalDegrees is that is what the shapefile’s unitofmeasureis inherently in+    // Set the Map Unit. 
-    mapView.MapUnit = GeographyUnit.DecimalDegree;​ +    mapView.MapUnit = GeographyUnit.Meter;
-    ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(@"​AppData/​Countries02.shp"​);​ +
-    AreaStyle areaStyle = new AreaStyle();​ +
-    areaStyle.FillBrush = new GeoSolidBrush(GeoColor.FromArgb(255,​ 233, 232, 214)); +
-    areaStyle.OutlinePen = new GeoPen(GeoColor.FromArgb(255,​ 118, 138, 69), 1); +
-    areaStyle.OutlinePen.DashStyle = LineDashStyle.Solid;​ +
-    worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = areaStyle;​ +
-    // This setting will apply from ZoonLevel01 to ZoomLevel20,​ that means we can see the world the samestylewithZoomLevel01 all the time no matter how far we zoom out/in. +
-    worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;+
  
-    ​ShapeFileFeatureLayer capitalLayer = new ShapeFileFeatureLayer(@"​AppData/WorldCapitals.shp"​);​ +    // Add a background layer 
-    ​PointStyle pointStyle ​= new PointStyle(); +    ​var backgroundOverlay ​= new LayerOverlay(); 
-    ​pointStyle.SymbolType = PointSymbolType.Square; +    ​backgroundOverlay.Layers.Add(new BackgroundLayer(new GeoSolidBrush(GeoColor.FromHtml("#​F0EEE8"​))));
-    pointStyle.FillBrush = new GeoSolidBrush(GeoColors.White); +
-    pointStyle.OutlinePen = new GeoPen(GeoColors.Black,​ 1)+
-    pointStyle.SymbolSize = 6;+
  
-    ​PointStyle stackStyle = new PointStyle();​ +    ​// Add a base map overlay
-    stackStyle.SymbolType = PointSymbolType.Square;​ +    ​var cloudRasterBaseMapOverlay ​= new ThinkGeoCloudRasterMapsOverlay("​USlbIyO5uIMja2y0qoM21RRM6NBXUad4hjK3NBD6pD0~",​ "​f6OJsvCDDzmccnevX55nL7nXpPDXXKANe5cN6czVjCH0s8jhpCH-2A~~",​ ThinkGeoCloudRasterMapsMapType.Light); 
-    ​stackStyle.FillBrush ​= new GeoSolidBrush(GeoColors.Maroon); +    ​mapView.Overlays.Add(cloudRasterBaseMapOverlay);
-    ​stackStyle.OutlinePen = new GeoPen(GeoColors.Transparent,​ 0)+
-    stackStyle.SymbolSize = 2;+
  
-    ​pointStyle.CustomPointStyles.Add(stackStyle);​ +    // Add a shapefile layer with point style
-    capitalLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = pointStyle;​ +    ​var customDataOverlay ​= new LayerOverlay(); 
-    // This setting also applies from ZoonLevel01 to ZoomLevel20,​ that means we can see city symbols the samestylewith ZoomLevel01 all the time. +    ​var capitalLayer = new ShapeFileFeatureLayer(@"​AppData/​WorldCapitals.shp"​);​ 
-    capitalLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;​ +    ​capitalLayer.FeatureSource.ProjectionConverter ​= new ProjectionConverter(43263857);
- +
-    // We create a new Layer for labeling the capitals. +
-    ShapeFileFeatureLayer capitalLabelLayer = new ShapeFileFeatureLayer(@"​AppData/​WorldCapitals.shp"​);​ +
-    GeoFont font = new GeoFont("​Arial",​ 9, DrawingFontStyles.Bold);​ +
-    GeoSolidBrush txtBrush = new GeoSolidBrush(GeoColors.Maroon);​ +
-    TextStyle textStyle = new TextStyle("​CITY_NAME",​ font, txtBrush);​ +
-    textStyle.XOffsetInPixel = 0; +
-    textStyle.YOffsetInPixel = -6; +
-    // We use the preset TextStyle. Here we passed in the “CITY_NAME”,​ which is the name of the field we want tolabel on map. +
-    capitalLabelLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = textStyle;​ +
-    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 wejoining the tiles together. +
-    // Change the number to another one (for example 0) and you can see the difference expecially when panning. +
- +
-    LayerOverlay layerOverlay = new LayerOverlay();​ +
-    ​// Add a background Layer +
-    layerOverlay.Layers.Add(new BackgroundLayer(new GeoSolidBrush(GeoColors.ShallowOcean)));​ +
-    // Add the shapefile layer to the layer overlay +
-    layerOverlay.Layers.Add(worldLayer);​ +
-    // We need to add both of the new layers to the Layer OverLay.  +
-    layerOverlay.Layers.Add(capitalLayer);​ +
-    layerOverlay.Layers.Add(capitalLabelLayer);​ +
-    // We need to add the layerOverlay to map. +
-    mapView.Overlays.Add(layerOverlay);​ +
-    // Set a proper extent for the Map.   +
-    mapView.CurrentExtent = new RectangleShape(-134,​ 70, -56, 7); +
-    // We now need to call the Refresh() method of the Map control so that the Map can redraw based on the datathahas been provided. +
-    mapView.Refresh();​ +
-+
-</​code>​ +
- +
-The result is as follows (Figure 9): +
- +
-{{thinkgeo12:​screenshots:​quickstartguide:​quickstart_textstyle.png}} +
-\\ +
-//Figure 9. 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. +
- +
-<code csharp>​ +
-private void MapViewLoaded(object sender, RoutedEventArgs e) +
-{ +
-    ​// Set the Map Unit. The reason for setting it to DecimalDegrees is that is what the shapefile’sunitofmeasureisinherently in. +
-    mapView.MapUnit = GeographyUnit.DecimalDegree;​ +
-    ShapeFileFeatureLayer worldLayer ​= new ShapeFileFeatureLayer(@"​AppData/​Countries02.shp"​); +
-    ​AreaStyle areaStyle = new AreaStyle();​ +
-    areaStyle.FillBrush = new GeoSolidBrush(GeoColor.FromArgb(255,​ 233, 232, 214)); +
-    areaStyle.OutlinePen = new GeoPen(GeoColor.FromArgb(255,​ 118, 138, 69), 1); +
-    areaStyle.OutlinePen.DashStyle = LineDashStyle.Solid;​ +
-    worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = areaStyle;​ +
-    // This setting will apply from ZoonLevel01 to ZoomLevel20,​ that means we can see the worldthesamestylewithZoomLevel01 all the time no matter how far we zoom out/in. +
-    worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;​ +
- +
-    ShapeFileFeatureLayer ​capitalLayer = new ShapeFileFeatureLayer(@"​AppData/​WorldCapitals.shp"​);​ +
-    ​PointStyle pointStyle = new PointStyle();​ +
-    pointStyle.SymbolType = PointSymbolType.Square; +
-    pointStyle.FillBrush ​= new GeoSolidBrush(GeoColors.White);​ +
-    pointStyle.OutlinePen = new GeoPen(GeoColors.Black1)+
-    pointStyle.SymbolSize = 6; +
- +
-    PointStyle stackStyle = new PointStyle();​ +
-    stackStyle.SymbolType = PointSymbolType.Square;​ +
-    stackStyle.FillBrush = new GeoSolidBrush(GeoColors.Maroon);​ +
-    stackStyle.OutlinePen = new GeoPen(GeoColors.Transparent,​ 0); +
-    stackStyle.SymbolSize = 2;+
  
-    ​pointStyle.CustomPointStyles.Add(stackStyle); +    ​var capitalStyle = new PointStyle() 
-    ​// We can customize our own Style. Here we passed in a color and a size. +    ​{ 
-    ​capitalLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle ​PointStyle.CreateSimpleCircleStyle(GeoColors.White, ​GeoColors.Brown); +        ​SymbolType ​PointSymbolType.Circle, 
-    ​// The Style we set here is available from ZoomLevel01 to ZoomLevel05That means if we zoom in a bit more, theappearance we set here will not be visible anymore.+        SymbolSize = 8, 
 +        FillBrush = new GeoSolidBrush(GeoColors.White), 
 +        OutlinePen = new GeoPen(GeoColors.Black, 2) 
 +    }
 +    ​capitalLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = capitalStyle;​
     capitalLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;​     capitalLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;​
 +    customDataOverlay.Layers.Add(capitalLayer);​
 +    mapView.Overlays.Add(customDataOverlay);​
  
- +    ​capitalLayer.Open(); 
-    ​capitalLayer.ZoomLevelSet.ZoomLevel06.DefaultPointStyle = pointStyle;​ +    // Set the extent ​of capitalLayer for the Map.  
-    // The Style we set here is available from ZoomLevel06 to ZoomLevel20. That means if we zoom out a bit more, th appearance we set here will not be visible any more. +    mapView.CurrentExtent = capitalLayer.GetBoundingBox();
-    capitalLayer.ZoomLevelSet.ZoomLevel06.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;​ +
- +
-    // We create a new Layer for labeling the capitals. +
-    ShapeFileFeatureLayer capitalLabelLayer = new ShapeFileFeatureLayer(@"​AppData/​WorldCapitals.shp"​)+
-    GeoFont font = new GeoFont("​Arial",​ 9, DrawingFontStyles.Bold);​ +
-    GeoSolidBrush txtBrush = new GeoSolidBrush(GeoColors.Maroon);​ +
-    TextStyle textStyle = new TextStyle("​CITY_NAME",​ font, txtBrush);​ +
-    textStyle.XOffsetInPixel = 0; +
-    textStyle.YOffsetInPixel = -6+
-    // We use the preset TextStyle. Here we passed in the “CITY_NAME”,​ which is the name of the field we wanttolabelon map. +
-    capitalLabelLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyle.CreateSimpleTextStyle("​CITY_NAME","​Arial",​ 8, DrawingFontStyles.Italic,​ GeoColors.Black,​ 3, 3); +
-    // The TextStyle we set here is available from ZoomLevel01 to ZoomLevel05.  +
-    capitalLabelLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level05;​ +
- +
-    capitalLabelLayer.ZoomLevelSet.ZoomLevel06.DefaultTextStyle = textStyle;​ +
-    // The TextStyle we set here is available from ZoomLevel06 to ZoomLevel20.  +
-    capitalLabelLayer.ZoomLevelSet.ZoomLevel06.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;​ +
- +
- +
-    LayerOverlay layerOverlay = new LayerOverlay();​ +
-    // Add a background Layer +
-    layerOverlay.Layers.Add(new BackgroundLayer(new GeoSolidBrush(GeoColors.ShallowOcean)));​ +
-    // Add the shapefile layer to the layer overlay +
-    layerOverlay.Layers.Add(worldLayer);​ +
-    // We need to add both of the new layers to the Layer OverLay.  +
-    layerOverlay.Layers.Add(capitalLayer); +
-    layerOverlay.Layers.Add(capitalLabelLayer);​ +
-    // We need to add the layerOverlay to map. +
-    mapView.Overlays.Add(layerOverlay);​ +
-    // Set a proper extent ​for the Map.   +
-    mapView.CurrentExtent = new RectangleShape(-134,​ 70, -56, 7); +
-    // We now need to call the Refresh() method of the Map control so that the Map can redraw based on thedatathaha been provided. +
-    mapView.Refresh();+
 } }
 </​code>​ </​code>​
  
-Can you imagine what the map will look like now? Below is the resultAt first it appears like figure 11, and the map changes to figure 12 as you zoom in.+{{thinkgeo12:​screenshots:​quickstartguide:​quickstart_addlayer_shapefile_piontstyle.png}} 
 +//Figure 9. Define ​and add Shapefile layer.//
  
-{{thinkgeo12:​screenshots:​quickstartguide:​quickstart_europe_zoomlevel1.png}} +And the result is as follows (Figure 10):
-\\ +
-//Figure 10. Map of Europe with two ZoomLevels, before Zoom In.//+
  
-{{thinkgeo12:​screenshots:​quickstartguide:​quickstart_europe_zoomlevel2.png}}+{{thinkgeo12:​screenshots:​quickstartguide:​quickstart_shapefile_piontstyle_screenshot.png}}
 \\ \\
-//​Figure ​11Map of Europe with two ZoomLevels, after Zoom In.//+//​Figure ​10Shapefile layer rendering result.// 
 + 
 +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.
  
 This completes ​this scenario. The next thing you might want to do is to make it run on another machine ​that does not have a developer license. ​A runtime ​license is the one we are looking for. Here is a guide to generate a runtime license to satisfy it, please refer to (http://​wiki.thinkgeo.com/​wiki/​map_suite_runtime_license_guide_for_desktop ) for details. This completes ​this scenario. The next thing you might want to do is to make it run on another machine ​that does not have a developer license. ​A runtime ​license is the one we are looking for. Here is a guide to generate a runtime license to satisfy it, please refer to (http://​wiki.thinkgeo.com/​wiki/​map_suite_runtime_license_guide_for_desktop ) for details.
- 
  
 ===== Summary ===== ===== Summary =====
-You now know the basics of using the ThinkGeo Map control ​and are able to get started adding 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:+You now know the basics of using the ThinkGeo Map controls ​and are able to get started adding functionality into your own applications. Let's recap what we have learned about the object relationships and how the pieces of ThinkGeo UI work together:
  
   -It is of the utmost importance that the units (feet, meters, decimal degrees, etc.) be set properly for the Map control based on the data.   -It is of the utmost importance that the units (feet, meters, decimal degrees, etc.) be set properly for the Map control based on the data.
   -Shapefiles provide the data used by a Map control to render a map.   -Shapefiles provide the data used by a Map control to render a map.
   -A Map is the basic control that contains all of the other objects that are used to tell how the map is to be rendered.   -A Map is the basic control that contains all of the other objects that are used to tell how the map is to be rendered.
-  -A Map has one-to-many Layers. A Layer correlates one-to-one with a shape file (.shp). +  -A Map has many layers. A Layer correlates one-to-one with a shape file (.shp). 
-  -A Layer can have one-to-many ​ZoomLevels. ZoomLevels help to define ranges (upper and lower) of when a Layer should be shown or hidden.+  -A Layer can have several ​ZoomLevels. ZoomLevels help to define ranges (upper and lower) of when a Layer should be shown or hidden.
  
  
  
  
thinkgeo_desktop_for_.net_core_quick_start_guide.1569223917.txt.gz · Last modified: 2019/09/23 07:31 by tgwikiupdate