Ejemplo n.º 1
0
        public static LocationResult findLocation(Location location, String authKey)
        {
            String point = location.Latitude.ToString(CultureInfo.CreateSpecificCulture("en-GB")) + "," +
                           location.Longitude.ToString(CultureInfo.CreateSpecificCulture("en-GB"));

            String output = "?o=xml";

            string key = "&key=" + authKey;

            string geocodeRequest = "http://dev.virtualearth.net/REST/v1/Locations/" + point + output + key;

            //Make the request and get the response
            XmlDocument geocodeResponse = GetXmlResponse(geocodeRequest);

            XmlElement root = geocodeResponse.DocumentElement;

            XmlNamespaceManager nsmgr = new XmlNamespaceManager(geocodeResponse.NameTable);

            nsmgr.AddNamespace("ns", "http://schemas.microsoft.com/search/local/ws/rest/v1");

            LocationResult result = null;

            if (int.Parse(root.SelectSingleNode("//ns:EstimatedTotal", nsmgr).InnerText) > 0)
            {
                XmlNodeList resources = root.SelectNodes("//ns:Location", nsmgr);

                result = new LocationResult(resources[0], nsmgr);
            }

            return(result);
        }
Ejemplo n.º 2
0
        public static LocationResult findLocation(Location location, String authKey)
        {
            String point = location.Latitude.ToString(CultureInfo.CreateSpecificCulture("en-GB")) + "," +
                location.Longitude.ToString(CultureInfo.CreateSpecificCulture("en-GB"));

            String output = "?o=xml";

            string key = "&key=" + authKey;

            string geocodeRequest = "http://dev.virtualearth.net/REST/v1/Locations/" + point + output + key;

            //Make the request and get the response
            XmlDocument geocodeResponse = GetXmlResponse(geocodeRequest);

            XmlElement root = geocodeResponse.DocumentElement;

            XmlNamespaceManager nsmgr = new XmlNamespaceManager(geocodeResponse.NameTable);
            nsmgr.AddNamespace("ns", "http://schemas.microsoft.com/search/local/ws/rest/v1");

            LocationResult result = null;

            if (int.Parse(root.SelectSingleNode("//ns:EstimatedTotal", nsmgr).InnerText) > 0)
            {
                XmlNodeList resources = root.SelectNodes("//ns:Location", nsmgr);
               
                result = new LocationResult(resources[0], nsmgr);                
            }

            return (result);
        }
Ejemplo n.º 3
0
        private void findLocationComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            LocationResult location = (LocationResult)findLocationComboBox.SelectedItem;

            if (location == null)
            {
                return;
            }

            map.SetView(location.BoundingBox);
        }