【问题标题】:Add existing value to an image URL将现有值添加到图像 URL
【发布时间】:2020-12-06 04:29:32
【问题描述】:

所以我试图将我从谷歌地图 api 获得的photo_reference 值添加到图像 url,该图像 url 通过photo reference 显示地点的图像。这是我的代码

$("#poi-detail-gambar").html("<img src= "'https://maps.googleapis.com/maps/api/place/photo?maxwidth=400&photoreference="' + marker.poiData.photo_reference + "'&key=myKey />");

但是图片没有显示出来。

我在这里做错了什么?

谢谢

【问题讨论】:

    标签: html image url


    【解决方案1】:

    您可以尝试使用这样的模板文字:

    $("#poi-detail-gambar").html(`<img src= "https://maps.googleapis.com/maps/api/place/photo?maxwidth=400&photoreference=${marker.poiData.photo_reference}&key=myKey />`);
    

    或者你可以像这样使用它:

    $("#poi-detail-gambar").html("<img src= 'https://maps.googleapis.com/maps/api/place/photo?maxwidth=400&photoreference='" + marker.poiData.photo_reference + "&key=myKey />");
    

    【讨论】:

    • 是的,我正在使用第二个,它可以工作,谢谢
    猜你喜欢
    • 2017-07-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多