如何将google图像映射API图片保存到我的服务器

Rin*_*rge 10 php google-maps

是否可以将谷歌地图图像API作为图像保存到我的服务器?

背景: Google地图图像API正在生成所需位置的图像.每次我要求外部URL.我可以将地图图像保存为服务器上的图像(png,gif)吗?这将提高我的网页速度.我尝试使用卷曲但未能复制图像

请求的网址 http://maps.googleapis.com/maps/api/staticmap?center=15719+OAKLEAF+RUN+DRIVE%2CLITHIA%2CFL%2C33547%2CUS&zoom=8&size=150x100&markers=color:blue|label:S|11211&sensor=假

小智 15

你可以尝试这样的事情:

<?php
$image = file_get_contents('http://maps.googleapis.com/maps/api/staticmap?center=15719%20OAKLEAF%20RUN%20DRIVE,LITHIA,FL,33547,US&zoom=8&size=150x100&markers=color%3ablue%7Clabel%3aS%7C11211&sensor=false'); 
$fp  = fopen('ae.png', 'w+'); 

fputs($fp, $image); 
fclose($fp); 
unset($image);
?>
Run Code Online (Sandbox Code Playgroud)