GPS软件监测点坐标
private void Form2_Load(object sender, EventArgs e)
{
serialPort1.Open();
}
private void serialPort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
{
string tmpstr = "";
safeAddtrText(serialPort1.ReadLine());
}
public delegate void _SafeAddtrTextCall(string text);
private void safeAddtrText(string text)
{
if (this.InvokeRequired)
{
_SafeAddtrTextCall call =
delegate(string s)
{
textBox2.Text = s;
jwd(s);
};
this.Invoke(call, text);
}
else
{
textBox2.Text = text;
jwd(text);
}
}
void jwd(string str)
{
string[] ss = str.Split(',');
if (ss[0] == "$GPRMC"&& ss[2]=="A")
{
double wd = double.Parse( ss[3]);
double jd = double.Parse(ss[5]);
txtwd.Text = f2d(wd).ToString();
txtjd.Text = f2d(jd).ToString();
}
}
double f2d(double f)
{
f = f / 100;
return Math.Round( (int)f+ ((f % ((int)f )) / 60) * 100,4);
}
private void button1_Click(object sender, EventArgs e)
{
serialPort1.Close();
}
把经纬度写入记事本
根据记事本中的经纬度生成点坐标,再叠加到底图上,添加个timer控件,设置间隔时间,记事本中的经纬度改变,点坐标就会动态显示