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 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); } }
private void select_Click(object sender, EventArgs e) { MessageBox.Show("暂时无法使用。。。。。"); return; if (this.txtAddress.Text.Length == 0) { this.txtAddress.Focus(); MessageBox.Show("请输入查询的地址"); } string search = string.Format("{0},{1}", this.txtCity.Text, this.txtAddress.Text); GeoCoderStatusCode code = this.mapControl.SetPositionByKeywords(search); if (code != GeoCoderStatusCode.G_GEO_SUCCESS) { MessageBox.Show("地址没有找到:'" + this.txtAddress.Text + "', 原因:" + code.ToString(), "GMap.NET", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } this.objects.Markers.Clear(); AddLocation(this.txtAddress.Text); }
// goto by geocoder private void textBoxGeo_KeyUp(object sender, System.Windows.Input.KeyEventArgs e) { if (e.Key == System.Windows.Input.Key.Enter) { GeoCoderStatusCode status = MainMap.SetPositionByKeywords(textBoxGeo.Text); if (status != GeoCoderStatusCode.G_GEO_SUCCESS) { MessageBox.Show("Geocoder can't find: '" + textBoxGeo.Text + "', reason: " + status.ToString(), "GMap.NET", MessageBoxButton.OK, MessageBoxImage.Exclamation); } else { currentMarker.Position = MainMap.Position; } } }
// goto by geocoder void textBoxGeo_KeyPress(object sender, GUI.KeyPressEventArgs e) { if ((GUI.Keys)e.KeyChar == GUI.Keys.Enter) { GeoCoderStatusCode status = MainMap.SetPositionByKeywords(textBoxGeo.Text); if (status != GeoCoderStatusCode.G_GEO_SUCCESS) { new Alt.GUI.Temporary.Gwen.Control.MessageBox(this, "Geocoder can't find: '" + textBoxGeo.Text + "', reason: " + status.ToString(), "GMap.NET"); } } }
// goto by geocoder private void textBoxGeo_KeyPress(object sender, KeyPressEventArgs e) { if ((Keys)e.KeyChar == Keys.Enter) { GeoCoderStatusCode status = MainMap.SetCurrentPositionByKeywords(textBoxGeo.Text); if (status != GeoCoderStatusCode.G_GEO_SUCCESS) { MessageBox.Show("Google Maps Geocoder can't find: '" + textBoxGeo.Text + "', reason: " + status.ToString(), "GMap.NET", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } }
// goto by geocoder private void btnGo_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(textBoxGeo.Text)) { GeoCoderStatusCode status = MainMap.SetCurrentPositionByKeywords(textBoxGeo.Text); if (status != GeoCoderStatusCode.G_GEO_SUCCESS) { MessageBox.Show("Google Maps Geocoder can't find: '" + textBoxGeo.Text + "', reason: " + status.ToString(), "GMap.NET", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else { double lat = double.Parse(textBoxLat.Text, System.Globalization.CultureInfo.InvariantCulture); double lng = double.Parse(textBoxLng.Text, System.Globalization.CultureInfo.InvariantCulture); MainMap.CurrentPosition = new PointLatLng(lat, lng); } }
private void txtFindAddress_KeyPress(object sender, KeyPressEventArgs e) { if ((Keys)e.KeyChar == Keys.Enter) { GeoCoderStatusCode status = TheMap.SetPositionByKeywords(txtFindAddress.Text); if (status != GeoCoderStatusCode.G_GEO_SUCCESS) { _Dh.msgExclamation("Не могу найти '" + txtFindAddress.Text + "', причина: " + status.ToString()); } } }
//public Marker GetMarker(string ID) //{ // //return MainMap.Markers.Single(m => m.); //data.Pins.Single(p => p.ID.ToString() == PinID); //} private void btnSearchGeo_Click(object sender, RoutedEventArgs e) { GeoCoderStatusCode status = MainMap.SetCurrentPositionByKeywords(textBoxGeo.Text); if (status != GeoCoderStatusCode.G_GEO_SUCCESS) { MessageBox.Show("A keresett Geokód: '" + textBoxGeo.Text + "'nem található. Hibakód: " + status.ToString(), "Hiba", MessageBoxButton.OK, MessageBoxImage.Exclamation); } else { currentMarker.Position = MainMap.Position; txtStatus_Field.Text = "Keresett Geokód: '" + textBoxGeo.Text + "' megjelölve!"; } }
// goto by geocoder private void textBoxGeo_KeyPress(object sender, KeyPressEventArgs e) { if ((Keys)e.KeyChar == Keys.Enter) { GeoCoderStatusCode status = MainMap.SetPositionByKeywords(textBoxGeo.Text); if (status != GeoCoderStatusCode.G_GEO_SUCCESS) { MessageBox.Show("Geocoder can't find: '" + textBoxGeo.Text + "', reason: " + status.ToString()); } e.Handled = true; } }
// ищем координаты по ключевым словам private void FindPointOnMap(string searchstring) { if (textBox1.Text.Length > 0) { GeoCoderStatusCode stc = new GeoCoderStatusCode(); //PointLatLng fPoint = (PointLatLng)GMap.NET.MapProviders.GoogleMapProvider.Instance.GetPoint(searchstring, out stc); object fPoint = GMap.NET.MapProviders.GoogleMapProvider.Instance.GetPoint(searchstring, out stc); if (stc == GeoCoderStatusCode.G_GEO_SUCCESS) { ShowCheckedGeoPointEdt(enumGeoPointType.geoptObstacleDot, ((PointLatLng)fPoint).Lat, ((PointLatLng)fPoint).Lng, APInf.AirfieldHeight, searchstring); } else { MessageBox.Show(string.Format("Что то пошло не так. Статус поиска - {0}", stc.ToString()), "Поиск адреса", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
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); } } }