Exemplo n.º 1
0
        public void testgeo()
        {
            googleMaps.Geocoding.GeocodingRequest rq = new googleMaps.Geocoding.GeocodingRequest();
            rq.Address  = "Palma";
            rq.Language = "ES";
            rq.Sensor   = "true";

            googleMaps.Geocoding.GeocodingResponse rsp = googleMaps.Geocoding.GeocodingService.GetResponse(rq);
            if (rsp.Status == googleMaps.ServiceResponseStatus.Ok)
            {
                foreach (googleMaps.Geocoding.GeocodingResult rs in rsp.Results)
                {
                    Console.WriteLine(rs.FormattedAddress);

                    foreach (googleMaps.Geocoding.AddressComponent comp in rs.Components)
                    {
                        if (comp.Types[0] == googleMaps.Geocoding.AddressType.Locality)
                        {
                            Console.WriteLine("city: " + comp.LongName);
                        }
                        if (comp.Types[0] == googleMaps.Geocoding.AddressType.Country)
                        {
                            Console.WriteLine("country: " + comp.LongName);
                        }
                        if (comp.Types[0] == googleMaps.Geocoding.AddressType.PostalCode)
                        {
                            Console.WriteLine("CP: " + comp.LongName);
                        }
                        if (comp.Types[0] == googleMaps.Geocoding.AddressType.AdministrativeAreaLevel1)
                        {
                            Console.WriteLine("province: " + comp.LongName);
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void testgeo()
        {
            googleMaps.Geocoding.GeocodingRequest rq = new googleMaps.Geocoding.GeocodingRequest();
            rq.Address = "Palma";
            rq.Language = "ES";
            rq.Sensor = "true";

            googleMaps.Geocoding.GeocodingResponse rsp = googleMaps.Geocoding.GeocodingService.GetResponse(rq);
            if (rsp.Status == googleMaps.ServiceResponseStatus.Ok)
            {
                foreach (googleMaps.Geocoding.GeocodingResult rs in rsp.Results)
                {
                    Console.WriteLine(rs.FormattedAddress);

                    foreach (googleMaps.Geocoding.AddressComponent comp in rs.Components)
                    {
                        if (comp.Types[0] == googleMaps.Geocoding.AddressType.Locality)
                        {
                            Console.WriteLine("city: " + comp.LongName);
                        }
                        if (comp.Types[0] == googleMaps.Geocoding.AddressType.Country)
                        {
                            Console.WriteLine("country: " + comp.LongName);
                        }
                        if (comp.Types[0] == googleMaps.Geocoding.AddressType.PostalCode)
                        {
                            Console.WriteLine("CP: " + comp.LongName);
                        }
                        if (comp.Types[0] == googleMaps.Geocoding.AddressType.AdministrativeAreaLevel1)
                        {
                            Console.WriteLine("province: " + comp.LongName);
                        }
                    }

                }
            }
        }