簡體   English   中英

Google Maps API服務器拒絕了您的請求。 無效請求。 缺少“尺寸”參數

[英]The Google Maps API server rejected your request. Invalid request. Missing the 'size' parameter

我正在node.js上編寫應用程序,我需要插入靜態Google Map。 代碼看起來像這樣

  .panel.panel-primary
    .panel-heading
      h2.panel-title On the map
    .panel-body
      img.img-responsive.img-rounded(src="http://maps.googleapis.com/maps/api/staticmap?center=#{location.coords.lat},#{location.coords.lng}&zoom=17&size=400x350&sensor=false&markers=#{location.coords.lat},#{location.coords.lng}&scale=2&key=AIzaSyDt0D6sy4v8BZFVJiAea93aiR63E-GpBL8")

控制器,從中獲取有關坐標的信息

res.render('location-info', {
    title: 'empty',
    pageHeader: {title: 'empty'},
    sidebar: {
        context: 'empty',
        callToAction: 'empty.'
    },
    location: {
        name: 'empty',
        address: 'empty',
        rating: 5,
        facilities: ['empty'],
        coords: {lat: 55.752813, lng: 37.791908},
        openingTimes: [{
            days: 'empty',
            opening: '19:00',
            closing: '01:00',
            closet: false
        },{

看起來如何。 當我嘗試復制別人的代碼時,一切正常。 救命! 先感謝您。

模板文字使用$ ,例如${varNameHere} -而不是#{location.coords.lat}

嘗試:

src="http://maps.googleapis.com/maps/api/staticmap?center=${location.coords.lat},${location.coords.lng}&zoom=17&size=400x350&sensor=false&markers=${location.coords.lat},${location.coords.lng}&scale=2&key=AIzaSyDt0D6sy4v8BZFVJiAea93aiR63E-GpBL8"

您可以在此處查看來自Google Map的錯誤消息。

您的大小參數不在預期的數值范圍內,或者在請求中丟失。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM