forked from SharpMap/SharpMap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextOnPathSample.cs
More file actions
75 lines (66 loc) · 3.01 KB
/
TextOnPathSample.cs
File metadata and controls
75 lines (66 loc) · 3.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;
using SharpMap;
using SharpMap.Data.Providers;
using SharpMap.Layers;
using SharpMap.Rendering;
using SharpMap.Rendering.Symbolizer;
using SharpMap.Styles;
using Point = GeoAPI.Geometries.Coordinate;
namespace WinFormSamples.Samples
{
class TextOnPathSample
{
public static Map InitializeMapOrig(float angle)
{
//Initialize a new map of size 'imagesize'
Map map = new Map();
//Set up the countries layer
VectorLayer layRoads = new VectorLayer("Roads");
//Set the datasource to a shapefile in the App_data folder
layRoads.DataSource = new ShapeFile("GeoData/World/shp_textonpath/DeMo_Quan5.shp", false);
(layRoads.DataSource as ShapeFile).Encoding = Encoding.UTF8;
//Set fill-style to green
layRoads.Style.Fill = new SolidBrush(Color.Yellow);
layRoads.Style.Line = new Pen(Color.Yellow, 4);
//Set the polygons to have a black outline
layRoads.Style.Outline = new Pen(Color.Black, 5); ;
layRoads.Style.EnableOutline = true;
layRoads.SRID = 4326;
//Set up a country label layer
LabelLayer layLabel = new LabelLayer("Roads labels");
layLabel.DataSource = layRoads.DataSource;
layLabel.Enabled = true;
layLabel.LabelColumn = "tenduong";
layLabel.LabelFilter = SharpMap.Rendering.LabelCollisionDetection.ThoroughCollisionDetection;
layLabel.Style = new LabelStyle();
layLabel.Style.ForeColor = Color.White;
layLabel.Style.Font = new Font(FontFamily.GenericSerif, 9f, FontStyle.Bold);
layLabel.Style.Halo = new Pen(Color.Black, 2f);
layLabel.Style.IsTextOnPath = true;
layLabel.Style.CollisionDetection = true;
//layLabel.Style.BackColor = new SolidBrush(Color.FromArgb(128, 255, 0, 0));
//layLabel.MaxVisible = 90;
//layLabel.MinVisible = 30;
layLabel.Style.HorizontalAlignment = LabelStyle.HorizontalAlignmentEnum.Center;
layLabel.SRID = 4326;
//layLabel.MultipartGeometryBehaviour = LabelLayer.MultipartGeometryBehaviourEnum.Largest;
//Add the layers to the map object.
//The order we add them in are the order they are drawn, so we add the rivers last to put them on top
map.Layers.Add(layRoads);
map.Layers.Add(layLabel);
//limit the zoom to 360 degrees width
//map.MaximumZoom = 360;
// map.BackColor = Color.LightBlue;
map.ZoomToExtents();
Matrix mat = new Matrix();
mat.RotateAt(angle, map.WorldToImage(map.Center));
map.MapTransform = mat;
return map;
}
}
}