Ejemplo n.º 1
0
        void MapControl_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (isEnable && isStarted && lastPointLatLng != PointLatLng.Empty)
            {
                PointLatLng p   = MapControl.FromLocalToLatLng(e.X, e.Y);
                double      x   = p.Lng - lastPointLatLng.Lng;
                double      y   = p.Lat - lastPointLatLng.Lat;
                double      dis = GMapHelper.GetDistanceInMeter(p, lastPointLatLng);
                double      sum = distanceList.Sum();
                dis += sum;
                string s = string.Format("总长:{0:0.00}米", dis);
                //this.toolTip.Show(s, this.MapControl);
                this.toolTip.SetToolTip(this.MapControl, s);

                tempLine.EndPoint = p;
                this.MapControl.UpdateMarkerLocalPosition(tempLine);
                this.MapControl.Refresh();
            }
        }
Ejemplo n.º 2
0
        private void MapControl_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Left && !isStarted && isEnable)
            {
                isStarted           = true;
                this.toolTip.Active = true;
                PointLatLng        p      = MapControl.FromLocalToLatLng(e.X, e.Y);
                DrawDistanceMarker marker = new DrawDistanceMarker(p, "起点");
                tempOverlay.Markers.Add(marker);
                lastPointLatLng = p;

                tempLine = new TempLineMarker(p, p);
                tempOverlay.Markers.Add(tempLine);
            }
            else if (e.Button == MouseButtons.Left && isStarted && isEnable)
            {
                PointLatLng p = MapControl.FromLocalToLatLng(e.X, e.Y);

                double x   = p.Lng - lastPointLatLng.Lng;
                double y   = p.Lat - lastPointLatLng.Lat;
                double dis = GMapHelper.GetDistanceInMeter(p, lastPointLatLng);
                distanceList.Add(dis);
                double sum = distanceList.Sum();
                string s   = string.Format("{0:0.00}米", sum);

                DrawDistanceMarker marker = new DrawDistanceMarker(p, s);
                tempOverlay.Markers.Add(marker);

                LineMarker line = new LineMarker(new PointLatLng(lastPointLatLng.Lat, lastPointLatLng.Lng), p);
                tempOverlay.Markers.Add(line);

                if (tempOverlay.Markers.Contains(tempLine))
                {
                    tempOverlay.Markers.Remove(tempLine);
                }
                tempLine = new TempLineMarker(p, p);
                tempOverlay.Markers.Add(tempLine);

                lastPointLatLng = p;
            }
        }