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


i need find cityname address, have take input(single textbox streetname, cityname,country) ex: skyline blvd 35, california, usa.

$str = "skyline blvd 35, munchen, germany";

result: munchen

what thought first find lat , lng , reverse geo cityname. lat n long: developers.google.com/maps/documentation/geocoding/?csw=1#geocoding

reverse geo:developers.google.com/maps/documentation/geocoding/?csw=1#reversegeocoding

i wonderring if there way of getting cityname may string itself..

skyline blvd35, munchen, germany.

$x = file_get_contents( "http://maps.googleapis.com/maps/api/geocode/json?sensor=false&address=" . urlencode( "skyline blvd 35, california, usa" )); $o = json_decode( $x ); foreach ( $o->results[0]->address_components $component ) {     if ( $component->types[0] == 'administrative_area_level_1' )         print $component->long_name;  } 

Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -