/// <summary> /// darg map by offset in pixels /// </summary> /// <param name="offset"></param> public void DragOffset(GPoint offset) { renderOffset.Offset(offset); UpdateCenterTileXYLocation(); if (centerTileXYLocation != centerTileXYLocationLast) { centerTileXYLocationLast = centerTileXYLocation; UpdateBounds(); } { LastLocationInBounds = Position; IsDragging = true; Position = FromLocalToLatLng((int)Width / 2, (int)Height / 2); IsDragging = false; } if (OnMapDrag != null) { OnMapDrag(); } }
public Task ProcesarDatos(string Country, string Department, string City, string Address) { Task task = Task.Run(() => { GeoCoderStatusCode status = GeoCoderStatusCode.UNKNOWN_ERROR; string fulladress = (string.IsNullOrEmpty(Country) ? "" : Country + ", ") + (string.IsNullOrEmpty(Department) ? "" : Department + ", ") + (string.IsNullOrEmpty(City) ? "" : City + ", " + Address); PointLatLng?pos = GMapProviders.GoogleMap.GetPoint(fulladress, out status); if (pos != null && status == GeoCoderStatusCode.OK) { GMapMarker myCity = new GMarkerGoogle(pos.Value, GMarkerGoogleType.green_small); myCity.ToolTipText = Address; myCity.ToolTipMode = MarkerTooltipMode.OnMouseOver; objects.Markers.Add(myCity); Exito += 1; } else { Falla += 1; } if (Exito % 100 == 0) { } if (Total == Exito + Falla) { } }); return(task); }
void AddLocation(int order, string place) { GeoCoderStatusCode status = GeoCoderStatusCode.Unknow; PointLatLng? pos = GMapProviders.GoogleMap.GetPoint("Canada, " + place, out status); if (pos != null && status == GeoCoderStatusCode.G_GEO_SUCCESS) { GMarkerGoogle m; if (order != 1) { m = new GMarkerGoogle(pos.Value, GMarkerGoogleType.green); } else { m = new GMarkerGoogle(pos.Value, GMarkerGoogleType.blue); } m.ToolTip = new GMapRoundedToolTip(m); m.ToolTipText = order + ": " + place; if (order != 1) { m.ToolTipMode = MarkerTooltipMode.Always; } else { m.ToolTipMode = MarkerTooltipMode.OnMouseOver; } objects.Markers.Add(m); // objects.Markers.Add(mBorders); } }
public void InitMapAndLocations(List <string> i_Locations, GMarkerGoogleType i_MakrerType) { MapControl.MapProvider = GoogleMapProvider.Instance; MapControl.DragButton = MouseButtons.Left; if (i_Locations != null) { GMapOverlay markersOverlay = new GMapOverlay("markers"); foreach (string location in i_Locations) { GeoCoderStatusCode status; PointLatLng?point = GoogleMapProvider.Instance.GetPoint(location, out status); if (point.HasValue) { GMarkerGoogle marker = new GMarkerGoogle(point.Value, i_MakrerType); markersOverlay.Markers.Add(marker); } } MapControl.Overlays.Add(markersOverlay); } MapControl.Zoom = 1; }
private void btnPesquisarEndereco_Click(object sender, EventArgs e) { string address = tbxEndereço.Text; GeoCoderStatusCode status; GeocodingProvider geocode = MainMap.MapProvider as GeocodingProvider; if (geocode == null) { MessageBox.Show("O tipo de mapa escolhido não possui \n serviço de geocoding !!!"); return; } PointLatLng?point = geocode.GetPoint(address, out status); //PointLatLng? point = GMapProviders.GoogleMap.GetPoint(address, out status); if (status == GeoCoderStatusCode.G_GEO_SUCCESS && point != null) { //MessageBox.Show(point.ToString()); MainMap.Position = point.Value; MainMap.Zoom = 18; } }
private void gMap1_Load(object sender, EventArgs e) { gMap1.MapProvider = GoogleMapProvider.Instance; GMaps.Instance.Mode = AccessMode.ServerAndCache; gMap1.ShowCenter = false; gMap1.DragButton = MouseButtons.Left; gMap1.OnMarkerClick += gmap_OnMarkerClick; ISet <string> set = manager.readInfo(); GMapOverlay markers = new GMapOverlay("markers"); foreach (string f in set) { GeoCoderStatusCode statusCode; PointLatLng? pointLatLng1 = OpenStreet4UMapProvider.Instance.GetPoint(f, out statusCode); if (pointLatLng1 != null) { GMapMarker marker00 = new GMarkerGoogle(new PointLatLng(pointLatLng1.Value.Lat, pointLatLng1.Value.Lng), GMarkerGoogleType.blue_dot); marker00.Tag = f; marker00.ToolTipText = f; marker00.ToolTip.Fill = Brushes.Black; marker00.ToolTip.Foreground = Brushes.White; marker00.ToolTip.Stroke = Pens.Black; marker00.ToolTip.TextPadding = new Size(10, 10); marker00.ToolTipMode = MarkerTooltipMode.OnMouseOver; markers.Markers.Add(marker00); } } gMap1.Overlays.Add(markers); }
private void button3_Click(object sender, EventArgs e) { markers.Clear(); List <Ciudad> lista = dataLoader.getLista(); //Trae los nombres de los municipios desde el Model foreach (Ciudad f in lista) { GeoCoderStatusCode statusCode; PointLatLng? pointLatLng1 = OpenStreet4UMapProvider.Instance.GetPoint(f.getCiudadNombre() + ',' + f.getDepartamento() + ',' + f.getPais(), out statusCode); //Las anteriores dos lineas proveen las funcionalidades para hacer la georeferenciación inversa if (comboBox1.Text == "Departamento") { if (pointLatLng1 != null) { GMapMarker marker00 = new GMarkerGoogle(new PointLatLng(pointLatLng1.Value.Lat, pointLatLng1.Value.Lng), GMarkerGoogleType.blue_dot); marker00.ToolTipText = f + "\n" + pointLatLng1.Value.Lat + "\n" + pointLatLng1.Value.Lng; // Esta linea es solo apariencia markers.Markers.Add(marker00); } } else { if (f.getDepartamento() == comboBox1.SelectedItem.ToString()) { GMapMarker marker00 = new GMarkerGoogle(new PointLatLng(pointLatLng1.Value.Lat, pointLatLng1.Value.Lng), GMarkerGoogleType.blue_dot); marker00.ToolTipText = f + "\n" + pointLatLng1.Value.Lat + "\n" + pointLatLng1.Value.Lng; // Esta linea es solo apariencia markers.Markers.Add(marker00); } } } }
public PointLatLng?GetPoint(string keywords, out GeoCoderStatusCode status, out float accuracy) { PointLatLng?coordinate = null; accuracy = 0f; var request = new GeocodingRequest { Address = keywords, Sensor = false }; var response = _geocodingService.GetResponse(request); status = GoogleMapWrapper.ToGeoCoderStatusCode(response.Status); if (response.Results.Any()) { var geometry = response.Results[0].Geometry; coordinate = GoogleMapWrapper.ToPointLatLng(geometry.Location); accuracy = GoogleMapWrapper.ToAccuracyValue(geometry.LocationType); } return(coordinate); }
private void SeleccionarRegistro(object sender, DataGridViewCellMouseEventArgs e) { filaSeleccionada = e.RowIndex; string fecha = dataGridView.Rows[filaSeleccionada].Cells[0].Value.ToString(); string autoridadAmbiental = dataGridView.Rows[filaSeleccionada].Cells[1].Value.ToString(); string nombreEstacion = dataGridView.Rows[filaSeleccionada].Cells[2].Value.ToString(); string tecnologia = dataGridView.Rows[filaSeleccionada].Cells[3].Value.ToString(); string latitud = dataGridView.Rows[filaSeleccionada].Cells[4].Value.ToString(); string longitud = dataGridView.Rows[filaSeleccionada].Cells[5].Value.ToString(); string departamento = dataGridView.Rows[filaSeleccionada].Cells[7].Value.ToString(); string municipio = dataGridView.Rows[filaSeleccionada].Cells[9].Value.ToString(); string tipoEstacion = dataGridView.Rows[filaSeleccionada].Cells[10].Value.ToString(); string tiempoExposicion = dataGridView.Rows[filaSeleccionada].Cells[11].Value.ToString(); string variable = dataGridView.Rows[filaSeleccionada].Cells[12].Value.ToString(); string unidades = dataGridView.Rows[filaSeleccionada].Cells[13].Value.ToString(); string concentracion = dataGridView.Rows[filaSeleccionada].Cells[14].Value.ToString(); GeoCoderStatusCode statusCode; PointLatLng? pointLatLng1 = OpenStreet4UMapProvider.Instance.GetPoint(municipio + ",COLOMBIA", out statusCode); markerOrigin.Position = new PointLatLng(pointLatLng1.Value.Lat, pointLatLng1.Value.Lng); gMapControl.Overlays.Add(markerOverlay); gMapControl.Position = markerOrigin.Position; markerOrigin.ToolTipMode = MarkerTooltipMode.Always; markerOrigin.ToolTipText = string.Format("Fecha: {0} \n Autoridad Ambiental: {1} \n Nombre de la Estacion: {2} \n Tecnologia: {3} \n Departamento: {4} \n Municipio: {5} \n Tipo de Estacion: {6} \n Tiempo de Exposicion: {7} \n Variable: {8} \n Unidades: {9} \n Concentracion: {10}" , fecha, autoridadAmbiental, nombreEstacion, tecnologia, departamento, municipio, tipoEstacion, tiempoExposicion, variable, unidades, concentracion); gMapControl.Zoom = 9; }
public static Coordinate Locate(string location) { GeoCoderStatusCode status; PointLatLng?pos = GMapProviders.GoogleMap.GetPoint(location, out status); while (status == GeoCoderStatusCode.G_GEO_TOO_MANY_QUERIES) { //if too many queries error sleep a while and try again.. Thread.Sleep(TimeSpan.FromSeconds(1)); return(Locate(location)); } switch (status) { case GeoCoderStatusCode.Unknow: break; case GeoCoderStatusCode.G_GEO_SUCCESS: return(new Coordinate(pos.Value.Lat, pos.Value.Lng)); break; case GeoCoderStatusCode.G_GEO_UNKNOWN_ADDRESS: throw new InvalidOperationException("Unknown address."); break; case GeoCoderStatusCode.G_GEO_BAD_REQUEST: throw new InvalidOperationException(); break; case GeoCoderStatusCode.G_GEO_SERVER_ERROR: throw new InvalidOperationException("Geo server is down."); break; case GeoCoderStatusCode.G_GEO_MISSING_QUERY: throw new InvalidOperationException(); break; case GeoCoderStatusCode.G_GEO_UNAVAILABLE_ADDRESS: throw new InvalidOperationException("Address is not public"); break; case GeoCoderStatusCode.G_GEO_UNKNOWN_DIRECTIONS: throw new InvalidOperationException(); break; case GeoCoderStatusCode.G_GEO_BAD_KEY: throw new InvalidOperationException(); break; case GeoCoderStatusCode.ExceptionInCode: throw new InvalidOperationException(); break; default: throw new ArgumentOutOfRangeException(); } throw new InvalidOperationException(); }
private void SearchLocation(string address) { PointLatLng?point = GetPointFromAddress(address.Trim()); if (point.HasValue) { if (tempMarker != null) { factoriesMapControl.Markers.Remove(tempMarker); } GeoCoderStatusCode status; Placemark? placemark = (factoriesMapControl.MapProvider as GeocodingProvider).GetPlacemark(point.Value, out status); if (status == GeoCoderStatusCode.OK && placemark.HasValue) { FactoryEVM factory = new FactoryEVM() { Name = ApplicationSettings.Map.NewFactoryName, Address = placemark.Value.Address.Trim(), Latitude = point.Value.Lat, Longitude = point.Value.Lng, CountryCode = placemark.Value.CountryNameCode.ToUpper() }; GMapMarker marker = CreateMarker(point.Value, factory, FactoryMarkerColor.Green); tempMarker = marker; factoriesMapControl.Markers.Add(marker); ZoomOnPoint(point.Value, ApplicationSettings.Map.ZoomMarker); _viewModel.SelectedFactory = factory; } } }
private void ProcesarDatos(string BusquedaLibre) { MainMap.Overlays.Clear(); status = GeoCoderStatusCode.UNKNOWN_ERROR; pos = GMapProviders.GoogleMap.GetPoint(BusquedaLibre, out status); if (pos != null && status == GeoCoderStatusCode.OK) { MainMap.Zoom = 18; MainMap.Position = new PointLatLng(pos.Value.Lat, pos.Value.Lng); Marker = new GMarkerGoogle(MainMap.Position, GMarkerGoogleType.red_dot) { ToolTipText = $"{BusquedaLibre}\nCoordenadas:{pos.Value.Lat}, {pos.Value.Lng}", ToolTipMode = MarkerTooltipMode.Always, }; MapOverlay = new GMapOverlay("Marcador"); MapOverlay.Markers.Add(Marker); MainMap.Overlays.Add(MapOverlay); } else { MessageBox.Show("No se pudo localizar la ubicación"); } }
private void showMarkers(List <string> cities, string value, DataTable dt) { List <String> names = new List <String>(); foreach (DataRow row in dt.Rows) { if (row[Box1.SelectedItem.ToString()] != DBNull.Value && row[DataManager.LA] != DBNull.Value) { string rowString = (string)row[Box1.SelectedItem.ToString()]; if (rowString.IndexOf(value, StringComparison.CurrentCultureIgnoreCase) >= 0) { cities.Add((string)row[DataManager.LA]); names.Add((string)row[Box1.SelectedItem.ToString()]); } } } cities = cities.Distinct().ToList(); markers.Clear(); int i = 0; foreach (string city in cities) { GeoCoderStatusCode statusCode; PointLatLng? pointLatLng1 = OpenStreet4UMapProvider.Instance.GetPoint(city, out statusCode); if (pointLatLng1 != null) { GMapMarker marker00 = new GMarkerGoogle(new PointLatLng(pointLatLng1.Value.Lat, pointLatLng1.Value.Lng), GMarkerGoogleType.blue_dot); marker00.ToolTipText = city + "\n" + names[i] + "\n" + pointLatLng1.Value.Lat + "\n" + pointLatLng1.Value.Lng; markers.Markers.Add(marker00); Console.WriteLine(city); i++; } } }
public async void RefreshMarkersAsync(IList <FactoryEVM> factories) { tempMarker = null; tempPosMarker = null; var tasks = new Dictionary <FactoryEVM, Task <PointLatLng?> >(); var factoriesToAdd = factories.Where(f => !factoriesMapControl.Markers.Any(m => m.Tag != null && (m.Tag as FactoryEVM).Id == f.Id)); foreach (FactoryEVM factory in factoriesToAdd) { tasks.Add(factory, GetFactoryCoordsAsync(factory)); } await Task.WhenAll(tasks.Values); foreach (var task in tasks) { FactoryEVM factory = task.Key; PointLatLng?point = task.Value.Result; if (point.HasValue) { GMapMarker marker = CreateMarker((PointLatLng)point, factory, FactoryMarkerColor.Red); factoriesMapControl.Markers.Add(marker); } } }
private void button1_Click(object sender, EventArgs e) { try { GeoCoderStatusCode status = GeoCoderStatusCode.Unknow; { PointLatLng?pos = GMaps.Instance.GetLatLngFromGeocoder(textAddress.Text, out status); if (pos != null && status == GeoCoderStatusCode.G_GEO_SUCCESS) { GMapMarker address = new GMapMarkerTransparentGoogleGreen(pos.Value); address.ToolTipMode = MarkerTooltipMode.Always; address.ToolTipText = textAddress.Text; Main.objects.Markers.Add(address); Main.MainMap.Position = address.Position; Main.menuItemGotoMap_Click(null, null); } else { labelstatus.Text = status.ToString(); } } } catch (Exception ex) { labelstatus.Text = ex.ToString(); } }
private void Form1_Load(object sender, EventArgs e) { mapa.DragButton = MouseButtons.Left; mapa.CanDragMap = true; mapa.MapProvider = GMapProviders.GoogleMap; mapa.Position = new PointLatLng(39.308744, -0.4195172); mapa.MinZoom = 0; mapa.MaxZoom = 24; mapa.Zoom = 15; mapa.AutoScroll = true; mapa.MarkersEnabled = true; mapa.Overlays.Clear(); GMapOverlay routes = new GMapOverlay("routes"); GMapOverlay circles = new GMapOverlay("polygons"); List <PointLatLng> points = new List <PointLatLng>(); using (var _points = new SqlDataAdapter($"Select Latitude, Longitude, Accuracy from detReadingSessionLocations where Session='{Values.Session}' order by LocationReadingNumber", Values.Conn)) { PointLatLng?punto1 = null; PointLatLng?punto2 = null; T = new DataTable(); _points.Fill(T); foreach (DataRow point in T.Rows) { if (punto1 != null) { punto2 = punto1; } punto1 = new PointLatLng(Convert.ToDouble(point["Latitude"]), Convert.ToDouble(point["Longitude"])); if (punto2 != null) { var distance = punto1.DistanceTo(punto2) * 1000; double accuracy = Convert.ToDouble(point["Accuracy"]); if (distance > accuracy) { points.Add(punto1 ?? new PointLatLng()); } } else { points.Add(punto1 ?? new PointLatLng()); } } GMapRoute route = new GMapRoute(points, "Trayectoria de prueba"); route.Stroke = new Pen(Color.Red, 3); routes.Routes.Add(route); mapa.Overlays.Add(routes); mapa.Refresh(); mapa.ReloadMap(); } }
private void MapControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { Point point = e.GetPosition(mapControl); PointLatLng pll = mapControl.FromLocalToLatLng((int)point.X, (int)point.Y); if ((aquireData.IsChecked == true ? true : false) && (!addStart)) { Guid id = Guid.NewGuid(); GMapMarker marker = new GMapMarker(pll); { marker.Shape = new MarkerShape(mapControl, new BitmapImage(new Uri("pack://application:,,,/Icon/大头针.png")), 16, 30, "Lng:" + pll.Lng.ToString("f2") + " Lat:" + pll.Lat.ToString("f2")); marker.Offset = new Point(-8, -26); marker.ZIndex = 1; marker.Tag = id; } markerList.Add(marker); mapControl.Markers.Add(marker); GMapMarker closeButton = new GMapMarker(pll); { closeButton.Shape = new CloseButton(mapControl, markerList, id, 11, 11); closeButton.Offset = new Point(6, -30); closeButton.ZIndex = 2; closeButton.Tag = id; } mapControl.Markers.Add(closeButton); } else if (addStart) { Guid id = Guid.NewGuid(); startPll = pll; GMapMarker marker = new GMapMarker(pll); { marker.Shape = new MarkerShape(mapControl, new BitmapImage(new Uri("pack://application:,,,/Icon/起点.png")), 30, 30, "Lng:" + pll.Lng.ToString("f2") + " Lat:" + pll.Lat.ToString("f2")); marker.Offset = new Point(-15, -27); marker.ZIndex = 3; marker.Tag = id; } mapControl.Markers.Add(marker); GMapMarker closeButton = new GMapMarker(pll); { closeButton.Shape = new CloseButton(mapControl, markerList, id, 11, 11); closeButton.Offset = new Point(9, -33); closeButton.ZIndex = 3; closeButton.Tag = id; } mapControl.Markers.Add(closeButton); addStart = false; } }
public GeoCoderStatusCode SetCurrentPositionByKeywords(string keys) { GeoCoderStatusCode status = GeoCoderStatusCode.Unknow; PointLatLng? pos = Manager.GetLatLngFromGeocoder(keys, out status); if (pos.HasValue && status == GeoCoderStatusCode.G_GEO_SUCCESS) { Position = pos.Value; } return(status); }
private void gmap_Load(object sender, EventArgs e) { gmap.MapProvider = GMap.NET.MapProviders.BingMapProvider.Instance; GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.ServerOnly; gmap.SetPositionByKeywords("New York, United States"); gmap.ShowCenter = false; gmap.DragButton = MouseButtons.Left; gmap.CanDragMap = true; gmap.MapProvider = GoogleMapProvider.Instance; gmap.Position = new PointLatLng(40.652941, -75.436502); gmap.MinZoom = 0; gmap.MaxZoom = 24; gmap.Zoom = 9; gmap.AutoScroll = true; readInfo(); GMapOverlay markers = new GMapOverlay("markers"); for (int i = 0; i < citys.Count(); i++) { if (citys.ElementAt(i).promDelays() > 1500) { GeoCoderStatusCode statusCode; PointLatLng? pointLatLng1 = OpenStreet4UMapProvider.Instance.GetPoint(citysNames.ElementAt(i), out statusCode); if (pointLatLng1 != null) { GMapMarker marker00 = new GMarkerGoogle(new PointLatLng(pointLatLng1.Value.Lat, pointLatLng1.Value.Lng), GMarkerGoogleType.red_dot); marker00.Tag = citysNames.ElementAt(i); marker00.ToolTipText = citysNames.ElementAt(i); marker00.ToolTip.Fill = Brushes.Black; marker00.ToolTip.Foreground = Brushes.White; marker00.ToolTip.Stroke = Pens.Black; marker00.ToolTip.TextPadding = new Size(10, 10); marker00.ToolTipMode = MarkerTooltipMode.OnMouseOver; markers.Markers.Add(marker00); gmap.Overlays.Add(markers); } } else { GeoCoderStatusCode statusCode; PointLatLng? pointLatLng1 = OpenStreet4UMapProvider.Instance.GetPoint(citysNames.ElementAt(i), out statusCode); if (pointLatLng1 != null) { GMapMarker marker00 = new GMarkerGoogle(new PointLatLng(pointLatLng1.Value.Lat, pointLatLng1.Value.Lng), GMarkerGoogleType.green_dot); marker00.Tag = citysNames.ElementAt(i); marker00.ToolTipText = citysNames.ElementAt(i); marker00.ToolTip.Fill = Brushes.Black; marker00.ToolTip.Foreground = Brushes.White; marker00.ToolTip.Stroke = Pens.Black; marker00.ToolTip.TextPadding = new Size(10, 10); marker00.ToolTipMode = MarkerTooltipMode.OnMouseOver; markers.Markers.Add(marker00); gmap.Overlays.Add(markers); } } } }
public static PointLatLng GetLocationByName(string i_Location) { GeoCoderStatusCode status; PointLatLng? point = GoogleMapProvider.Instance.GetPoint(i_Location, out status); PointLatLng pointToReturn = PointLatLng.Empty; if (point.HasValue) { pointToReturn = point.Value; } return(pointToReturn); }
private void findMap_Click(object sender, EventArgs e) { if (this.polygons.Count == 0) { MessageBox.Show("Данные полигонов не были загружены!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (this.showIntersections) { findMap.Text = ShowPointsButtonText; this.showIntersections = false; } for (int index = 0; index < this.polygons.Count; index++) { List <PointLatLng> intersections = new List <PointLatLng>(); int length = this.polygons[index].Points.Count; List <PointLatLng> pointsToDelete = new List <PointLatLng>(); for (int i = 0; i < length - 4; i++) { PointLatLng?intersection = this.CheckForIntersection( this.polygons[index].Points[i], this.polygons[index].Points[i + 1], this.polygons[index].Points[i + 2], this.polygons[index].Points[i + 3]); if (intersection != null) { intersections.Add(intersection.Value); pointsToDelete.Add(this.polygons[index].Points[i + 1]); pointsToDelete.Add(this.polygons[index].Points[i + 2]); } } if (intersections.Count > 0) { this.HighlightIntersectionsMap(intersections); this.polygons[index].Intersecions = intersections; pointsToDelete.ForEach(point => this.updatedPolygons[index].Points.Remove(point)); } } this.showIntersections = true; findMap.Text = HidePointsButtonText; fixButton.Enabled = true; gmap.Zoom++; gmap.Zoom--; }
/// <summary> /// Gọi Tác vụ đến bản đồ /// </summary> /// <param name="start"></param> /// <param name="end"></param> /// <param name="diemDau"></param> /// <param name="diemCuoi"></param> public void ShowBanDo(PointLatLng?start, PointLatLng?end, string diemDau, string diemCuoi) { if (start != null) { this._gMapMarkerA = MainMap.AddMarkerEnum(start.Value, GMapResources.EnumMarkerCustom.MarkerD); } if (end != null) { this._gMapMarkerB = MainMap.AddMarkerEnum(end.Value, GMapResources.EnumMarkerCustom.MarkerA); } Route(); AddressA = diemDau; AddressB = diemCuoi; }
/// <summary> /// adds marker using geocoder /// </summary> /// <param name="place"></param> public void AddLocationMarker(string place) { GeocoderStatusCode status; PointLatLng? pos = GMapProviders.GoogleMap.GetPoint(place, out status); if (pos != null && status == GeocoderStatusCode.Success) { var m = new GMarkerIcon(pos.Value, GMarkerIconType.green); m.ToolTipText = place; m.ToolTipMode = MarkerTooltipMode.Always; fObjects.Markers.Add(m); } }
public static PointLatLng GetPositionByKeywords(string keys) { GeoCoderStatusCode status; GeocodingProvider geocodingProvider = GMapProviders.GoogleMap; if (geocodingProvider != null) { PointLatLng?point = geocodingProvider.GetPoint(keys, out status); if (status == GeoCoderStatusCode.G_GEO_SUCCESS && point.HasValue) { return(point.Value); } } return(new PointLatLng()); }
/// <summary> /// adds marker using geocoder /// </summary> /// <param name="place"></param> private void AddLocationMarker(string place) { GeoCoderStatusCode status = GeoCoderStatusCode.Unknow; PointLatLng? pos = GMapProviders.GoogleMap.GetPoint(place, out status); if (pos != null && status == GeoCoderStatusCode.G_GEO_SUCCESS) { GMarkerGoogle m = new GMarkerGoogle(pos.Value, GMarkerGoogleType.green); m.ToolTip = new GMapRoundedToolTip(m); m.ToolTipText = place; m.ToolTipMode = MarkerTooltipMode.Always; fObjects.Markers.Add(m); } }
private void btnHeatMap_Click(object sender, EventArgs e) { GeoCoderStatusCode statusCode; for (int i = 0; i < dataGridView.Rows.Count; i++) { string municipio = dataGridView.Rows[i].Cells[9].Value.ToString(); PointLatLng?pointLatLng1 = OpenStreet4UMapProvider.Instance.GetPoint(municipio + ",COLOMBIA", out statusCode); PointF pointF = new PointF(); pointF.X = Convert.ToSingle(pointLatLng1.Value.Lat); pointF.Y = Convert.ToSingle(pointLatLng1.Value.Lng); CreateCircle(pointF, 0.1, 1080); } gMapControl.Overlays.Add(Circulos); gMapControl.Zoom++; gMapControl.Zoom--; }
public static double DistanceTo(this PointLatLng?baseCoordinates, PointLatLng?targetCoordinates, UnitOfLength unitOfLength) { var baseRad = Math.PI * baseCoordinates?.Lat / 180; var targetRad = Math.PI * targetCoordinates?.Lat / 180; var theta = baseCoordinates?.Lng - targetCoordinates?.Lng; var thetaRad = Math.PI * theta / 180; double dist = Math.Sin(baseRad ?? 0) * Math.Sin(targetRad ?? 0) + Math.Cos(baseRad ?? 0) * Math.Cos(targetRad ?? 0) * Math.Cos(thetaRad ?? 0); dist = Math.Acos(dist); dist = dist * 180 / Math.PI; dist = dist * 60 * 1.1515; return(unitOfLength.ConvertFromMiles(dist)); }
private void LoadGMaps(PointLatLng?start, string end) { GDirections route; if (start != null && end != null) { var statusCode = GMap.NET.MapProviders.GoogleMapProvider.Instance.GetDirections(out route, start.Value, end, true); if (statusCode == DirectionsStatusCode.NOT_FOUND) { MessageBox.Show("Não Localizado, verifique o endereço."); } if (route != null) { // add route GMapRoute r = new GMapRoute(route.Route, "My Route"); r.IsHitTestVisible = false; routes.Routes.Add(r); // add route start/end marks GMapMarker m1 = new GMarkerGoogle(start.Value, GMarkerGoogleType.green_big_go); m1.ToolTipText = "Start: " + route.StartAddress; m1.ToolTipMode = MarkerTooltipMode.Always; GMapMarker m2 = new GMarkerGoogle(route.Route[route.Route.Count() - 1], GMarkerGoogleType.red_big_stop); m2.ToolTipText = "End: " + end.ToString(); m2.ToolTipMode = MarkerTooltipMode.Always; objects.Markers.Add(m1); objects.Markers.Add(m2); MainMap.ZoomAndCenterRoute(r); } } else if (end != null) { GeoCoderStatusCode status = MainMap.SetPositionByKeywords(end); if (status != GeoCoderStatusCode.G_GEO_SUCCESS) { MessageBox.Show("Opsss... Endereço não localizado: '" + end + "', Razão: " + status.ToString(), "GMap.NET", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } }
private void municipios_Click(object sender, EventArgs e) //Mostrar municipios de Colombia { List <string> lista = dm.getLista(); //Trae los nombres de los municipios desde el Model foreach (string f in lista) { GeoCoderStatusCode statusCode; PointLatLng? pointLatLng1 = OpenStreet4UMapProvider.Instance.GetPoint(f, out statusCode); //Las anteriores dos lineas proveen las funcionalidades para hacer la georeferenciación inversa if (pointLatLng1 != null) { GMapMarker marker00 = new GMarkerGoogle(new PointLatLng(pointLatLng1.Value.Lat, pointLatLng1.Value.Lng), GMarkerGoogleType.blue_dot); marker00.ToolTipText = f + "\n" + pointLatLng1.Value.Lat + "\n" + pointLatLng1.Value.Lng; // Esta linea es solo apariencia markers.Markers.Add(marker00); } } }
private void SearchLocation() { PointLatLng?point = GetPointFromAddress(searchEntryTextBox.Text.Trim()); if (point.HasValue) { if (tempMarker != null) { factoriesMapControl.Markers.Remove(tempMarker); } tempMarker = CreateMarker(point.Value, new FactoryEVM() { Name = ApplicationSettings.Map.NewFactoryName, Address = searchEntryTextBox.Text.Trim(), Latitude = point.Value.Lat, Longitude = point.Value.Lng }, FactoryMarkerColor.Green); factoriesMapControl.Markers.Add(tempMarker); ZoomOnPoint(point.Value, ApplicationSettings.Map.ZoomMarker); } }
private void DoSearch() { try { GeoCoderStatusCode status = GeoCoderStatusCode.Unknow; pos = GMaps.Instance.GetLatLngFromGeocoder(tboxAddress.Text, out status); if (pos != null && status == GeoCoderStatusCode.G_GEO_SUCCESS) { this.DialogResult = DialogResult.OK; Close(); } else { SenseAPIs.SenseMessageBox.Show(status.ToString(), "Error", SenseMessageBoxButtons.OK); } } catch (System.Exception ex) { SenseAPIs.SenseMessageBox.Show(ex.Message, "Error", SenseMessageBoxButtons.OK); } }
/// <summary> /// drag map /// </summary> /// <param name="pt"></param> public void Drag(GPoint pt) { renderOffset.X = pt.X - dragPoint.X; renderOffset.Y = pt.Y - dragPoint.Y; UpdateCenterTileXYLocation(); if(centerTileXYLocation != centerTileXYLocationLast) { centerTileXYLocationLast = centerTileXYLocation; UpdateBounds(); } if(IsDragging) { LastLocationInBounds = Position; Position = FromLocalToLatLng((int)Width / 2, (int)Height / 2); if(OnMapDrag != null) { OnMapDrag(); } } }
/// <summary> /// darg map by offset in pixels /// </summary> /// <param name="offset"></param> public void DragOffset(GPoint offset) { renderOffset.Offset(offset); UpdateCenterTileXYLocation(); if(centerTileXYLocation != centerTileXYLocationLast) { centerTileXYLocationLast = centerTileXYLocation; UpdateBounds(); } { LastLocationInBounds = Position; IsDragging = true; Position = FromLocalToLatLng((int)Width / 2, (int)Height / 2); IsDragging = false; } if(OnMapDrag != null) { OnMapDrag(); } }