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(); } }
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); }
public Placemark?GetPlacemark(PointLatLng location, out GeoCoderStatusCode status) { List <Placemark> placemarkList; status = GetPlacemarks(location, out placemarkList); return(placemarkList != null && placemarkList.Count > 0 ? placemarkList[0] : (Placemark?)null); }
public PointLatLng?GetPoint(string keywords, out GeoCoderStatusCode status) { List <PointLatLng> pointList; status = GetPoints(keywords, out pointList); return(pointList != null && pointList.Count > 0 ? pointList[0] : (PointLatLng?)null); }
/// <summary> /// Updates position on map /// </summary> private void txtLat_KeyPress(object sender, KeyPressEventArgs e) { if ((Keys)e.KeyChar == Keys.Enter) { this.txtFind.Text = ""; this.listBox1.DataSource = null; double lat, lng; try { double.TryParse(txtLat.Text, out lat); double.TryParse(txtLong.Text, out lng); List <Placemark> list = new List <Placemark>(); GeoCoderStatusCode status = GeoCoder.GetPlacemarks(new Point2D(lat, lng), out list); if (status == GeoCoderStatusCode.G_GEO_SUCCESS) { this.listBox1.DataSource = list; } this.UpdateMapPosition(lat, lng); } catch (Exception) { MessageBox.Show("Invalid format"); } } }
public PointLatLng?GetPoint(Placemark placemark, out GeoCoderStatusCode status) { List <PointLatLng> pointList; status = GetPoints(placemark, out pointList); return(pointList != null && pointList.Count > 0 ? pointList[0] : (PointLatLng?)null); }
private void mBtnIP1_Click(object sender, EventArgs e) { this.Text = "IP 1 : " + IP1 + " ( " + IP1_lat + " , " + IP1_lng + " ) "; gMapControl1.CacheLocation = Environment.CurrentDirectory + "\\GMapCache\\"; //缓存位置 gMapControl1.MapProvider = GMapProviders.GoogleChinaMap; //google china 地图 gMapControl1.MinZoom = 2; //最小比例 gMapControl1.MaxZoom = 24; //最大比例 gMapControl1.Zoom = 10; //当前比例 gMapControl1.ShowCenter = false; //不显示中心十字点 gMapControl1.DragButton = System.Windows.Forms.MouseButtons.Left; //左键拖拽地图 gMapControl1.Position = new PointLatLng(IP1_lat, IP1_lng); //地图中心位置 GMapProvider.Language = LanguageType.ChineseTraditional; gMapControl1.Overlays.Add(markersOverlay); PointLatLng point = new PointLatLng(IP1_lat, IP1_lng); GeoCoderStatusCode statusCode = GeoCoderStatusCode.Unknow; var gp = gMapControl1.MapProvider as GeocodingProvider; Placemark?place = gp.GetPlacemark(point, out statusCode); if (statusCode == GeoCoderStatusCode.G_GEO_SUCCESS) { GMapMarker marker = new GMarkerGoogle(point, GMarkerGoogleType.green); marker.ToolTipText = place.Value.Address; marker.ToolTipMode = MarkerTooltipMode.Always; markersOverlay.Markers.Add(marker); } }
/// <summary> /// Runs geocoding task based upon user input /// </summary> private void txtFind_KeyPress(object sender, KeyPressEventArgs e) { if ((Keys)e.KeyChar == Keys.Enter) { this.listBox1.DataSource = null; List <Point2D> points = new List <Point2D>(); GeoCoderStatusCode status = GeoCoder.GetPoints(txtFind.Text, out points); if (status == GeoCoderStatusCode.G_GEO_SUCCESS && points.Count > 0) { this.txtLat.Text = points[0].Lat.ToString(); this.txtLong.Text = points[0].Lng.ToString(); this.UpdateMapPosition(points[0].Lat, points[0].Lng); if (this.chkShowAll.Checked) { ParameterizedThreadStart start = ShowAll; Thread thread = new Thread(start); thread.Priority = ThreadPriority.BelowNormal; thread.IsBackground = true; thread.Start(points); } else { this.listBox1.DataSource = points; } } } }
private void TextBoxLocation_KeyUp(object sender, KeyEventArgs e) { if (e.KeyCode.Equals(Keys.Enter)) { gmap.MapProvider = GMap.NET.MapProviders.GoogleMapProvider.Instance; GeoCoderStatusCode code = gmap.SetPositionByKeywords(this.textBoxLocation.Text); /* * GeoCoderStatusCode status = GeoCoderStatusCode.UNKNOWN_ERROR; * GeocodingProvider gp = gmap.MapProvider as GeocodingProvider; * var pt = gp.GetPoint( "Paris, France", out status ); * if( pt != null) * gmap.Position = pt.Value;// new GMap.NET.PointLatLng( 48.8589507, 2.2775175 ); */ if (code == GeoCoderStatusCode.OK) { buttonFind_ClickAsync(this, null); } // } //if( textBoxLocation.Text.EndsWith( "\r\n" ) ) // gmap.SetPositionByKeywords( textBoxLocation.Text ); }
public PointLatLng?GetPoint(Placemark placemark, out GeoCoderStatusCode status) { List <PointLatLng> pointList; status = GetLatLngFromGeocoderUrl(MakeGeocoderDetailedUrl(placemark), out pointList); return(pointList != null && pointList.Count > 0 ? pointList[0] : (PointLatLng?)null); }
/// <summary> /// Returns the first name for a given point /// </summary> public static Placemark GetPlacemark(Point2D location, out GeoCoderStatusCode status) { List <Placemark> pointList; status = GetPlacemarks(location, out pointList); return(pointList != null && pointList.Count > 0 ? pointList[0] : null); }
private void Search() { if (string.IsNullOrEmpty(SearchTextBox.Text)) { return; } using (BusyCursor.Display()) { GeoCoderStatusCode res = MapControl.SetPositionByKeywords(SearchTextBox.Text); switch (res) { case GeoCoderStatusCode.OK: MapControl.Zoom = 11; break; case GeoCoderStatusCode.ZERO_RESULTS: MessageBoxEx.Show(System.Windows.Application.Current.MainWindow, "Location not found.", "Cog", MessageBoxButton.OK, MessageBoxImage.Information); break; default: MessageBoxEx.Show(System.Windows.Application.Current.MainWindow, "Unable to connect to map server.", "Cog", MessageBoxButton.OK, MessageBoxImage.Error); break; } } }
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); } }
//api de Bing //http://dev.virtualearth.net/REST/v1/Locations?q={0}&key={1} //http://dev.virtualearth.net/REST/v1/Locations?q=moreno%202254,mar%20del%20plata&key=bpBO0zDlRa970B6utXiJ~fX83ZmlkorNqopUtDFehGw~AoCRAJfGGthrRRq9qQ-NDmrbtYT5fP9ODX52kWa-bfj07spvy3UkDju_BoNlDaCe public static PointLatLng ObtenerCordenadasPorDireccion(string direccion, out GeoCoderStatusCode status) { var address = direccion; var requestUri = string.Format("http://maps.googleapis.com/maps/api/geocode/xml?address={0}", Uri.EscapeDataString(address)); double lat = 0; double lng = 0; //34.6000° S, 58.3833° W ARGENTINA var request = WebRequest.Create(requestUri); try { var response = request.GetResponse(); var xdoc = XDocument.Load(response.GetResponseStream()); switch (xdoc.Element("GeocodeResponse").Element("status").Value) { case "OK": status = GeoCoderStatusCode.G_GEO_SUCCESS; break; case "ZERO_RESULTS": status = GeoCoderStatusCode.G_GEO_UNAVAILABLE_ADDRESS; break; case "OVER_QUERY_LIMIT": throw new OverQueryLimitException("Se excedió la cantidad de consultas a Google."); break; case "REQUEST_DENIED": status = GeoCoderStatusCode.ExceptionInCode; break; case "INVALID_REQUEST": status = GeoCoderStatusCode.G_GEO_BAD_REQUEST; break; default: status = GeoCoderStatusCode.Unknow; break; } if (status == GeoCoderStatusCode.G_GEO_SUCCESS) { var result = xdoc.Element("GeocodeResponse").Element("result"); var locationElement = result.Element("geometry").Element("location"); lat = double.Parse(locationElement.Element("lat").Value, CultureInfo.InvariantCulture); lng = double.Parse(locationElement.Element("lng").Value, CultureInfo.InvariantCulture); } } catch (Exception exc) { throw exc; //status = GeoCoderStatusCode.ExceptionInCode; } var point = new PointLatLng(lat, lng); return(point); }
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); }
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"); } }
public PointLatLng? GetPoint(string keywords, out GeoCoderStatusCode status) { List<PointLatLng> list; status = this.GetPoints(keywords, out list); if ((list != null) && (list.Count > 0)) { return new PointLatLng?(list[0]); } return null; }
public PointLatLng? GetPoint(Placemark placemark, out GeoCoderStatusCode status) { List<PointLatLng> list; status = this.GetLatLngFromGeocoderUrl(this.MakeGeocoderDetailedUrl(placemark), out list); if ((list != null) && (list.Count > 0)) { return new PointLatLng?(list[0]); } return null; }
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()); } } }
// 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 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"); } } }
public Placemark GetCenterNameByLocation(PointLatLng location) { GeoCoderStatusCode statusCode = new GeoCoderStatusCode(); Placemark? place = this.GetPlacemark(location, out statusCode); if (place.HasValue) { return(place.Value); } return(Placemark.Empty); }
public Placemark?GetPlacemark(PointLatLng location, out GeoCoderStatusCode status) { List <Placemark> placemarksByLocation = this.GetPlacemarksByLocation(location); if (placemarksByLocation != null && placemarksByLocation.Count > 0) { status = GeoCoderStatusCode.G_GEO_SUCCESS; return(new Placemark(placemarksByLocation[0])); } status = GeoCoderStatusCode.Unknow; return(null); }
// 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; } }
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); }
public void Set_MapLocation(string keyWord) { RouteMap2.MaxZoom = 24; RouteMap2.Zoom = 14; Console.WriteLine(keyWord.Trim()); GeoCoderStatusCode statusCode = new GeoCoderStatusCode(); var pointLatLng = RouteMap2.GeocodingProvider.GetPoint(keyWord.Trim(), out statusCode); if (statusCode == GeoCoderStatusCode.OK) { RouteMap2.Position = new PointLatLng(pointLatLng.Value.Lat, pointLatLng.Value.Lng); } }
public PointLatLng?GetPoint(Placemark placemark, out GeoCoderStatusCode status) { List <PointLatLng> points = this.GetPointsByPlacemark(placemark); if (points != null && points.Count > 0) { status = GeoCoderStatusCode.G_GEO_SUCCESS; return(points[0]); } status = GeoCoderStatusCode.Unknow; return(null); }
//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!"; } }
public Placemark?GetPlacemark(PointLatLng location, out GeoCoderStatusCode status) { //http://nominatim.openstreetmap.org/reverse?format=xml&lat=52.5487429714954&lon=-1.81602098644987&zoom=18&addressdetails=1 #region -- response -- /* * <reversegeocode timestamp="Wed, 01 Feb 12 09:51:11 -0500" attribution="Data Copyright OpenStreetMap Contributors, Some Rights Reserved. CC-BY-SA 2.0." querystring="format=xml&lat=52.5487429714954&lon=-1.81602098644987&zoom=18&addressdetails=1"> * <result place_id="2061235282" osm_type="way" osm_id="90394420" lat="52.5487800131654" lon="-1.81626922291265"> * 137, Pilkington Avenue, Castle Vale, City of Birmingham, West Midlands, England, B72 1LH, United Kingdom * </result> * <addressparts> * <house_number> * 137 * </house_number> * <road> * Pilkington Avenue * </road> * <suburb> * Castle Vale * </suburb> * <city> * City of Birmingham * </city> * <county> * West Midlands * </county> * <state_district> * West Midlands * </state_district> * <state> * England * </state> * <postcode> * B72 1LH * </postcode> * <country> * United Kingdom * </country> * <country_code> * gb * </country_code> * </addressparts> * </reversegeocode> */ #endregion return(GetPlacemarkFromReverseGeocoderUrl(MakeReverseGeocoderUrl(location), out status)); }
/// <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); } }
public Placemark? GetPlacemark(PointLatLng location, out GeoCoderStatusCode status) { List<Placemark> pointList; status = GetPlacemarks(location, out pointList); return pointList != null && pointList.Count > 0 ? pointList [0] : (Placemark?)null; }
/// <summary> /// NotImplemented /// </summary> /// <param name="placemark"></param> /// <param name="status"></param> /// <returns></returns> public PointLatLng? GetPoint(Placemark placemark, out GeoCoderStatusCode status) { throw new NotImplementedException("use GetPoint(string keywords..."); }
public PointLatLng? GetPoint(string keywords, out GeoCoderStatusCode status) { List<PointLatLng> pointList; status = GetPoints(keywords, out pointList); return pointList != null && pointList.Count > 0 ? pointList [0] : (PointLatLng?)null; }
private void parsePoints(int pointIndex, List<string> listPanoIds, List<PointLatLng> newPoints, string previousPanoId) { GoogleMapProvider gp = GMapProviders.GoogleMap; GeoCoderStatusCode StreetViewStatus = new GeoCoderStatusCode(); //List<string> listPanoIds = new List<string>(); string panoId = gp.GetPanoId(newPoints[pointIndex], out StreetViewStatus); //Debug.WriteLine("panoId: "+panoId); if (panoId != null && !panoId.Equals(previousPanoId)) { previousPanoId = panoId; listPanoIds.Add(panoId); if (pointIndex == newPoints.Count - 1) { //handle completion return; } else { pointIndex++; parsePoints(pointIndex, listPanoIds, newPoints, previousPanoId); // handle cancelation } } else { newPoints.RemoveAt(pointIndex); if (pointIndex == newPoints.Count) { return; } else { parsePoints(pointIndex, listPanoIds, newPoints, previousPanoId); } } }
public Placemark? GetPlacemark(PointLatLng location, out GeoCoderStatusCode status) { // http://msdn.microsoft.com/en-us/library/ff701713.aspx throw new NotImplementedException(); }
public PointLatLng? GetPoint(Placemark placemark, out GeoCoderStatusCode status) { List<PointLatLng> pointList; status = GetPoints(placemark, out pointList); return pointList != null && pointList.Count > 0 ? pointList[0] : (PointLatLng?)null; }
public Placemark? GetPlacemark(PointLatLng location, out GeoCoderStatusCode status) { throw new NotImplementedException(); }
public string GetPanoId(PointLatLng location, out GeoCoderStatusCode status) { List<string> panoIdList; status = GetPanoIds(location, out panoIdList); return panoIdList != null && panoIdList.Count > 0 ? panoIdList[0] : null; }
public PointLatLng? GetPoint(Placemark placemark, out GeoCoderStatusCode status) { List<PointLatLng> pointList; status = GetLatLngFromGeocoderUrl(MakeGeocoderDetailedUrl(placemark), out pointList); return pointList != null && pointList.Count > 0 ? pointList[0] : (PointLatLng?)null; }
private void buttonLocation_Click(object sender, RoutedEventArgs e) { try { string location = textBoxGeo.Text; GeoCoderStatusCode status = new GeoCoderStatusCode(); PointLatLng? point = GMapProviders.GoogleMap.GetPoint(location, out status); if (point != null && status == GeoCoderStatusCode.G_GEO_SUCCESS) { MainMap.Position = (PointLatLng)point; } //MainMap.Position = new PointLatLng(lat, lng); } catch (Exception ex) { MessageBox.Show("incorrect coordinate format: " + ex.Message); } }
Placemark GetPlacemarkFromReverseGeocoderUrl(string url, out GeoCoderStatusCode status) { status = GeoCoderStatusCode.Unknow; Placemark ret = null; try { string geo = GMaps.Instance.UsePlacemarkCache ? Cache.Instance.GetContent(url, CacheType.PlacemarkCache) : string.Empty; bool cache = false; if(string.IsNullOrEmpty(geo)) { geo = GetContentUsingHttp(url); if(!string.IsNullOrEmpty(geo)) { cache = true; } } if(!string.IsNullOrEmpty(geo)) { if(geo.StartsWith("<?xml") && geo.Contains("<result")) { if(cache && GMaps.Instance.UsePlacemarkCache) { Cache.Instance.SaveContent(url, CacheType.PlacemarkCache, geo); } XmlDocument doc = new XmlDocument(); doc.LoadXml(geo); { XmlNode r = doc.SelectSingleNode("/reversegeocode/result"); if(r != null) { ret = new Placemark(r.InnerText); XmlNode ad = doc.SelectSingleNode("/reversegeocode/addressparts"); if(ad != null) { var vl = ad.SelectSingleNode("country"); if(vl != null) { ret.CountryName = vl.InnerText; } vl = ad.SelectSingleNode("country_code"); if(vl != null) { ret.CountryNameCode = vl.InnerText; } vl = ad.SelectSingleNode("postcode"); if(vl != null) { ret.PostalCodeNumber = vl.InnerText; } vl = ad.SelectSingleNode("state"); if(vl != null) { ret.AdministrativeAreaName = vl.InnerText; } vl = ad.SelectSingleNode("region"); if(vl != null) { ret.SubAdministrativeAreaName = vl.InnerText; } vl = ad.SelectSingleNode("suburb"); if(vl != null) { ret.LocalityName = vl.InnerText; } vl = ad.SelectSingleNode("road"); if(vl != null) { ret.ThoroughfareName = vl.InnerText; } } status = GeoCoderStatusCode.G_GEO_SUCCESS; } } } } } catch(Exception ex) { ret = null; status = GeoCoderStatusCode.ExceptionInCode; Debug.WriteLine("GetPlacemarkFromReverseGeocoderUrl: " + ex); } return ret; }
public Placemark GetPlacemark(PointLatLng location, out GeoCoderStatusCode status) { //http://nominatim.openstreetmap.org/reverse?format=xml&lat=52.5487429714954&lon=-1.81602098644987&zoom=18&addressdetails=1 #region -- response -- /* <reversegeocode timestamp="Wed, 01 Feb 12 09:51:11 -0500" attribution="Data Copyright OpenStreetMap Contributors, Some Rights Reserved. CC-BY-SA 2.0." querystring="format=xml&lat=52.5487429714954&lon=-1.81602098644987&zoom=18&addressdetails=1"> <result place_id="2061235282" osm_type="way" osm_id="90394420" lat="52.5487800131654" lon="-1.81626922291265"> 137, Pilkington Avenue, Castle Vale, City of Birmingham, West Midlands, England, B72 1LH, United Kingdom </result> <addressparts> <house_number> 137 </house_number> <road> Pilkington Avenue </road> <suburb> Castle Vale </suburb> <city> City of Birmingham </city> <county> West Midlands </county> <state_district> West Midlands </state_district> <state> England </state> <postcode> B72 1LH </postcode> <country> United Kingdom </country> <country_code> gb </country_code> </addressparts> </reversegeocode> */ #endregion return GetPlacemarkFromReverseGeocoderUrl(MakeReverseGeocoderUrl(location), out status); }
private void buttonStreetView_Click(object sender, RoutedEventArgs e) { DirectionsProvider dp = MainMap.MapProvider as DirectionsProvider; bool avoidHighways = (bool)checkBoxAvoidHighways.IsChecked; bool avoidTools = (bool)checkBoxAvoidTools.IsChecked; bool walkingMode = (bool)checkBoxWalkingMode.IsChecked; GDirections direction = new GDirections(); DirectionsStatusCode status = dp.GetDirections (out direction, start, end, avoidHighways, avoidTools, walkingMode, true, true); //Debug.WriteLine(status); //Debug.WriteLine(direction.Route.ToString()); if (direction != null && status == DirectionsStatusCode.OK) { GMapMarker m1 = new GMapMarker(start); m1.Shape = new CustomMarkerDemo(this, m1, "Start: " + direction.StartAddress); GMapMarker m2 = new GMapMarker(end); m2.Shape = new CustomMarkerDemo(this, m2, "End: " + direction.EndAddress); GMapRoute mRoute = new GMapRoute(direction.Route); { mRoute.ZIndex = -1; } MainMap.Markers.Add(m1); MainMap.Markers.Add(m2); MainMap.Markers.Add(mRoute); MainMap.ZoomAndCenterMarkers(null); MainMap.hasDirection = true; MainMap.selectedDirection = direction; List<PointLatLng> newPoints = new List<PointLatLng>(); List<string> listPanoIds = handleDirectionsRoute(direction, newPoints); //Debug.WriteLine("Pano Ids list: " + String.Join("\n", listPanoIds)); Debug.WriteLine("Number of PanoIds: " + listPanoIds.Count); if (listPanoIds == null || listPanoIds.Count == 0) { return; /*GoogleMapProvider gp = GMapProviders.GoogleMap; GeoCoderStatusCode StreetViewStatus = new GeoCoderStatusCode(); //List<string> listPanoIds = new List<string>(); listPanoIds = new List<string>(); string panoId = gp.GetPanoId(start, out StreetViewStatus); if (panoId != null && !panoId.Equals(String.Empty)) listPanoIds.Add(panoId); else return;*/ } GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); if ((sender as Button).Name.Equals("buttonStreetViewQuality")) { startStreetView(listPanoIds, 3, false); } else if ((sender as Button).Name.Equals("buttonStreetViewQuick")) { startStreetView(listPanoIds, 2, false); } else if ((sender as Button).Name.Equals("buttonOculusView")) { startStreetView(listPanoIds, 3, true); } } else { MainMap.hasDirection = false; MainMap.selectedDirection = null; GoogleMapProvider gp = GMapProviders.GoogleMap; GeoCoderStatusCode StreetViewStatus = new GeoCoderStatusCode(); //List<string> listPanoIds = new List<string>(); List<string> listPanoIds = new List<string>(); string panoId = gp.GetPanoId(start, out StreetViewStatus); if (panoId != null && !panoId.Equals(String.Empty)) { listPanoIds.Add(panoId); GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); if ((sender as Button).Name.Equals("buttonStreetViewQuality")) { startStreetView(listPanoIds, 3, false); } else if ((sender as Button).Name.Equals("buttonStreetViewQuick")) { startStreetView(listPanoIds, 2, false); } else if ((sender as Button).Name.Equals("buttonOculusView")) { startStreetView(listPanoIds, 3, true); } } } }