[英]The Google Maps API server rejected your request. Invalid request. Missing the 'size' parameter
I'm writing an application on node.js I need to insert a Static Google Map. 我正在node.js上编写应用程序,我需要插入静态Google Map。 The code looks like this 代码看起来像这样
.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")
Controller, from where information about coordinates is taken 控制器,从中获取有关坐标的信息
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
},{
How it looks like. 看起来如何。 When im try to copy someone else's code, everything works fine. 当我尝试复制别人的代码时,一切正常。 Help! 救命! Thank you in advance. 先感谢您。
Template literals use $
, eg ${varNameHere}
- not #{location.coords.lat}
. 模板文字使用$
,例如${varNameHere}
-而不是#{location.coords.lat}
。
Try: 尝试:
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"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.