示例#1
2
        public double getDistance(PointLatLng p1, PointLatLng p2)
        {
            GMapRoute route = new GMapRoute("getDistance");
            route.Points.Add(p1);
            route.Points.Add(p2);
            double distance = route.Distance;
            route.Clear();
            route = null;

            return distance;
        }
 public GMapMarkerTarget(PointLatLng p, GMapControl map, Bitmap icon)
     : base(p)
 {
     Size = SizeSt;
     MainMap = map;
     this.icon = icon;
 }
示例#3
1
        private void addPIN(PointLatLng point)
        {
            GMapOverlay markersOverlay = new GMapOverlay(gmap, "marker");
            this.marker = new GMapMarkerGoogleRed(point);
            markersOverlay.Markers.Add(marker);
            gmap.Overlays.Add(markersOverlay);

            marker.ToolTipText = this.article.mLink;
            marker.ToolTipMode = MarkerTooltipMode.Never;
        }
示例#4
0
 public GMapMarkerBDZ(PointLatLng p)
     : base(p) {
     Size = SizeSt = new Size(20, 20);
     Offset = new Point(-10, -10);
     Text = string.Empty;
     mFont = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Bold);
 }
示例#5
0
 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);
     this.image = image;
 }
示例#6
0
 public FeedMarker(PointLatLng loc, Article art, GMapControl gmap)
 {
     location = loc;
     article = art;
     this.gmap = gmap;
     addPIN(location);
 }
 public GMapCustomImageMarkerYellow(PointLatLng p)
     : base(p)
 {
     image = Image.FromFile("img/point_y.png");
     Size = new System.Drawing.Size(image.Width, image.Height);
     Offset = new Point( - (image.Width / 2), - (image.Height / 2));
 }
示例#8
0
 public GMapMarkerBYQ(PointLatLng p)
     : base(p) {
     Size=SizeSt = new Size(15, 10);
     Offset = new Point(-7, -5);
     Text = string.Empty;
     mFont = new Font(FontFamily.GenericSansSerif, 8, FontStyle.Bold);
 }
        public static GMapMarker FindNearestMarker(this Collection<GMapMarker> source, PointLatLng point, Func<PointLatLng, PointLatLng, double> getDistance)
        {
            GMapMarker nearestMarker = null;
            double smallestDistance = double.PositiveInfinity;
            foreach (var marker in source)
            {
                if (marker.Position != point)
                {
                    var distance = getDistance(marker.Position, point);
                    if (distance < smallestDistance)
                    {
                        smallestDistance = distance;
                        nearestMarker = marker;
                    }
                }
            }

            if(double.IsPositiveInfinity(smallestDistance))
            {
                return null;
            }
            else
            {
                return nearestMarker;
            }
        }
示例#10
0
 public GMapMarkerGzbx(PointLatLng p)
     : base(p) {
     Image = Resources.marker;
     ImageShadow = Resources.shadow50;
     Size = SizeSt = new Size(Image.Width, Image.Height);
     Offset = new Point(-10, -34);
 }
示例#11
0
 public GMapMarkerRect(PointLatLng p)
     : base(p)
 {
     Pen.DashStyle = DashStyle.Dot;
     Size = new System.Drawing.Size(50, 50);
     Offset = new System.Drawing.Point(-Size.Width / 2, -Size.Height / 2 - 20);
 }
示例#12
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="p">The position of the marker</param>
 public CustomMarker(PointLatLng p, Image image)
     : base(p)
 {
     img = image;
     Size = img.Size;
     Offset = new System.Drawing.Point(-Size.Width / 2, -Size.Height / 2);
 }
        private void button1_Click_1(object sender, EventArgs e)
        {
            double lat1 = Double.Parse(textBox_latitude1.Text);
            double lon1 = Double.Parse(textBox_longitude1.Text);
            double lat2 = Double.Parse(textBox_latitude2.Text);
            double lon2 = Double.Parse(textBox_longitude2.Text);
            double lat3 = Double.Parse(textBox_latitude3.Text);
            double lon3 = Double.Parse(textBox_longitude3.Text);
            double lat4 = Double.Parse(textBox_latitude4.Text);
            double lon4 = Double.Parse(textBox_longitude4.Text);
            PointLatLng p1 = new PointLatLng(lat1, lon1);
            PointLatLng p2 = new PointLatLng(lat2, lon2);
            PointLatLng p3 = new PointLatLng(lat3, lon3);
            PointLatLng p4 = new PointLatLng(lat4, lon4);
            FlightPlanner.instance.polygongridmode = true;
            FlightPlanner.instance.drawnpolygon.Points.Add(p1);
            FlightPlanner.instance.drawnpolygon.Points.Add(p2);
            FlightPlanner.instance.drawnpolygon.Points.Add(p3);
            FlightPlanner.instance.drawnpolygon.Points.Add(p4);
            FlightPlanner.instance.drawnpolygonsoverlay.Polygons.Add(FlightPlanner.instance.drawnpolygon);


            /*List<PointLatLng> points = new List<PointLatLng>();
            PointLatLng p1 = new PointLatLng(lat1, lon1);
            PointLatLng p2 = new PointLatLng(lat2, lon2);
            PointLatLng p3 = new PointLatLng(lat3, lon3);
            PointLatLng p4 = new PointLatLng(lat4, lon4);
            points.Add(p1);
            points.Add(p2);
            points.Add(p3);
            points.Add(p4);
            GMap.NET.WindowsForms.GMapPolygon test = new GMap.NET.WindowsForms.GMapPolygon(points, "yolo");
            test.IsVisible = true;*/
        }
示例#14
0
        private Image img; /// <summary>

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="p">The position of the marker</param>
        public GMapMarkerImage(PointLatLng p, Image image)
            : base(p)
        {
            img = image;
            Size = img.Size;
            Offset = new System.Drawing.Point(-Size.Width, Size.Height / 7);
        }
示例#15
0
        public void Build_Prediction_Marker(PointLatLng Base_Position, string ACID, MySqlProvider.PredictionTableNumberType Table_Type, ref GMapOverlay Overlay)
        {
            MySqlProvider SqlProvider = new MySqlProvider();
            System.Collections.Generic.List<MySqlProvider.PredictionDataSetOneRow> Record = SqlProvider.GetOneRecordPerTimeAndACID(Table_Type, SharedData.LookAheadTime, ACID, false);

            // If prediction data for the given parameters exists
            // then lets add it to the display list.
            if (Record.Count > 0)
            {
                GeoCordSystemDegMinSecUtilities.LatLongClass P_Pont = new GeoCordSystemDegMinSecUtilities.LatLongClass(double.Parse(Record[0].Lat), double.Parse(Record[0].Lon));

                PointLatLng PredictedPoint = new PointLatLng(P_Pont.GetLatLongDecimal().LatitudeDecimal, P_Pont.GetLatLongDecimal().LongitudeDecimal);
                PredictionMarker PM;

                string label = Record[0].ACID + "\n" + Record[0].Time.ToShortTimeString();

                switch (Table_Type)
                {
                    case MySqlProvider.PredictionTableNumberType.One:
                        PM = new PredictionMarker(Base_Position, Color.Magenta, PredictedPoint, label);
                        Overlay.Markers.Add(PM);
                        break;
                    case MySqlProvider.PredictionTableNumberType.Two:
                        PM = new PredictionMarker(Base_Position, Color.Blue, PredictedPoint, label);
                        Overlay.Markers.Add(PM);
                        break;
                    case MySqlProvider.PredictionTableNumberType.Three:
                        PM = new PredictionMarker(Base_Position, Color.Orange, PredictedPoint, label);
                        Overlay.Markers.Add(PM);
                        break;
                }
            }
        }
示例#16
0
        public void MapFieldBoundaries(double lat, double lng)
        {
            //--- Check if this is the First point of a new Area
            if (View.CreateIsNewField)
            {
                CurrentFieldPoints    = new List <PointLatLng>();
                View.CreateIsNewField = false;
            }
            CurrentFieldPoints.Add(new PointLatLng(lat, lng));

            var closedList = CurrentFieldPoints;

            closedList.Add(new PointLatLng(CurrentFieldPoints[0].Lat, CurrentFieldPoints[0].Lng));

            var polygon = new GMapPolygon(closedList, "New Field");

            Polygons.Polygons.Add(polygon);
            closedList.RemoveAt(closedList.Count - 1);

            var pnt    = new GMap.NET.PointLatLng(lat, lng);
            var marker = new GMap.NET.WindowsForms.Markers.GMarkerGoogle(pnt, GMap.NET.WindowsForms.Markers.GMarkerGoogleType.green_dot);

            PushPins.Markers.Add(marker);

            var grid = View.CurrentWorkspace.CurrentDefineView.GridLatLongPoints;

            grid.Rows.Add(grid.RowCount + 1, lat, lng);
            //polygons.Polygons.Add(polygon);
            //gmap.Overlays.Add(polygons);
        }
示例#17
0
 public RectLatLng(PointLatLng location, SizeLatLng size)
 {
     this.lng = location.Lng;
      this.lat = location.Lat;
      this.widthLng = size.WidthLng;
      this.heightLat = size.HeightLat;
 }
示例#18
0
         /// <summary>
         /// 创建线路杆塔点标记
         /// </summary>
         /// <param name="LineCode"></param>
         /// <returns></returns>
         static public List<GMapMarkerVector> BuildLineGT(string LineCode, string LineName) {
             IList<PS_gt> list = Client.ClientHelper.PlatformSqlMap.GetList<PS_gt>(string.Format("where Linecode='{0}' order by gtcode", LineCode));

             List<GMapMarkerVector> markers = new List<GMapMarkerVector>();
             GMapMarkerVector marker = null;
             GMapMarkerVector preMarker = null;
             foreach (PS_gt gt in list) {
                 PointF pf = new PointF((float)gt.gtLon, (float)gt.gtLat);
                 if (box.Contains(pf)) {
                     PointLatLng point = new PointLatLng(Convert.ToDouble(gt.gtLat), Convert.ToDouble(gt.gtLon));
                     if (gt.gtType.Contains("方杆")) 
                         marker = new GMapMarkerRect(point);
                     else
                         marker = new GMapMarkerVector(point);
                     if (preMarker != null) {
                         marker.ParentMarker = preMarker;
                         preMarker.NextMarker = marker;
                     }
                     preMarker = marker;
                     marker.ToolTipText = gt.gth + "\n" + LineName;
                     marker.Tag = gt;

                     markers.Add(marker);
                 }
             }

             return markers;
         }
示例#19
0
        /// <summary>
        /// Creates the map marker and adds it to the map
        /// </summary>
        public void CreateMapMarker(PointLatLng point, string tooltip)
        {
            GMarkerGoogle marker = new GMarkerGoogle(point, GMarkerGoogleType.red);
            marker.ToolTipText = tooltip;

            gmap.Overlays[0].Markers.Add(marker);
            gmap.UpdateMarkerLocalPosition(marker);
        }
示例#20
0
 public CustomMarker(GMap.NET.PointLatLng p, int id, Int64 colorGround = 0xFF006400, Int64 colorId = 0xFFFFFFFF) : base(p)
 {
     brushGround = new SolidBrush(Color.FromArgb((int)((colorGround >> 24) & 0xFF), (int)((colorGround >> 16) & 0xFF), (int)((colorGround >> 8) & 0xFF), (int)(colorGround & 0xFF)));
     brushId     = new SolidBrush(Color.FromArgb((int)(colorId >> 24), (int)((colorId >> 16) & 0xFF), (int)((colorId >> 8) & 0xFF), (int)(colorId & 0xFF)));
     ID          = id;
     Size        = new System.Drawing.Size(20, 20);    //标记绘制区域的大小
     Offset      = new System.Drawing.Point(-10, -10); //标记矩形左上角与指定点的偏移
 }
        public GMapTextMarker(GMap.NET.PointLatLng p, string tipText)
            : base(p)
        {
            //Size = new System.Drawing.Size(image.Width, image.Height);
            //Offset = new System.Drawing.Point(-st/2, 0);

            TipText = tipText;
        }
示例#22
0
 public GMapMarkerVector(PointLatLng p)
     : base(p) {
     Size = SizeSt;
     Offset = new Point(-2, -2);
     Pen = new Pen(Color.Blue, 1);
     items = new List<GMapMarkerVector>();
     font = new Font("宋体", 9);
 }
示例#23
0
 public GMapMarkerKG(PointLatLng p)
     : base(p) {
     Size = SizeSt = new Size(8, 6);
     Offset = new Point(-4, -3);
     Text = string.Empty;
     mFont = new Font(FontFamily.GenericSansSerif, 8, FontStyle.Bold);
     Pen = new Pen(Color.Red, 2);
 }
 public void update(PointLatLng point)
 {
     if (tag.Equals(""))
         polygon.Points[int.Parse(host.CurentRectMarker.InnerMarker.Tag.ToString().Replace("grid", "")) - 1] = new PointLatLng(point.Lat, point.Lng);
     else
         polygon.Points[int.Parse(host.CurentRectMarker.InnerMarker.Tag.ToString().Replace(tag, "").Replace("grid", "")) - 1] = new PointLatLng(point.Lat, point.Lng);
     host.MainMap.UpdatePolygonLocalPosition(polygon);
 }
示例#25
0
 public void AddToLogCurrentInfo(PointLatLng data)
 {
     gpsLog[logCounter++] = data;
     if (logCounter == logSize)
     {
         logCounter = 0;
         logFull = true;
     }
 }
示例#26
0
 public GMapMarkerCopter(PointLatLng p, float heading, float cog, float target, byte coptertype)
     : base(p)
 {
     this.heading = heading;
     this.cog = cog;
     this.target = target;
     this.coptertype = coptertype;
     Size = SizeSt;
 }
示例#27
0
 public void ConvertCoordGroundToPixel(double GroundX, double GroundY, ref int PixelX, ref int PixelY)
 {
     GMap.NET.PointLatLng Position = new GMap.NET.PointLatLng();
     Position.Lat = GroundY;
     Position.Lng = GroundX;
     GMap.NET.GPoint p = MyMainMap.FromLatLngToLocal(Position);
     PixelX = (int)p.X;
     PixelY = (int)p.Y;
 }
示例#28
0
 public GMapTipMarker(GMap.NET.PointLatLng p, Image image, string tipText)
     : base(p)
 {
     Size         = new System.Drawing.Size(image.Width, image.Height);
     Offset       = new System.Drawing.Point(-Size.Width / 2, -Size.Height / 2);
     this.image   = image;
     HighlightPen = new System.Drawing.Pen(Brushes.Red, 2);
     TipText      = tipText;
 }
 /// <summary>
 /// get pixel coordinates from lat/lng
 /// </summary>
 /// <param name="p"></param>
 /// <param name="zoom"></param>
 /// <returns></returns>
 public Point FromLatLngToPixel(PointLatLng p, int zoom)
 {
    Point ret = Point.Empty;
    if(!FromLatLngToPixelCache[zoom].TryGetValue(p, out ret))
    {
       ret = FromLatLngToPixel(p.Lat, p.Lng, zoom);
       FromLatLngToPixelCache[zoom].Add(p, ret);
    }
    return ret;
 }
示例#30
0
        public GMapMarkerRect(PointLatLng p)
            : base(p)
        {
            Pen.DashStyle = DashStyle.Dash;

            // do not forget set Size of the marker
            // if so, you shall have no event on it ;}
            Size = new System.Drawing.Size(50, 50);
            Offset = new System.Drawing.Point(-Size.Width/2, -Size.Height/2 - 20);
        }
示例#31
0
        public GMapMarkerRect(PointLatLng p)
            : base(p)
        {
            Pen = new Pen(Brushes.Blue, 5);

            // do not forget set Size of the marker
            // if so, you shall have no event on it ;}
            Size = new System.Drawing.Size(80, 80);
            Offset = new System.Drawing.Point(-Size.Width / 2, -Size.Height / 2);
        }
        public static void AddDefaultGoogleMarker(this Collection<GMapMarker> source, PointLatLng? point, GMarkerGoogleType style, object tag = null)
        {
            if (point != null)
            {
                GMarkerGoogle m = new GMarkerGoogle((PointLatLng)point, style);
                m.ToolTip = new GMapRoundedToolTip(m);
                m.ToolTipMode = MarkerTooltipMode.OnMouseOver;
                m.Tag = tag;

                source.Add(m);
            }
        }
示例#33
0
        //GMapMarker createMarker(PointLatLng pos) {
        //    GMapMarkerVector marker = new GMapMarkerVector(pos);
        //    marker.Pen = new Pen(Color.FromArgb(144, Color.GreenYellow), 2);
        //    marker.IsHitTestVisible = false;
        //    marker.ToolTipMode = MarkerTooltipMode.OnMouseOver;
        //    return marker;
        //}
        GMapMarker createMarker(PointLatLng pos) {
            GMapMarkerVector marker = new GMapMarkerVector(pos);

            marker.Pen = new Pen(Color.FromArgb(144, Color.MidnightBlue), 2);
            marker.IsHitTestVisible = false;
            marker.ToolTipMode = MarkerTooltipMode.OnMouseOver;
            routes.Markers.Add(marker);
            if (routes.Markers.Count > 1)
                marker.ToolTipText = routes.Routes[0].Distance + "";// rMap1.Manager.GetDistance(pos, objects.Markers[objects.Markers.Count - 1].Position) + "";

            return marker;
        }
示例#34
0
 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);
     this.image = image;
     Pen        = null;
     OutPen     = null;
     //this.ToolTipMode = MarkerTooltipMode.OnMouseOver;
     this.ToolTipText  = string.Format("{0}\r\n{1}\r\n{2}\r\n{3}", "CQH8992", "GV:95°", "H:4686m", "S:748km/h");
     this.ToolTip.Fill = new SolidBrush(Color.FromArgb(0, 0, 0, 0));
 }
示例#35
0
 GMapMarker createMarker(PointLatLng pos) {
     GMapMarker marker = null;
     object newobj= Activator.CreateInstance(NewVectorType);
     if (newobj is GMapMarker)
         marker = newobj as GMapMarker;
     if (marker == null) {
         marker = new GMapMarkerVector(pos);
         marker.IsHitTestVisible = false;                
     }
     marker.ToolTipMode = MarkerTooltipMode.OnMouseOver;
     return marker;
 }
        private void example1()
        {
            GMap.NET.PointLatLng start;
            GMap.NET.PointLatLng end;

            //GMap.NET.GDirections gDirections1;
            GMap.NET.WindowsForms.GMapRoute gMapRoute1;
            GMap.NET.WindowsForms.GMapOverlay gMapOverlay1;

            try
            {
                // Luis hard-codes an example start- and end-point,
                // I think I might try to make it dynamic to help me understand it
                // and give me practice with it.
                // However at first to get the code running, I'm going to hard-code it.
                //
                start = new GMap.NET.PointLatLng(46.299106, -119.295999);
                end = new GMap.NET.PointLatLng(46.276860, -119.291511);

                var dirstatcode = GMap.NET.MapProviders.GMapProviders.GoogleMap.GetDirections(out gDirections1,
                                                                                              start, end,
                                                                                              false,  // bool avoidHighways
                                                                                              false, // bool avoidTolls
                                                                                              false, // bool walking mode
                                                                                              false,  // bool sensor
                                                                                              false  // bool metric
                                                                                              );
                gMapRoute1 = new GMap.NET.WindowsForms.GMapRoute(gDirections1.Route, "foo");
                // After trying this, I get an error at the aboe line, saying that gDirections1 was null.
                //
                // Try 1
                // Changed MapProvider to GoogleMapProvider (was BingMapProvider).
                // No difference.
                //
                // Try 2
                // Moved the declaration of "gDirections1" to the entire form.
                // No difference.

                gMapOverlay1 = new GMap.NET.WindowsForms.GMapOverlay(); // string param is optional
                gMapOverlay1.Routes.Add(gMapRoute1);
                //MainMap.Overlays.Add(gMapOverlay1);
                this.gMapControl1.Overlays.Add(gMapOverlay1);

            }
            catch (Exception ex)
            {
                MessageBox.Show("Exception happened, {0}", ex.Message);
            }
        }
        public static GMap.NET.PointLatLng FindPointAtDistanceFrom(GMap.NET.PointLatLng startPoint, double initialBearingRadians, double distanceKilometres)
        {
            const double radiusEarthKilometres = 21000;
            var          distRatio             = distanceKilometres / radiusEarthKilometres;
            var          distRatioSine         = Math.Sin(distRatio);
            var          distRatioCosine       = Math.Cos(distRatio);
            var          startLatRad           = DegreesToRadians(startPoint.Lat);
            var          startLonRad           = DegreesToRadians(startPoint.Lng);
            var          startLatCos           = Math.Cos(startLatRad);
            var          startLatSin           = Math.Sin(startLatRad);
            var          endLatRads            = Math.Asin((startLatSin * distRatioCosine) + (startLatCos * distRatioSine * Math.Cos(initialBearingRadians)));
            var          endLonRads            = startLonRad + Math.Atan2(
                Math.Sin(initialBearingRadians) * distRatioSine * startLatCos,
                distRatioCosine - startLatSin * Math.Sin(endLatRads));

            return(new GMap.NET.PointLatLng(RadiansToDegrees(endLatRads), RadiansToDegrees(endLonRads)));
        }
示例#38
0
        public GMapMarkerImage(GMap.NET.PointLatLng p, Image image)
            : base(p)
        {
            Size        = new System.Drawing.Size(50, 50);
            Offset      = new System.Drawing.Point(-Size.Width / 2, -Size.Height / 2);
            this.image  = image;
            SelectedPen = null;
            AlarmPen    = null;

            //if (!CenterPoint.IsEmpty)
            //{
            //    List<PointLatLng> pointList = new List<PointLatLng>();
            //    pointList.Add(CenterPoint);
            //    pointList.Add(this.Position);
            //    GMapRoute gmr = new GMapRoute(pointList, "tmp gmr");
            //    gmr.Stroke = RoutePen;
            //    Overlay.Routes.Add(gmr);
            //}
        }
示例#39
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            if (Core.IsDragging)
            {
                if (!isDragging)
                {
                    isDragging = true;
                    Debug.WriteLine("IsDragging = " + isDragging);
                }

                if (BoundsOfMap.HasValue && !BoundsOfMap.Value.Contains(Position))
                {
                    // ...
                }
                else
                {
                    Core.mouseCurrent = ApplyRotationInversion(e.X, e.Y);
                    Core.Drag(Core.mouseCurrent);
                    Refresh();
                }
            }
            else
            {
                if (isSelected && !selectionStart.IsEmpty && (Form.ModifierKeys == Keys.Alt || Form.ModifierKeys == Keys.Shift))
                {
                    selectionEnd = FromLocalToLatLng(e.X, e.Y);
                    {
                        GMap.NET.PointLatLng p1 = selectionStart;
                        GMap.NET.PointLatLng p2 = selectionEnd;

                        double x1 = Math.Min(p1.Lng, p2.Lng);
                        double y1 = Math.Max(p1.Lat, p2.Lat);
                        double x2 = Math.Max(p1.Lng, p2.Lng);
                        double y2 = Math.Min(p1.Lat, p2.Lat);

                        SelectedArea = new RectLatLng(y1, x1, x2 - x1, y1 - y2);
                    }
                }
            }

            base.OnMouseMove(e);
        }
示例#40
0
        private PointLatLng FindPointAtDistanceFrom(GMap.NET.PointLatLng startPoint, double initialBearingRadians, double distanceKilometres)
        {
            double radius = 6371.01;

            var δ = distanceKilometres / radius; // angular distance in radians
            var θ = DegreesToRadians(initialBearingRadians);

            var φ1 = DegreesToRadians(startPoint.Lat);
            var λ1 = DegreesToRadians(startPoint.Lng);

            var sinφ2 = Math.Sin(φ1) * Math.Cos(δ) + Math.Cos(φ1) * Math.Sin(δ) * Math.Cos(θ);
            var φ2    = Math.Asin(sinφ2);
            var y     = Math.Sin(θ) * Math.Sin(δ) * Math.Cos(φ1);
            var x     = Math.Cos(δ) - Math.Sin(φ1) * sinφ2;
            var λ2    = λ1 + Math.Atan2(y, x);

            var lat = RadiansToDegrees(φ2);
            var lon = RadiansToDegrees(λ2);

            return(new PointLatLng(lat, lon));
        }
示例#41
0
        private void SearchLocation_old()
        {
            try
            {
                string postCode = txtAddress.Text.Trim();

                if (string.IsNullOrEmpty(postCode))
                {
                    //MessageBox.Show("Please enter a PostCode");
                    MessageBox.Show("Please enter a Address");
                    return;
                }

                //postCode = General.GetPostCodeMatch(postCode);
                var latlng = GetDistance.PostCodeToLongLat(postCode, "GB");

                if (latlng != null)
                {
                    GMap.NET.PointLatLng point = new GMap.NET.PointLatLng(latlng.Value.Latitude, latlng.Value.Longitude);
                    gMapControl1.Position = point;

                    GMapOverlay polyOverlay = new GMapOverlay(gMapControl1, "overlayJob");

                    GMapMarkerCustom marker1 = new GMapMarkerCustom(new PointLatLng(Convert.ToDouble(latlng.Value.Latitude), Convert.ToDouble(latlng.Value.Longitude)), Resources.Resource1.pushpin_PassengerOnBoard);
                    marker1.ToolTipMode = MarkerTooltipMode.Always;
                    marker1.Tag         = new PointLatLng(latlng.Value.Latitude, latlng.Value.Longitude);

                    polyOverlay.Markers.Add(marker1);
                    gMapControl1.Overlays.Clear();
                    gMapControl1.Overlays.Add(polyOverlay);

                    gMapControl1.Zoom = 16;
                }
            }
            catch (Exception ex)
            {
                ENUtils.ShowMessage(ex.Message);
            }
        }
示例#42
0
        /// <summary>
        /// Called on POINTUPDATED_ACK, whenever a point changes
        /// in some other running client. Updates local points respectively
        /// </summary>
        /// <param name="packet"></param>
        private void OnPointUpdatedAck(PointUpdatedAck packet)
        {
            foreach (var polygon in _polygons.Polygons)
            {
                if (!(polygon.Tag is PolyZone zone))
                {
                    continue;
                }
                if (int.Parse(zone.Id) != packet.ZoneId)
                {
                    continue;
                }

                if (packet.Added)
                {
                    var pointLatLng = new GMap.NET.PointLatLng(packet.Lat, packet.Lng);
                    polygon.Points.Insert(packet.Index, pointLatLng);
                    zone.Geometry.Insert(packet.Index, pointLatLng.ToGeometry(packet.PointId));
                }
                else if (packet.Removed)
                {
                    polygon.Points.RemoveAt(packet.Index);
                    zone.Geometry.RemoveAt(packet.Index);
                }
                else
                {
                    var i  = zone.Geometry.FindIndex(x => x.Id == packet.PointId);
                    var pt = new GMap.NET.PointLatLng(packet.Lat, packet.Lng);
                    polygon.Points[i] = pt;
                    zone.Geometry[i]  = pt.ToGeometry(packet.PointId);
                }

                UpdatePolygonLocalPosition(polygon);
                Refresh();
                break;
            }
        }
示例#43
0
        public Map()
        {
            InitializeComponent();
            DisableFocusOnMouseEnter = true;

            _selectedStrokeClr = new Pen(Brushes.Blue)
            {
                Width = 2
            };
            _selecteFillClr  = new SolidBrush(Color.FromArgb(90, Color.Blue));
            _isMouseDown     = false;
            IsDrawingPolygon = false;
            ShowCenter       = false;
            _readOnly        = false;

            _pointer = new GMarkerGoogle(Position, GMarkerGoogleType.arrow)
            {
                IsHitTestVisible = false
            };
            _topLayer.Markers.Add(_pointer);

            var deleteCacheDate = DateTime.Now;

            deleteCacheDate = deleteCacheDate.AddDays(-10);
            Manager.PrimaryCache.DeleteOlderThan(deleteCacheDate, null);

            _centerOfTheMap = new GMap.NET.PointLatLng(47.49801, 19.03991);

            drawPolygonCtxMenu.Renderer  = _tsRenderer;
            polygonPointCtxMenu.Renderer = _tsRenderer;

            _isWaitingForResponse = false;

            Client.Instance.OnPointUpdatedAck    += OnPointUpdatedAck;
            Client.Instance.OnZoneInfoUpdatedAck += OnZoneInfoUpdatedAck;
        }
示例#44
0
        private void DisplayLocationByLatLng()
        {
            try
            {
                GMap.NET.PointLatLng point = new GMap.NET.PointLatLng(this.DefaultLat, this.DefaultLng);
                gMapControl1.Position = point;

                GMapOverlay polyOverlay = new GMapOverlay(gMapControl1, "overlayJob");

                GMapMarkerCustom marker1 = new GMapMarkerCustom(point, Resources.Resource1.pushpin_PassengerOnBoard);
                marker1.ToolTipMode = MarkerTooltipMode.Never;
                marker1.Tag         = point;
                polyOverlay.Markers.Add(marker1);
                gMapControl1.Overlays.Clear();
                gMapControl1.Overlays.Add(polyOverlay);


                gMapControl1.Zoom = 16;
            }
            catch (Exception ex)
            {
                ENUtils.ShowMessage(ex.Message);
            }
        }
示例#45
0
 public static PointLatLng Subtract(PointLatLng pt, SizeLatLng sz)
 {
     return(new PointLatLng(pt.Lat + sz.HeightLat, pt.Lng - sz.WidthLng));
 }
示例#46
0
 public GMapMarkerTile(PointLatLng p, int size) : base(p)
 {
     Size = new System.Drawing.Size(size, size);
 }
示例#47
0
 public void Offset(PointLatLng pos)
 {
     this.Offset(pos.Lat, pos.Lng);
 }
示例#48
0
        /// <summary>
        /// Gets called when the cursor moves on the map
        /// </summary>
        /// <param name="e">Mouse event arguments</param>
        protected override void OnMouseMove(MouseEventArgs e)
        {
            if (!_readOnly)
            {
                if (e.Button == MouseButtons.Left)
                {
                    if (Equals(_currentRectMarker, null))
                    {
                        _pointer.Position = FromLocalToLatLng(e.X, e.Y);

                        // Handles polygon dragging on the map
                        if (CurrentPolygon != null && CurrentPolygon.IsMouseOver)
                        {
                            for (var i = 0; i < CurrentPolygon.Points.Count; i++)
                            {
                                var pnew = new GMap.NET.PointLatLng(
                                    CurrentPolygon.Points[i].Lat + _pointer.Position.Lat - _previousMouseLocation.Lat,
                                    CurrentPolygon.Points[i].Lng + _pointer.Position.Lng - _previousMouseLocation.Lng
                                    );
                                CurrentPolygon.Points[i] = pnew;

                                var zone = (PolyZone)CurrentPolygon.Tag;
                                var id   = zone.Geometry[i].Id;

                                zone.Geometry[i] = pnew.ToGeometry(id);
                            }

                            UpdatePolygonLocalPosition(CurrentPolygon);
                        }
                    }
                    // Handles dragging a point of a polygon
                    else if (CurrentPolygon != null)
                    {
                        var pnew = FromLocalToLatLng(e.X, e.Y);

                        var pIndex = (int?)_currentRectMarker.Tag;

                        if (pIndex.HasValue && pIndex < CurrentPolygon.Points.Count)
                        {
                            CurrentPolygon.Points[pIndex.Value] = pnew;
                            var zone = (PolyZone)CurrentPolygon.Tag;

                            // TODO: Find a workaround for waiting for a server response in this
                            // non-asynch method. Currently it causes the gui to hang up
                            if (_isWaitingForResponse)
                            {
                                while (_isWaitingForResponse)
                                {
                                    Thread.Sleep(300);
                                }
                            }

                            var id = zone.Geometry[pIndex.Value].Id;

                            zone.Geometry[pIndex.Value] = pnew.ToGeometry(id);
                            UpdatePolygonLocalPosition(CurrentPolygon);

                            _pointer.Position = pnew;
                            CurrentPolygon.PointsHasChanged();
                            _currentRectMarker.Position = pnew;

                            // TODO: Remove real-time update
                            // It is very inefficent
                            //await Task.Run(() => { Sql.Instance.UpdatePoint(zone.Geometry[pIndex.Value]); });
                        }
                    }
                }
                else if (IsDrawingPolygon)
                {
                    // Handles dragging a point of a NEW polygon on the map
                    _currentNewRectMaker.Position = FromLocalToLatLng(e.X, e.Y);

                    _currentDrawingPolygon.Points[_currentDrawingPolygon.Points.Count - 1] =
                        _currentNewRectMaker.Position;
                    UpdatePolygonLocalPosition(_currentDrawingPolygon);
                }

                _previousMouseLocation = FromLocalToLatLng(e.X, e.Y);
            }
            else if (e.Button == MouseButtons.Left)
            {
                _pointer.Position = FromLocalToLatLng(e.X, e.Y);
            }

            base.OnMouseMove(e);
        }
 public GMapMarkerRoute(GMap.NET.PointLatLng p) : base(p)
 {
 }
示例#50
0
 public bool Contains(PointLatLng pt)
 {
     return(this.Contains(pt.Lat, pt.Lng));
 }
 public void addCoords(GMap.NET.PointLatLng latlng)
 {
     pp = latlng;
 }
示例#52
0
 //------------------HARİTA KONUMUNA GÖRE TEXTBOXLARI DEĞİŞTİR---------------------
 private void harita1_OnPositionChanged(GMap.NET.PointLatLng point)
 {
     enlemTextBox.Text  = harita1.Position.Lat.ToString();
     boylamTextBox.Text = harita1.Position.Lng.ToString();
 }
示例#53
0
 /// <summary>
 /// Sets the pointer to a given position
 /// </summary>
 /// <param name="pos"></param>
 public void SetPointerPosition(GMap.NET.PointLatLng pos)
 {
     _pointer.Position = pos;
 }
示例#54
0
 public GPoint FromLatLngToPixel(PointLatLng p, int zoom)
 {
     return(FromLatLngToPixel(p, zoom, false));
 }
示例#55
0
 /// <summary>
 /// Drags the center of the map to a given position
 /// </summary>
 /// <param name="pos"></param>
 public void SetMapPosition(GMap.NET.PointLatLng pos)
 {
     Position = pos;
 }
示例#56
0
 public static PointLatLng Add(PointLatLng pt, SizeLatLng sz)
 {
     return(new PointLatLng(pt.Lat - sz.HeightLat, pt.Lng + sz.WidthLng));
 }
示例#57
0
 public PointLatLngAlt(GMap.NET.PointLatLng pll)
 {
     this.Lat = pll.Lat;
     this.Lng = pll.Lng;
 }
示例#58
0
 public SizeLatLng(PointLatLng pt)
 {
     this.heightLat = pt.Lat;
     this.widthLng  = pt.Lng;
 }
示例#59
-1
      /// <summary>
      /// get pixel coordinates from lat/lng
      /// </summary>
      /// <param name="p"></param>
      /// <param name="zoom"></param>
      /// <returns></returns>
      public GPoint FromLatLngToPixel(PointLatLng p, int zoom, bool useCache)
      {
         if(useCache)
         {
            GPoint ret = GPoint.Empty;
            if(!FromLatLngToPixelCache[zoom].TryGetValue(p, out ret))
            {
               ret = FromLatLngToPixel(p.Lat, p.Lng, zoom);
               FromLatLngToPixelCache[zoom].Add(p, ret);

               // for reverse cache
               if(!FromPixelToLatLngCache[zoom].ContainsKey(ret))
               {
                  FromPixelToLatLngCache[zoom].Add(ret, p);
               }

               Debug.WriteLine("FromLatLngToPixelCache[" + zoom + "] added " + p + " with " + ret);
            }
            return ret;
         }
         else
         {
            return FromLatLngToPixel(p.Lat, p.Lng, zoom);
         }
      }
        private PointLatLng getLatLong(PointD i_location)
        {
            PointLatLng coordinates;
            coordinates = new PointLatLng(i_location.X, i_location.Y);

            return coordinates;
        }