在winforms中向gmap添加多个标记 [英] Adding multiple markers to gmap in winforms

查看:89
本文介绍了在winforms中向gmap添加多个标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I am trying to plot custom markers on lat-lon points read from a csv file

But I am not able to get my code to work: it either adds just the first marker or the last

Could you please have a look and tell me where i am getting it wrong?

   markers = new GMapOverlay("markers");
                 while ((line = sr.ReadLine()) != null)
                {
                    string[] parts = line.Split(',');
                    var p = parts;
                    Double.TryParse(parts[3],out lat);
                    Double.TryParse(parts[4], out lon);
                    GMapMarker marker = new GMarkerGoogle(new PointLatLng(lat, lon), new Bitmap("..\\..\\Resources\\arp.jpg"));
                    
                    marker.ToolTipText = new PointLatLng(lat,lon).ToString();
                     
                    marker.IsVisible = true;

                    markers.Markers.Add(marker);
                    navDataMap.Overlays.Add(markers);

 

                }

//adds just first marker

                markers = new GMapOverlay("markers");
                 while ((line = sr.ReadLine()) != null)
                {
                    string[] parts = line.Split(',');
                    var p = parts;
                    Double.TryParse(parts[3],out lat);
                    Double.TryParse(parts[4], out lon);
                    GMapMarker marker = new GMarkerGoogle(new PointLatLng(lat, lon), new Bitmap("..\\..\\Resources\\arp.jpg"));
                    
                    marker.ToolTipText = new PointLatLng(lat,lon).ToString();
                     
                    marker.IsVisible = true;

                    markers.Markers.Add(marker);
                    //navDataMap.Overlays.Add(markers);

 

                }
                navDataMap.Overlays.Add(markers);

//adds just last marker

Thank you





我尝试了什么:



所有stackoverflow解决方案



What I have tried:

all the stackoverflow solutions

推荐答案

所有你需要的做的是调试你的代码。逐行逐步查看发生了什么。我们无法运行您的代码,因此我们无法为您执行此操作。我们不应该。调试代码是开发人员可以拥有的最重要的工具。



如果只加1,那么你的循环可能无效。但只有你能弄清楚为什么我们无法运行你的代码。
All you have to do is debug your code. Step through it line by line and see what is happening. We can't run your code so we can't do this for you. And we shouldn't. Debugging code is the most important tool a developer can have.

If it is only adding 1 then your loop is likely not working. But only you can figure out why since we can't run your code.


这篇关于在winforms中向gmap添加多个标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆