【问题标题】:What to do with the response of Street View Image API?如何处理 Street View Image API 的响应?
【发布时间】:2016-03-24 17:59:40
【问题描述】:

我刚开始使用 Street View Image API,但是当我调用它时,它返回的只是一个巨大的无法读取的字符串。

我应该如何将该字符串转换为实际图像?谢谢。

这是我使用 jQyuery 发出的 AJAX 请求:

        $.ajax({
        method: "GET",
        url: "https://maps.googleapis.com/maps/api/streetview",
        success: function(data) {
            console.log(data);
        },
        data: {
            size: "600x300",
            location: "46.414382,10.013988",
            heading: "151.78",
            pitch: "-0.76",
            key: key
        }
    });

【问题讨论】:

  • 显示你的代码..请
  • @scaisEdge 我已将其添加到问题中,谢谢。
  • 有了这个你的目标是什么..这段代码,如果工作,返回图像..并且控制台中的日志结果没有用..

标签: image google-maps google-street-view


【解决方案1】:

正如@scaisEdge所说,它返回一个图像,直接使用URL作为<img>src

jQuery(
  function($) {
    $('#streetview')
      .attr('src', 'https://maps.googleapis.com/maps/api/streetview?' + $.param({
        size: "600x300",
        location: "46.414382,10.013988",
        heading: "151.78",
        pitch: "-0.76",
        //key:key
      })).show();
  }
);
#streetview {
  display: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<img id="streetview" />

【讨论】:

  • 谢谢!但是由于某种原因,如果我执行 AJAX 请求并将图像的 src 设置为请求的响应,它将不起作用。
猜你喜欢
  • 1970-01-01
  • 2019-06-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-11-29
  • 1970-01-01
  • 1970-01-01
  • 2023-03-31
相关资源
最近更新 更多