繁体   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