Wednesday, 15 August 2012

google maps api 3 - how to get cityname from address php, googlemaps -


I must search for the city name by address, for input to me (street name, city name, country with singles Textbox) will take pre-horizons Blvd 35, California, USA.

$ str = "Skyline Blvd 35, munchen, Germany";

The result: Munchen

For the first time I discovered the latitude and the LAG and then reverse the name to get the city name. Late N Long: Developers.google.com/maps/documentation/geocoding/?csw=1#geocoding

Reverse Land Developers. Google.com/maps/documentation/geocoding/? Csw = 1 # Reverse Geocoding

I'm thinking that there can be another way of getting the name of the city by itself ..

Horizon BLVD35, Munchen, Germany.

P>

  $ x = file_get_contents ("http://maps.googleapis.com/ Maps / api / geocode / json? Sensor = false and address = ". Urlencode (" Skyline Blvd 35, California, USA ")); $ O = json_decode ($ x); Foreach ($ o-> Results [0] - & gt; as address_components $ component) {if ($ component-> type [0] == 'administrative_area_level_1') Print $ component- & gt; Long_name; }  

No comments:

Post a Comment