コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
ファイル: MapsViewerWin.cs プロジェクト: m-kosina/GEDKeeper
 private void txtPlace_KeyPress(object sender, KeyPressEventArgs e)
 {
     if ((Keys)e.KeyChar == Keys.Enter)
     {
         GeocoderStatusCode status = fMapBrowser.MapControl.SetPositionByKeywords(txtPlace.Text);
         if (status != GeocoderStatusCode.Success)
         {
             MessageBox.Show("Geocoder can't find: '" + txtPlace.Text + "', reason: " + status, @"GKMap", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
     }
 }
コード例 #5
0
        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));
        }
コード例 #6
0
        private Placemark?GetPlacemarkFromReverseGeocoderUrl(string url, out GeocoderStatusCode status)
        {
            status = GeocoderStatusCode.Unknown;
            Placemark?ret = null;

            try {
                string geo = GMaps.Instance.GetContent(url, CacheType.PlacemarkCache);

                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.SaveContent(url, CacheType.PlacemarkCache, geo);
                        }

                        XmlDocument doc = new XmlDocument();
                        doc.LoadXml(geo);

                        XmlNode r = doc.SelectSingleNode("/reversegeocode/result");
                        if (r != null)
                        {
                            var p = new Placemark(r.InnerText);

                            XmlNode ad = doc.SelectSingleNode("/reversegeocode/addressparts");
                            if (ad != null)
                            {
                                var vl = ad.SelectSingleNode("country");
                                if (vl != null)
                                {
                                    p.CountryName = vl.InnerText;
                                }

                                vl = ad.SelectSingleNode("country_code");
                                if (vl != null)
                                {
                                    p.CountryNameCode = vl.InnerText;
                                }

                                vl = ad.SelectSingleNode("postcode");
                                if (vl != null)
                                {
                                    p.PostalCodeNumber = vl.InnerText;
                                }

                                vl = ad.SelectSingleNode("state");
                                if (vl != null)
                                {
                                    p.AdministrativeAreaName = vl.InnerText;
                                }

                                vl = ad.SelectSingleNode("region");
                                if (vl != null)
                                {
                                    p.SubAdministrativeAreaName = vl.InnerText;
                                }

                                vl = ad.SelectSingleNode("suburb");
                                if (vl != null)
                                {
                                    p.LocalityName = vl.InnerText;
                                }

                                vl = ad.SelectSingleNode("road");
                                if (vl != null)
                                {
                                    p.ThoroughfareName = vl.InnerText;
                                }
                            }

                            ret = p;

                            status = GeocoderStatusCode.Success;
                        }
                    }
                }
            } catch (Exception ex) {
                ret    = null;
                status = GeocoderStatusCode.ExceptionInCode;
                Debug.WriteLine("GetPlacemarkFromReverseGeocoderUrl: " + ex);
            }

            return(ret);
        }
コード例 #7
0
 public Placemark?GetPlacemark(PointLatLng location, out GeocoderStatusCode status)
 {
     // http://msdn.microsoft.com/en-us/library/ff701713.aspx
     throw new NotImplementedException();
 }