public static function getGoogleMapImage($params = array(), $saveTo = null, $https = true){
//set default parameters
if(!isset($params['markers'])){
$params['center'] = isset($params['center']) ? $params['center'] : 0;
$params['zoom'] = isset($params['zoom']) ? $params['zoom'] : 0;
}
$params['size'] = isset($params['size']) ? $params['size'] : '200x200';
$params['sensor'] = isset($params['sensor']) ? $params['sensor'] : 'false';
foreach($params as $name => $value){
$paramString.=$name . '=' . urlencode($value) . '&';
}
$paramString = trim($paramString, '&');
$httpPrefix = $https ? 'https://' : 'http://';
$imageUrl = $httpPrefix . 'maps.googleapis.com/maps/api/staticmap?' . $paramString;
if(!$saveTo){ //if you don't want to save image, just to display it
return $imageUrl;
}
if(isset($params['format'])){
switch($params['format']){
case 'png8': $imgExt = '.png'; break;
case 'gif': $imgExt = '.gif'; break;
case 'jpg': $imgExt = '.jpg'; break;
case 'jpg-baseline': $imgExt = '.jpg'; break;
default: $imgExt = '.png';
}
}else{
$imgExt = '.png';
}
$saveTo = preg_replace("/\\.[^.\\s]{3,4}$/", "", $saveTo) . $imgExt; //in case requested file extension and provided in $saveTo don't match
if(self::getImage($imageUrl, $saveTo)){
return realpath($saveTo);
}
return false;
}
Я использовал вызов curl для получения изображений из созданного $ imageUrl