地霉素ap学习笔记,两学生机勃勃做学习笔记

来源:http://www.pykjg.com 作者:一分快三官网 人气:100 发布时间:2019-11-07
摘要:罗红霉素ap学习笔记,两学意气风发做读书笔记 GMap学习笔记 1、林大霉素ap类别详细明白  What is the  map control  ( GMapControl )?This is the control which renders the map.   What is an  Overlay  ( GMapO

罗红霉素ap学习笔记,两学意气风发做读书笔记

GMap学习笔记

1、林大霉素ap类别详细明白

  •  What is the map control (GMapControl)? This is the control which renders the map. 
  •  What is an Overlay (GMapOverlay)? This is a layer on top of the map control. You can have several layers on top of a map, each layer representing, say, a route with stops, a list    of stores etc.
  •  What are Markers (GMapMarker)? These are the points on a layer, each representing a specific geo location (Lat,Lon) e.g. each drop point on a route.
  • What is a route (GMapRoute)? This is the path or direction between two or more poin

 

 

 

 

 

 

 

 

 

 

 

2、c# 使用克林霉素ap 完结具体的功能(加载地图、放大、减少、鹰眼、增多点线面、自定义marker、截图、下载缓存卡塔尔国

     注:添加GMap.NET.Core.dll 和 GMap.NET.WindowsForms.dll文件,引用后接纳欧霉素ap的控件。

 2.1 加载地图

这里直接调用了SuperMap iServer REST服务。调用第三方地图服务仿效

 2.2 放大、缩短地图

图片 1

private void tsbZoomIn_Click(object sender, EventArgs e)
{
this.mapControl1.Zoom += 1;
}

private void tsbZoomOut_Click(object sender, EventArgs e)
{
this.mapControl1.Zoom -= 1;
}

//定义的地图控件缩放变化后对应的事件

private void mapControl1_OnMapZoomChanged()
{
double zoom = this.mapControl1.Zoom - Convert.ToDouble(5);
this.mapControl2.Zoom = zoom; //设置地图缩放大小

}

View Code

 2.3 鹰眼

亟需2个地图控件,同一时候缩放、移动,实现联合浮动的功力。

图片 2

gMapControl1 事件设置代码:

图片 3

private bool Mapleft1 = false;
private void gMapControl1_MouseDown(object sender, MouseEventArgs e)
{
    if (e.Button == MouseButtons.Left)
    {
        Mapleft1 = true;
    }
}

private void gMapControl1_MouseUp(object sender, MouseEventArgs e)
{
    if (e.Button == MouseButtons.Left)
    {
        Mapleft1 = false;
    }
}

private void gMapControl1_OnPositionChanged(PointLatLng point)
{
    if (Mapleft1)
    {
        this.gMapControl2.Position = point; //设置小地图中心点
    }
}
private void gMapControl1_OnMapZoomChanged()
{
    double zoom = this.gMapControl1.Zoom - Convert.ToDouble(5);
    this.gMapControl2.Zoom = zoom; //设置地图缩放大小
}

View Code

gMapControl2 事件设置代码:

图片 4

private bool Mapleft2 = false;
private void gMapControl2_MouseMove(object sender, MouseEventArgs e)
{
    lastPosition1 = this.gMapControl1.FromLocalToLatLng(e.X, e.Y);
}

private void gMapControl2_MouseUp(object sender, MouseEventArgs e)
{
    if (e.Button==MouseButtons.Left)
    {
        Mapleft2 = false;
    }
}

private void gMapControl2_MouseDown(object sender, MouseEventArgs e)
{
    if (e.Button == MouseButtons.Left)
    {
        this.gMapControl1.Position = lastPosition1; //鼠标单击设置gMapControl1.中心点
        Mapleft2 = true;
    }
}

private void gMapControl2_OnPositionChanged(PointLatLng point)
{
    if (Mapleft2)
    {
        this.gMapControl1.Position = point; //设置gMapControl1中心点
    }
}

View Code

 2.4 增多点线面

以加多点对象为例:

图片 5

IAction _editAddAlarmAction = null;

        //添加告警源
        private void tsbAddAlarm_Click_1(object sender, EventArgs e)
        {
            if (_editAddAlarmAction == null)
            {
                _editAddAlarmAction = new AddAlarmAction();
            }
            this.mapControl1.CurrentAction = _editAddAlarmAction;
            ToolCheckChanged((sender as ToolStripItem).Name);
        }

View Code 图片 6

  public class AddAlarmAction : Action
    {

        List<Feature> targetFeatures = null;


        private GMapControl _gMapControl = null;
        private GMapOverlay markerOverlay = new GMapOverlay("addalarm");
        private bool _start = false;
        List<PointLatLng> _points = null;
        List<Point2D> _point2Ds = new List<Point2D>();
        private string _mapUrl = string.Empty;
        private string _mapName = string.Empty;
        Map _map = null;

        public override void OnLoad(GMapControl gMapControl)
        {
            _gMapControl = gMapControl;
            _gMapControl.Overlays.Add(markerOverlay);
            _points = new List<PointLatLng>();
            _start = false;
            this._mapUrl = ((SuperMapProvider)gMapControl.MapProvider).ServiceUrl;
            this._mapName = ((SuperMapProvider)gMapControl.MapProvider).MapName;
            this._map = new Map(this._mapUrl);
        }
        public override void OnMapMouseDown(object sender, MouseEventArgs e)
        {
            PointLatLng currentPoint = this._gMapControl.FromLocalToLatLng(e.X, e.Y);
            double mercatorX, mercatorY;
            Helper.LonLat2Mercator(currentPoint.Lng, currentPoint.Lat, out mercatorX, out mercatorY);
            Point2D point2D = new Point2D(mercatorX, mercatorY);

            _point2Ds.Add(point2D);
            _points.Add(currentPoint);
            if (_start)
            {
                GMapMarker marker = new GMapMarkerImage(currentPoint, new Bitmap("C:\Users\yaohui\Desktop\iClient-for-DotNet-master\iClient-for-DotNet-master\Demo\demo.winform\Resources\sign-warning-icon.png"));
                markerOverlay.Markers.Add(marker);
                marker.ToolTipText = "告警源编号:";
                marker.ToolTip.Fill = Brushes.Blue;
                marker.ToolTip.Foreground = Brushes.White;
                marker.ToolTip.Stroke = Pens.Black;
                marker.ToolTip.TextPadding = new Size(20, 20);
                marker.ToolTipMode = MarkerTooltipMode.OnMouseOver;
            }
            _start = true;

        }
        public override void OnMapMouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (!_start) return;
            PointLatLng currentPoint = this._gMapControl.FromLocalToLatLng(e.X, e.Y);
            double mercatorX, mercatorY;
            Helper.LonLat2Mercator(currentPoint.Lng, currentPoint.Lat, out mercatorX, out mercatorY);
            Point2D point2D = new Point2D(mercatorX, mercatorY);
            markerOverlay.Markers.Clear();
            _points.Clear();
            _point2Ds.Clear();
            _start = false;
        }

    }

View Code

 2.5 自定义marker

 通过持续gmap的marker类,举办增添:(这里增多了符号高亮的画笔卡塔 尔(阿拉伯语:قطر‎

图片 7

using GMap.NET.WindowsForms;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;



namespace gmap.demo.winform
{
    class GMapMarkerImage : GMapMarker
    {
        private Image image;
        public Image Image
        {
            get
            {
                return image;
            }
            set
            {
                image = value;
                if (image != null)
                {
                    this.Size = new Size(image.Width, image.Height);
                }
            }
        }

        public bool IsHighlight = true;
        public Pen HighlightPen
        {
            set;
            get;
        }

        public Pen FlashPen
        {
            set;
            get;
        }
        public Pen OutPen
        {
            get;
            set;
        }
        private Timer flashTimer = new Timer();

        private int radius;
        private int flashRadius;

        public GMapMarkerImage(GMap.NET.PointLatLng p, Image image)
            : base(p)
        {
            Size = new System.Drawing.Size(image.Width, image.Height);
            Offset = new System.Drawing.Point(-Size.Width / 2, -Size.Height / 2);
            Image = image;
            HighlightPen = new System.Drawing.Pen(Brushes.Red, 2);
            radius = Size.Width >= Size.Height ? Size.Width : Size.Height;
            flashTimer.Interval = 10;
            flashTimer.Tick += new EventHandler(flashTimer_Tick);
        }

        void flashTimer_Tick(object sender, EventArgs e)
        {
            if (FlashPen == null)
            {
                FlashPen = new Pen(Brushes.Red, 3);
                flashRadius = radius;
            }
            else
            {
                flashRadius += radius / 4;
                if (flashRadius >= 2 * radius)
                {
                    flashRadius = radius;
                    FlashPen.Color = Color.FromArgb(255, Color.Red);
                }
                else
                {
                    Random rand = new Random();
                    int alpha = rand.Next(255);
                    FlashPen.Color = Color.FromArgb(alpha, Color.Red);
                }
            }
        }
        //this.Overlay.Control.Refresh();
        //this.mapControl1.Refresh();

        public void StartFlash()
        {
            flashTimer.Start();
        }
        public void StopFlash()
        {
            flashTimer.Stop();
            if (FlashPen != null)
            {
                FlashPen.Dispose();
                FlashPen = null;
            }
        }
        //this.mapControl1.Refresh();

        public override void OnRender(Graphics g)
        {
            if (image == null)
                return;

            Rectangle rect = new Rectangle(LocalPosition.X, LocalPosition.Y, Size.Width, Size.Height);
            g.DrawImage(image, rect);

            if (IsMouseOver && IsHighlight)
            {
                g.DrawRectangle(HighlightPen, rect);
            }

            if (FlashPen != null)
            {
                g.DrawEllipse(FlashPen,
                    new Rectangle(LocalPosition.X - flashRadius / 2 + Size.Width / 2, LocalPosition.Y - flashRadius / 2 + Size.Height / 2, flashRadius, flashRadius));
            }
        }
        //public override void Dispose()
        //{
        //    if (HighlightPen != null)
        //    {
        //        HighlightPen.Dispose();
        //        HighlightPen = null;
        //    }
        //    if (FlashPen != null)
        //    {
        //        FlashPen.Dispose();
        //        FlashPen = null;
        //    }
        //}
    }
}

View Code

 2.6 截图

图片 8

//地图保存为图片
        private void toolStripButton6_Click(object sender, EventArgs e)
        {
            try
            {
                using (SaveFileDialog dialog = new SaveFileDialog())
                {
                    dialog.Filter = "PNG (*.png)|*.png";
                    dialog.FileName = "GMap.NET image";
                    Image image = this.mapControl1.ToImage();
                    if (image != null)
                    {
                        using (image)
                        {
                            if (dialog.ShowDialog() == DialogResult.OK)
                            {
                                string fileName = dialog.FileName;
                                if (!fileName.EndsWith(".png", StringComparison.OrdinalIgnoreCase))
                                {
                                    fileName += ".png";
                                }
                                image.Save(fileName);
                                MessageBox.Show("图片已保存: " + dialog.FileName, "GMap.NET", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                            }
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show("图片保存失败: " + exception.Message, "GMap.NET", MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
        }

View Code

 2.7 保存缓存

图片 9

        //保存缓存
        private void toolStripButton7_Click(object sender, EventArgs e)
        {
            if (this.mapControl1.ShowExportDialog() == true)
            {
                //this.gMapControl1.ShowTileGridLines = true;//显示瓦片,也就是显示方格
                this.mapControl1.ReloadMap();
            }
        }

View Code

 

3、iclient for .net 模拟B/S完成报告急察方闪烁demo呈现

图片 10

 

4、参考

 

土霉素ap学习笔记 1、克林霉素ap体系精解 What is the map control ( 螺旋霉素apControl )? This is the control which renders the map. What is an Ove...

本文由一分快三平台发布于一分快三官网,转载请注明出处:地霉素ap学习笔记,两学生机勃勃做学习笔记

关键词:

最火资讯