Google Places Photos API以哪种格式返回图像? [英] What format does the Google Places Photos API return the image in?

查看:186
本文介绍了Google Places Photos API以哪种格式返回图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个在此API: https://maps.googleapis.com/maps/api/place/photo?maxwidth=400&photoreference=CnRtAAAATLZNl354RwP_9UKbQ_5Psy40texXePv4oAlgP4qNEkdIrkyse7rPXYGd9D_Uj1rVsQdWT4oRz4QrYAJNpFX7rzqqMlZw2h2E2y5IKMUZ7ouD_SlcHxYq1yL4KbKUv3qtWgTK0A6QbGh87GB3sscrHRIQiG2RrmU_jF4tENr9wGS_YxoUSSDrYjWmrNfeEHSGSc3FyhNLlBU&key=AddYourOwnKeyHere

当您使用Postman或在浏览器中调用它时,它会返回精美呈现的图像.现在,从应用程序内部,当我使用$ http或jQuery调用此API时,返回的是很多垃圾".谁能解释这个垃圾是什么?它是与图像相对应的base64编码的二进制数据吗? 我需要这些信息,以便可以在我的应用中显示该图像. img ng-src ="{{photo}}"和img data-ng-src =" {{photo}}"均无效.我还尝试在img标签中显式指定base64,这没用.

When you invoke it using Postman, or in a browser, it returns an image which is rendered beautifully. Now, from inside an app, when I use $http or jQuery to call this API, what is returned is LOTS of "garbage". Can anyone explain what this garbage is? Is it base64 encoded binary data corresponding to the image? I need this information so that I can display this image in my app.. Neither img ng-src="{{photo}}" nor img data-ng-src="{{photo}}" worked. I also tried explicitly specifying base64 in the img tag, didn't work.

谢谢!

推荐答案

该URL返回图像的二进制文件,例如JPEG文件.您可以将该URL直接用作<img>标记的src.

That URL returns the binary file of the image, e.g. a JPEG file. You can use that URL as the src of an <img> tag directly.

这篇关于Google Places Photos API以哪种格式返回图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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