User Tools

Site Tools


map_suite_samples_applies_to

Map Suite Samples Applies To

In this article, we will take an example which is similar to the one marked with note “Applies To Desktop, Web, Silverlight, Services, Wpf” to show you how to use these samples in all Map Suite basic products, Services Edition, Desktop Edition, WPF Desktop Edition, Web Edidition and SilverlightEdition. And through this thread, we will know how extensible and cross-platform the Map Suite products are.

To make sure the demo is simple and understandable; it just includes “HeatLayer” and the result is as following.

Now please let us go through the sample with all products.

Download the Sample

Map Suite Services Edition

To display the HeatLayer with Services Edition, please open “Visual Studio” → “Add New Project” → Select “Windows Forms Application” template, and then add “MapSuiteCore” reference and a “PictureBox” control used for showing map. The code is simple and understandable like below:

ShapeFileFeatureSource featureSource = new ShapeFileFeatureSource(@"..\..\Data\quksigx020.shp");
HeatLayer heatlayer = new HeatLayer(featureSource);
HeatStyle heatStyle = new HeatStyle();
heatStyle.IntensityColumnName = "other_mag1";
heatStyle.IntensityRangeStart = 0;
heatStyle.IntensityRangeEnd = 12;
heatStyle.Alpha = 180;
heatlayer.HeatStyle = heatStyle;
mapEngine.DynamicLayers.Add("HeatLayer", heatlayer);
 
mapEngine.OpenAllLayers();
mapEngine.DrawDynamicLayers(bitmap, GeographyUnit.DecimalDegree);
mapEngine.CloseAllLayers();

Map Suite Desktop Edition

Displaying HeatLayer using Desktop Edition is very similar to the code in Service Edition, the biggest difference is that we need to reference “MapSuiteDesktop.dll” and use “Map Suite Desktop Map” to host and render the layer. Please see the code below:

ShapeFileFeatureSource featureSource = new ShapeFileFeatureSource(@"..\..\Data\quksigx020.shp");
HeatLayer heatlayer = new HeatLayer(featureSource);
HeatStyle heatStyle = new HeatStyle();
heatStyle.IntensityColumnName = "other_mag1";
heatStyle.IntensityRangeStart = 0;
heatStyle.IntensityRangeEnd = 12;
heatStyle.Alpha = 180;
heatlayer.HeatStyle = heatStyle;
 
LayerOverlay overlay = new LayerOverlay();
overlay.Layers.Add(heatlayer);
winformsMap1.Overlays.Add("HeatOverlay", overlay);

Map Suite Wpf Desktop Edition

WPF (Windows Presentation Foundation) is the next generation rendering user interfaces in Windows-based applications. It also can be used to display the HeatLayer using Map Suite Wpf Desktop Edition. Please check the code below, and you may find the code is same to the one used in Desktop Edition.

ShapeFileFeatureSource featureSource = new ShapeFileFeatureSource(@"..\..\Data\quksigx020.shp");
HeatLayer heatlayer = new HeatLayer(featureSource);
HeatStyle heatStyle = new HeatStyle();
heatStyle.IntensityColumnName = "other_mag1";
heatStyle.IntensityRangeStart = 0;
heatStyle.IntensityRangeEnd = 12;
heatStyle.Alpha = 180;
heatlayer.HeatStyle = heatStyle;
 
LayerOverlay overlay = new LayerOverlay();
overlay.Layers.Add(heatlayer);
Map1.Overlays.Add(overlay);

Map Suite Web Edition

To view the HeatLayer on the website, please create a “Web Application” with “Visual Studio”, reference the “MapSuiteCore.dll” and “WebEdition.dll” to the project, and then add the code as following to Page_Load method.

if (!IsPostBack)
{
    Map1.MapUnit = GeographyUnit.DecimalDegree;
    Map1.CurrentExtent = new RectangleShape(-125, 47, -67, 25);
 
    WorldMapKitWmsWebOverlay worldOverlay = new WorldMapKitWmsWebOverlay();
    Map1.CustomOverlays.Add(worldOverlay);
 
    ShapeFileFeatureSource featureSource = new ShapeFileFeatureSource(@"..\..\Data\quksigx020.shp");
    HeatLayer heatlayer = new HeatLayer(featureSource);
    HeatStyle heatStyle = new HeatStyle();
    heatStyle.IntensityColumnName = "other_mag1";
    heatStyle.IntensityRangeStart = 0;
    heatStyle.IntensityRangeEnd = 12;
    heatStyle.Alpha = 180;
    heatlayer.HeatStyle = heatStyle;
 
    LayerOverlay overlay = new LayerOverlay();
    overlay.IsBaseOverlay = false;
    overlay.Layers.Add(heatlayer);
    Map1.CustomOverlays.Add(overlay);
}

Map Suite Silverlight Edition

Displaying HeatLayer in Silverlight Application, two projects are required, one is client Silverlight project to host the map, and another one is web application to read the heat data from server and generates images for HeatLayer. Here as following is the sample code:

Client Side:

Map1.MapUnit = GeographyUnit.DecimalDegree;
 
ServerLayerOverlay serverLayerOverlay = new ServerLayerOverla("NativeServer", "SilverlightMapConnector1");
Map1.Overlays.Add(serverLayerOverlay);
 
WorldMapKitWmsSilverlightOverlay worldOverlay = new WorldMapKitWmsSilverlightOverlay();
Map1.Overlays.Add(worldOverlay);
 
Map1.CurrentExtent = new RectangleShape(-125, 47, -67, 25);

Server Side:

if (!Page.IsPostBack)
{
    ServerLayerOverlay layerOverlay = new ServerLayerOverlay("NativeServer");
 
    ShapeFileFeatureSource featureSource = new ShapeFileFeatureSource(@"..\..\Data\quksigx020.shp");
    HeatLayer heatlayer = new HeatLayer(featureSource);
    HeatStyle heatStyle = new HeatStyle();
    heatStyle.IntensityColumnName = "other_mag1";
    heatStyle.IntensityRangeStart = 0;
    heatStyle.IntensityRangeEnd = 12;
    heatStyle.Alpha = 180;
    heatlayer.HeatStyle = heatStyle;
    layerOverlay.Layers.Add(heatlayer);
 
    SilverlightMapConnector1.ServerLayerOverlays.Add(layerOverlay);
}

You now know why these samples are marked with “Applies To Desktop, Web, Silverlight, Services, Wpf”, because they can use in any Map Suite product with almost the same code. If you still have any questions please download the attached samples or contact support@thinkgeo.com for detail.

map_suite_samples_applies_to.txt · Last modified: 2015/10/10 07:31 (external edit)