User Tools

Site Tools


thinkgeo_cloud_.net_sdk_quick_start_guide

ThinkGeo Cloud .NET SDK Quick Start Guide

The ThinkGeo Cloud .NET SDK Quickstart Guide will guide you through the process of creating a sample application and will help you become familiar with ThinkGeo Cloud .NET SDK.

The purpose of this guide is to help you quickly get started building your own spatially aware applications with ThinkGeo Cloud. 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 ThinkGeo Cloud? The best way is to make a sample application with it.

Download the Sample

Setting up the Environment

Let's start with a new WPF project in Microsoft Visual Studio (2015 or newer) and call it QuickstartSample (see Figure 1). We can create the project with .NET Framework 4.0 or 4.5.


Figure 1. Creating a new project in the Visual Studio IDE.

The project QuickstartSample is created in a new solution called QuickstartSample. The wizard creates a single WPF Application. Next we need to install MapSuiteDesktopForWpf-Standard from nugget package server (see Figure 2-5).


Figure 2. Refer to Manage NuGet Packages.


Figure 3. Refer to MapSuiteDesktopForWpf - Standard.

Now the package is installing into the project.

Click “OK” if the message box like Figure 4 pops up.

Figure 4. Review package references.

The “NetTopologySuite” is the third part assembly, so the license acceptance is required. You can click “I Accept” to agree the license.(See Figure 5)

Figure 5. NuGet installation success.

Adding the Map Control

Open “…/QuickstartSample/packages/MapSuiteDesktopForWpf-Standard.10.0.0/designtime” package folder and drag “ThinkGeo.MapSuite.Wpf.dll” assembly to the Toolbox of Visual Studio.

Draw the Map control on the MainWindow by clicking on the WpfMap Control object in the Toolbox and then dragging(using the left mouse button) it to the MainWindow. 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.

The second way. You can open your .xaml file and add reference code to refer Wpf map to your application (See Figure 6)

<Window x:Class="HelloWorld.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:HelloWorld"
        mc:Ignorable="d"
        xmlns:uc1="clr-namespace:ThinkGeo.MapSuite.Wpf;assembly=ThinkGeo.MapSuite.Wpf"
        Title="MainWindow" Height="600" Width="800">
    <Grid>
        <uc1:WpfMap Name="Map1" Loaded="Map1_Loaded"/>
    </Grid>
</Window>


Figure 6. 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.
Once the developer license is ready, run the application. Your map should look like the one below: (see Figure 7).

Figure 7. The normal map is rendered after the developer license file has been got.

Now you can see the ThinkGeo.Cloud.Client had been installed also. Copy the code as below and paste it into Map_Loaded function, it can works.

            map.MapUnit = GeographyUnit.Meter;
            map.ZoomLevelSet = ThinkGeoCloudMapsOverlay.GetZoomLevelSet();
 
            thinkGeoCloudMapsOverlay = new ThinkGeoCloudMapsOverlay();
            //thinkGeoCloudMapsOverlay = new ThinkGeoCloudMapsOverlay(clientId, clientSecret);
 
            // Tiles will be cached in the TEMP folder (%USERPROFILE%\AppData\Local\Temp\MapSuite\PersistentCaches) by default if the TileCache property is not set.
            //thinkGeoCloudMapsOverlay.TileCache = new XyzFileBitmapTileCache("ThinkGeoCloudMapsTileCache");
 
            map.Overlays.Add(thinkGeoCloudMapsOverlay);
 
            map.CurrentExtent = new ThinkGeo.MapSuite.Shapes.RectangleShape(-13086298.60, 7339062.72, -8111177.75, 2853137.62);
            map.Refresh();
thinkgeo_cloud_.net_sdk_quick_start_guide.txt · Last modified: 2018/12/29 10:27 by tgwikiupdate