如何将Google图片地图API图片保存到我的服务器 [英] How do I save the google image map API picture to my server

查看:231
本文介绍了如何将Google图片地图API图片保存到我的服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将Google地图图片API作为图片保存到我的服务器中?

Is it possible to save the google map image API as an image to my server?

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

Background: Google map image API is generating an image of the desired location. Every time I am calling for the external URL. Can I save the map image as an image(png, gif) on my server? This will improve my web page speed. I tried with curl but failed to copy the image

请求的网址
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 = false

推荐答案


$ b

you can try something like this:

<?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);
?>

这篇关于如何将Google图片地图API图片保存到我的服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆