-
Notifications
You must be signed in to change notification settings - Fork 119
/
Copy pathBPOI.cs
93 lines (91 loc) · 2.45 KB
/
BPOI.cs
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json.Linq;
using System.Drawing;
namespace BMap.NET.WindowsForm.BMapElements
{
/// <summary>
/// 地图中POI 信息点
/// </summary>
public class BPOI : BMapElement
{
/// <summary>
/// 位置
/// </summary>
public LatLngPoint Location
{
set;
get;
}
/// <summary>
/// 索引号
/// </summary>
public int Index
{
get;
set;
}
/// <summary>
/// POI的数据源
/// </summary>
public JObject DataSource
{
get;
set;
}
private bool _selected;
/// <summary>
/// 当前POI是否被选中
/// </summary>
public bool Selected
{
get
{
return _selected;
}
set
{
_selected = value;
}
}
private Rectangle _rect;
/// <summary>
/// POI在屏幕中的范围
/// </summary>
public Rectangle Rect
{
get
{
return _rect;
}
}
/// <summary>
/// 绘制方法
/// </summary>
/// <param name="g"></param>
/// <param name="center"></param>
/// <param name="zoom"></param>
/// <param name="screen_size"></param>
public override void Draw(System.Drawing.Graphics g, LatLngPoint center, int zoom, System.Drawing.Size screen_size)
{
Point p = MapHelper.GetScreenLocationByLatLng(Location, center, zoom, screen_size); //屏幕坐标
Bitmap b;
if (_selected)
{
b = Properties.BMap.ico_blue_point_big;
}
else
{
b = Properties.BMap.ico_red_point_small;
}
g.DrawImage(b, new Rectangle(p.X - b.Width / 2, p.Y - b.Height, b.Width, b.Height));
using (Font f = new Font("微软雅黑", 10, FontStyle.Bold))
{
g.DrawString(((Char)(Index + 65)).ToString(), f, Brushes.White, new PointF(_selected ? (p.X - 5) : (p.X - 6), _selected ? (p.Y - 30) : (p.Y - 26)));
}
_rect = new Rectangle(p.X - b.Width / 2, p.Y - b.Height, b.Width, b.Height);
}
}
}