Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

php know if city exist gmap api

   public static function  latlong($location) {

        if ($location!='') {
            try {
                $json = file_get_contents('http://maps.googleapis.com/maps/api/geocode/json?address='.urlencode($location));
                $parsedjson = json_decode($json, true);

                if (key_exists(0,$parsedjson['results'])) {
                    $lat_long_array = $parsedjson['results'][0]['geometry']['location'];
                    return $lat_long_array;
                } else {
                    return false;
                }
            } catch (Exception $e) {
                //echo 'Caught exception: ',  $e->getMessage(), "
";
                return false;
            }
        }


    }
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #php #city #exist #gmap #api
ADD COMMENT
Topic
Name
2+4 =