void CustomMarkerDemo_MouseMove(object sender, MouseEventArgs e) { if (e.LeftButton == MouseButtonState.Pressed && IsMouseCaptured) { Point p = e.GetPosition(MainWindow.MainMap); IncrementoLatLon = this.Marker.Position - MainWindow.MainMap.FromLocalToLatLng((int)p.X, (int)p.Y); this.Marker.Position = MainWindow.MainMap.FromLocalToLatLng((int)p.X, (int)p.Y); } if (Marker_Line != null) { GMapRoute aux = (GMapRoute)Marker_Line; aux.Points.Clear(); List <PointLatLng> route = new List <PointLatLng>(); double A = 26 / 2; double B = 151 / 2; route.Add(this.Marker_link.Position); var PC = this.MainWindow.MainMap.FromLatLngToLocal(this.Marker.Position); var PM = this.MainWindow.MainMap.FromLatLngToLocal(this.Marker_link.Position); double CX = PC.X; double CY = PC.Y; double AX = PM.X; double AY = PM.Y; Vector A1 = new Vector(CX - B, CY + A); Vector A2 = new Vector(CX + B, CY + A); Vector A3 = new Vector(CX + B, CY - A); Vector A4 = new Vector(CX - B, CY - A); Vector P1 = new Vector(CX, CY); Vector P2 = new Vector(AX, AY); var Point = Matematicas.Matematicas.PuntoRectangulo(A1, A2, A3, A4, P1, P2); route.Add(MainWindow.MainMap.FromLocalToLatLng((int)Point.Value.X, (int)Point.Value.Y)); aux.Points = route; aux.RegenerateShape(this.MainWindow.MainMap); } }
void MarkerControl_MouseLeave(object sender, MouseEventArgs e) { Marker.ZIndex -= 10000; IncrementoLatLon = Marker.Position - Marker_link.Position; }
/// <summary> /// Группирует квартиры, которые находятся поблизости. /// </summary> private IEnumerable <ApartmentsGroup> GroupNearestApartments(IEnumerable <ApartmentInfo> apartments, SizeLatLng size) { // TODO: Надо выбрать самый оптимальный метод. //double GetDiscreteValue2(double value, double step) => (int)(value / step) * step; double GetDiscreteValue(double value, double step) => (float)Math.Round(value / step) * step; PointLatLng GetDiscrete(PointLatLng p) => new PointLatLng(GetDiscreteValue(p.Lat, size.HeightLat), GetDiscreteValue(p.Lng, size.WidthLng)); var map = new Dictionary <PointLatLng, List <ApartmentInfo> >(); foreach (var apartment in apartments) { var discretePoint = GetDiscrete(apartment.Location); if (!map.TryGetValue(discretePoint, out var list)) { list = new List <ApartmentInfo>(); map[discretePoint] = list; } list.Add(apartment); } return(map.Select(x => new ApartmentsGroup(x.Value))); }