GPS在谷歌地图上给出错误的位置

本文关键字:错误 位置 出错 谷歌地图 GPS | 更新日期: 2023-09-27 18:33:15

当我将Sim548c的GPS连接到Google map API时,我正在使用它的GPS和我的 C# 代码它给出了距离出口位置约 1 公里的错误位置,但是当我使用以下software它给出了出口位置时,在 10m 中,我为 GPS Cordinats 使用了以下代码集并将其传递给网络浏览器。

if (s.Contains("$GPRMC"))
        {
            latlon = s.Split('*');
            int i=0;
            while (!latlon[i].Contains("GPRMC"))
            {
                i++;
            }
            //latlon = latlon[i].Split(',');
            if (latlon[i].Contains(",A,"))
            {
                latlon = latlon[i].Split(',');
                lat = latlon[3];
                lon = latlon[5];

                latt = double.Parse(lat.Substring(0,2));
                latt += double.Parse(lat.Substring(2, 2)) / 60.0;
                latt += double.Parse(lat.Substring(5)) / 3600.0/100.0;
                lonn = double.Parse(lon.Substring(0,3));
                lonn += double.Parse(lon.Substring(3, 2))/60.0;
                lonn += double.Parse(lon.Substring(6))/3600.0/100.0;

                //richTextBox1.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate() { richTextBox1.AppendText("Write'n"); }));
                richTextBox2.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate() 
                    { 
                        richTextBox2.AppendText(lonn.ToString()+","+latt.ToString()+"'n"); 
                    }));
                label1.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate()
                {
                    label1.Content = lon;
                }));
                label2.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate()
                {
                    label2.Content = lat;
                }));
                Thread.Sleep(1000);
                webBrowser1.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate()
                    {
                        try
                        {
                            webBrowser1.InvokeScript("animate", latt.ToString(), lonn.ToString());
                        }
                        catch { }
                    })
                    );
            }

GPS在谷歌地图上给出错误的位置

我认为问题在于您将秒转换为度

latt += double.Parse(lat.Substring(5)) / 3600.0/100.0;

您只需要将"秒"部分除以 3600

latt += double.Parse(lat.Substring(5)) / 3600.0;
lonn += double.Parse(lon.Substring(6)) / 3600.0;

您可能已经知道的另一件事是,如果纬度值在南侧,则纬度值为负,而西侧的经度值为负。否则,您的位置可能会出现在地球的错误一侧。