Exemplo n.º 1
0
 void gmap_OnMarkerClick(GMapMarker item, MouseEventArgs e)
 {
     if (item is GMapMarkerImage)
     {
         currentMarker = null;
         GMapMarkerImage m      = item as GMapMarkerImage;
         String          info_i = "设备编号:" + m.id;
         info_i += "\n设备名称:" + m.machine_name;
         info_i += "\n设备位置:" + m.location;
         info_i += "\n安装时间:" + m.install_time;
         info_i += "\n位置经度:" + m.longitude;
         info_i += "\n位置纬度:" + m.latitude;
         MessageBox.Show(info_i);
     }
     //String message = "marker was clicked(经度:" + item.Position.Lng + ", 纬度:" + item.Position.Lat + ")" ;
     //MessageBox.Show(message);
 }
Exemplo n.º 2
0
        private void gmap_Load(object sender, EventArgs e)
        {
            // Initialize map:    
            gmap.MapProvider             = GMap.NET.MapProviders.GoogleChinaMapProvider.Instance;
            GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.ServerOnly;
            gmap.MinZoom    = 2;                                //最小缩放
            gmap.MaxZoom    = 17;                               //最大缩放
            gmap.Zoom       = 5;                                //当前缩放
            gmap.ShowCenter = false;                            //不显示中心十字点
            gmap.Position   = new PointLatLng(32.064, 118.704); //地图中心位置:南京
            GMapOverlay objects = new GMapOverlay("objects");   //放置marker的图层
            int         len     = m_list.Length;

            for (int cnt = 0; cnt < len; ++cnt)
            {
                Bitmap bitmap = Bitmap.FromFile("C:\\Users\\dell\\Documents\\Visual Studio 2010\\Projects\\WindowsFormsApplication6\\WindowsFormsApplication6\\images\\water1.png") as Bitmap;
                //GMarkerGoogle marker = new GMarkerGoogle(new PointLatLng(m_list[cnt].longitude, m_list[cnt].latitude), bitmap);
                GMapMarkerImage marker = new GMapMarkerImage(new PointLatLng(m_list[cnt].longitude, m_list[cnt].latitude), bitmap);
                marker.id           = m_list[cnt].id;
                marker.machine_name = m_list[cnt].machine_name;
                marker.location     = m_list[cnt].location;
                marker.install_time = m_list[cnt].install_time;
                marker.longitude    = m_list[cnt].longitude;
                marker.latitude     = m_list[cnt].latitude;
                objects.Markers.Add(marker);
            }
            gmap.Overlays.Add(objects);


            GMapOverlay        polyOverlay = new GMapOverlay("polygons");
            List <PointLatLng> points      = new List <PointLatLng>();

            points.Add(new PointLatLng(32.064, 118.704));
            points.Add(new PointLatLng(33.067, 118.707));
            points.Add(new PointLatLng(34.070, 120.710));
            points.Add(new PointLatLng(31.073, 119.713));
            GMapPolygon polygon = new GMapPolygon(points, "mypolygon");

            polygon.Fill   = new SolidBrush(Color.FromArgb(50, Color.Red));
            polygon.Stroke = new Pen(Color.Red, 1);
            polyOverlay.Polygons.Add(polygon);
            gmap.Overlays.Add(polyOverlay);

            gmap.OnMarkerClick += new MarkerClick(gmap_OnMarkerClick);
            gmap.OnMarkerEnter += new MarkerEnter(gmap_OnMarkerEnter);
        }
Exemplo n.º 3
0
        void gmap_OnMarkerEnter(GMapMarker item)
        {
            if (item is GMapMarkerImage)
            {
                currentMarker = null;
                GMapMarkerImage m      = item as GMapMarkerImage;
                String          info_i = "设备编号:" + m.id;
                info_i += "\n设备名称:" + m.machine_name;
                info_i += "\n设备位置:" + m.location;
                info_i += "\n安装时间:" + m.install_time;
                info_i += "\n位置经度:" + m.longitude;
                info_i += "\n位置纬度:" + m.latitude;
                this.toolTip1.SetToolTip(this.gmap, info_i);
            }

            //String info = item.Position.Lat + " " + item.Position.Lng;
            //this.toolTip1.SetToolTip(this.gmap, info);
        }
        private void gmap_Load(object sender, EventArgs e)
        {
            // Initialize map:
            gmap.MapProvider = GMap.NET.MapProviders.GoogleChinaMapProvider.Instance;
            GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.ServerOnly;
            gmap.MinZoom = 2;  //最小缩放
            gmap.MaxZoom = 17; //最大缩放
            gmap.Zoom = 5;     //当前缩放
            gmap.ShowCenter = false; //不显示中心十字点
            gmap.Position = new PointLatLng(32.064, 118.704); //地图中心位置:南京
            GMapOverlay objects = new GMapOverlay("objects"); //放置marker的图层
            int len = m_list.Length;
            for (int cnt = 0; cnt < len; ++cnt)
            {
                Bitmap bitmap = Bitmap.FromFile("C:\\Users\\dell\\Documents\\Visual Studio 2010\\Projects\\WindowsFormsApplication6\\WindowsFormsApplication6\\images\\water1.png") as Bitmap;
                //GMarkerGoogle marker = new GMarkerGoogle(new PointLatLng(m_list[cnt].longitude, m_list[cnt].latitude), bitmap);
                GMapMarkerImage marker = new GMapMarkerImage(new PointLatLng(m_list[cnt].longitude, m_list[cnt].latitude), bitmap);
                marker.id = m_list[cnt].id;
                marker.machine_name = m_list[cnt].machine_name;
                marker.location = m_list[cnt].location;
                marker.install_time = m_list[cnt].install_time;
                marker.longitude = m_list[cnt].longitude;
                marker.latitude = m_list[cnt].latitude;
                objects.Markers.Add(marker);
            }
            gmap.Overlays.Add(objects);

            GMapOverlay polyOverlay = new GMapOverlay("polygons");
            List<PointLatLng> points = new List<PointLatLng>();
            points.Add(new PointLatLng(32.064, 118.704));
            points.Add(new PointLatLng(33.067, 118.707));
            points.Add(new PointLatLng(34.070, 120.710));
            points.Add(new PointLatLng(31.073, 119.713));
            GMapPolygon polygon = new GMapPolygon(points, "mypolygon");
            polygon.Fill = new SolidBrush(Color.FromArgb(50, Color.Red));
            polygon.Stroke = new Pen(Color.Red, 1);
            polyOverlay.Polygons.Add(polygon);
            gmap.Overlays.Add(polyOverlay);

            gmap.OnMarkerClick += new MarkerClick(gmap_OnMarkerClick);
            gmap.OnMarkerEnter += new MarkerEnter(gmap_OnMarkerEnter);
        }
        void gmap_OnMarkerEnter(GMapMarker item)
        {
            if (item is GMapMarkerImage)
            {
                currentMarker = null;
                GMapMarkerImage m = item as GMapMarkerImage;
                String info_i = "设备编号:" + m.id;
                info_i += "\n设备名称:" + m.machine_name;
                info_i += "\n设备位置:" + m.location;
                info_i += "\n安装时间:" + m.install_time;
                info_i += "\n位置经度:" + m.longitude;
                info_i += "\n位置纬度:" + m.latitude;
                this.toolTip1.SetToolTip(this.gmap, info_i);
            }

            //String info = item.Position.Lat + " " + item.Position.Lng;
            //this.toolTip1.SetToolTip(this.gmap, info);
        }
 void gmap_OnMarkerClick(GMapMarker item, MouseEventArgs e)
 {
     if (item is GMapMarkerImage)
     {
         currentMarker = null;
         GMapMarkerImage m = item as GMapMarkerImage;
         String info_i = "设备编号:" + m.id;
         info_i += "\n设备名称:" + m.machine_name;
         info_i += "\n设备位置:" + m.location;
         info_i += "\n安装时间:" + m.install_time;
         info_i += "\n位置经度:" + m.longitude;
         info_i += "\n位置纬度:" + m.latitude;
         MessageBox.Show(info_i);
     }
     //String message = "marker was clicked(经度:" + item.Position.Lng + ", 纬度:" + item.Position.Lat + ")" ;
     //MessageBox.Show(message);
 }