Ejemplo n.º 1
0
        public ReverseCodeCoordinate GetGeoCode()
        {
            ReverseCodeCoordinate tmp = new ReverseCodeCoordinate();

            tmp.locationname = String.Empty;

            if (XmlDoc != null)
            {
                if (XMLStatusCheck(XmlDoc) == true)
                {
                    return(GetLatLng(XmlDoc));
                }
                else
                {
                    return(tmp);
                }
            }
            else
            {
                XmlDoc = XMLDownloader(URL);
                if (XMLStatusCheck(XmlDoc) == true)
                {
                    return(GetLatLng(XmlDoc));
                }
                else
                {
                    return(tmp);
                }
            }
        }
Ejemplo n.º 2
0
        private ReverseCodeCoordinate GetLatLng(XmlDocument xmlDoc)
        {
            XmlNode nodeGeocodeResponse = null;
            XmlNode nodeResult          = null;
            XmlNode nodeGeometry        = null;
            XmlNode nodeLocationItem    = null;
            ReverseCodeCoordinate res   = new ReverseCodeCoordinate();

            // Loop for the <GeocodeResponse> tag
            for (int i = 0; i < xmlDoc.ChildNodes.Count; i++)
            {
                // If it is the rss tag
                if (xmlDoc.ChildNodes[i].Name == "GeocodeResponse")
                {
                    // <rss> tag found
                    nodeGeocodeResponse = xmlDoc.ChildNodes[i];
                }
            }

            // If it is the channel tag

            if (nodeGeocodeResponse.ChildNodes[2].Name == "result")
            {
                // <channel> tag found
                nodeResult = nodeGeocodeResponse.ChildNodes[2];
            }


            // Loop for the <geometry> tag
            for (int i = 0; i < nodeResult.ChildNodes.Count; i++)
            {
                // If it is the channel tag
                if (nodeResult.ChildNodes[i].Name == "formatted_address")
                {
                    // <channel> tag found
                    res.locationname = nodeResult.ChildNodes[i].InnerText;
                }
            }


            /////<location>finding
            //for (int i = 0; i < nodeGeometry.ChildNodes.Count; i++)
            //{
            //    // If it is the item tag, then it has children tags which we will add as items to the ListView
            //    if (nodeGeometry.ChildNodes[i].Name == "location")
            //    {
            //        nodeLocationItem = nodeGeometry.ChildNodes[i];
            //        res.Latitude = nodeLocationItem["lat"].InnerText;
            //        res.Longitude = nodeLocationItem["lng"].InnerText;
            //    }
            //}

            //res.IsValue = true;
            //return res;
            return(res);
        }