XGeocoding - funkcje API Google do pozyskiwania wsp. geograficznych z map Google
Migracja; autor Piotr, ostatnia modyfikacja przed importem 2014-12-02T11:40:26.000Z; XGeocoding-funkcje-API-Google-do-pozyskiwania-wsp-geograficznych-z-map-Google
W bibliotece GigaNet.Lib.Google klasa XGeocoding pozwala na wywołanie zapytać do Google API aby na podstawie adresu dostać współrzędne i odwrotnie z współrzędnych dostać adres.
Przykład wywołania
GeocodingResponseCoordinates c = XGeocoding.RequestCoordinateFromAddress(string.Format("Kościuszki 229, Katowice"));
System.Console.WriteLine( "Status={0}", c.Status );
System.Console.WriteLine( "Latitude={0}", c.Latitude );
System.Console.WriteLine( "Longitude={0}", c.Longitude );
System.Console.WriteLine( "LocationType={0}", c.LocationType );
decimal lat = c.Latitude;
decimal lng = c.Longitude;
GeocodingResponseAddress a = XGeocoding.RequestAddressFromCoordinate(lat, lng);
System.Console.WriteLine( "Status={0}", a.Status );
System.Console.WriteLine( "LocationType={0}", a.LocationType );
System.Console.WriteLine("Latitude={0}", a.Latitude);
System.Console.WriteLine("Longitude={0}", a.Longitude);
System.Console.WriteLine( "Address={0}", a.Address );
Zwraca wynik
Status=OK
Latitude=50.2237738
Longitude=18.9877325
LocationType=ROOFTOP
Status=OK
LocationType=ROOFTOP
Address=Tadeusza Kościuszki 229, Katowice, Poland
Przykład jak znaleźć środek Polski według Google Maps
GeocodingResponseCoordinates c = XGeocoding.RequestCoordinateFromAddress( string.Format( "Polska") );
System.Console.WriteLine( "Status={0}", c.Status );
System.Console.WriteLine( "Latitude={0}", c.Latitude );
System.Console.WriteLine( "Longitude={0}", c.Longitude );
System.Console.WriteLine( "LocationType={0}", c.LocationType );
GeocodingResponseAddress a = XGeocoding.RequestAddressFromCoordinate( c.Latitude, c.Longitude );
System.Console.WriteLine( "Status={0}", a.Status );
System.Console.WriteLine( "LocationType={0}", a.LocationType );
System.Console.WriteLine( "Address={0}", a.Address );
Zwraca wynik
Status=OK
Latitude=51,9194380
Longitude=19,1451360
LocationType=APPROXIMATE
Status=OK
LocationType=ROOFTOP
Address=Skórka 13, 95-045 Skórka, Poland