Javascript 谷歌地图信息窗口内容中的变量失败
我有一个信息窗口,我想从变量中获取数据,但每当我试图运行它时,这段代码总是失败 如果没有变量,此代码可以正常工作:Javascript 谷歌地图信息窗口内容中的变量失败,javascript,google-maps,Javascript,Google Maps,我有一个信息窗口,我想从变量中获取数据,但每当我试图运行它时,这段代码总是失败 如果没有变量,此代码可以正常工作: content: "<button onClick="MyObject.joinevent(this.id);" id='"+mid+"' class="join btn btn-primary pull-right">Join Event</button><br/><hr/>"+"<b>Event Title</b
content: "<button onClick="MyObject.joinevent(this.id);" id='"+mid+"' class="join btn btn-primary pull-right">Join Event</button><br/><hr/>"+"<b>Event Title</b> "+eventtitle+"<br/>"+"<b>Event Time</b> "+eventtime+"<br/>"+"<b>Event Duration</b> "+eventduration+"<br/>"+"<b>Event Category</b> "+eventcategory
content:“加入事件”
“+”事件标题“+eventtitle+”
“+”事件时间“+eventtime+”
“+”事件持续时间“+eventduration+”
“+”事件类别“+eventcategory”
将内容分配给变量时:
var infoWindow = new google.maps.InfoWindow({
var kontent = '"<button onClick="MyObject.joinevent(this.id);" id='"+mid+"' class="join btn btn-primary pull-right">Join Event</button><br/><hr/>"+"<b>Event Title</b> "+eventtitle+"<br/>"+"<b>Event Time</b> "+eventtime+"<br/>"+"<b>Event Duration</b> "+eventduration+"<br/>"+"<b>Event Category</b> "+eventcategory';
content: kontent
});
var infoWindow=new google.maps.infoWindow({
var kontent='“加入事件”
“+”事件标题“+eventtitle+”
“+”事件时间“+eventtime+”
“+”事件持续时间“+eventduration+”
“+”事件类别“+eventcategory”;
内容:康腾特
});
我在var kontent=…
如何更正我的问题?InfoWindow收到一个哈希。在外部定义变量,然后根据需要使用它:
var kontent = "<button onClick="MyObject.joinevent(this.id);" id='"+mid+"' class="join btn btn-primary pull-right">Join Event</button><br/><hr/>"+"<b>Event Title</b> "+eventtitle+"<br/>"+"<b>Event Time</b> "+eventtime+"<br/>"+"<b>Event Duration</b> "+eventduration+"<br/>"+"<b>Event Category</b> "+eventcategory;
var infoWindow = new google.maps.InfoWindow({
content: kontent
});
var kontent=“加入事件”
“+”事件标题“+eventtitle+”
“+”事件时间“+eventtime+”
“+”事件持续时间“+eventduration+”
“+”事件类别“+eventcategory;
var infoWindow=new google.maps.infoWindow({
内容:康腾特
});
信息窗口接收哈希。在外部定义变量,然后根据需要使用它:
var kontent = "<button onClick="MyObject.joinevent(this.id);" id='"+mid+"' class="join btn btn-primary pull-right">Join Event</button><br/><hr/>"+"<b>Event Title</b> "+eventtitle+"<br/>"+"<b>Event Time</b> "+eventtime+"<br/>"+"<b>Event Duration</b> "+eventduration+"<br/>"+"<b>Event Category</b> "+eventcategory;
var infoWindow = new google.maps.InfoWindow({
content: kontent
});
var kontent=“加入事件”
“+”事件标题“+eventtitle+”
“+”事件时间“+eventtime+”
“+”事件持续时间“+eventduration+”
“+”事件类别“+eventcategory;
var infoWindow=new google.maps.infoWindow({
内容:康腾特
});
:InfoWindow构造函数采用InfoWindowOptions对象文字,该文字指定显示信息窗口的初始参数
这意味着您需要更改以下内容:
var infoWindow = new google.maps.InfoWindow({
var kontent = '"<button onClick="MyObject.joinevent(this.id);" id='"+mid+"' class="join btn btn-primary pull-right">Join Event</button><br/><hr/>"+"<b>Event Title</b> "+eventtitle+"<br/>"+"<b>Event Time</b> "+eventtime+"<br/>"+"<b>Event Duration</b> "+eventduration+"<br/>"+"<b>Event Category</b> "+eventcategory';
content: kontent
});
var infoWindow=new google.maps.infoWindow({
var kontent='“加入事件”
“+”事件标题“+eventtitle+”
“+”事件时间“+eventtime+”
“+”事件持续时间“+eventduration+”
“+”事件类别“+eventcategory”;
内容:康腾特
});
致:
var kontent='“加入事件”
“+”事件标题“+eventtitle+”
“+”事件时间“+eventtime+”
“+”事件持续时间“+eventduration+”
“+”事件类别“+eventcategory”;
var infoWindow=new google.maps.infoWindow({
内容:康腾特
});
:InfoWindow构造函数采用InfoWindowOptions对象文字,该文字指定显示信息窗口的初始参数
这意味着您需要更改以下内容:
var infoWindow = new google.maps.InfoWindow({
var kontent = '"<button onClick="MyObject.joinevent(this.id);" id='"+mid+"' class="join btn btn-primary pull-right">Join Event</button><br/><hr/>"+"<b>Event Title</b> "+eventtitle+"<br/>"+"<b>Event Time</b> "+eventtime+"<br/>"+"<b>Event Duration</b> "+eventduration+"<br/>"+"<b>Event Category</b> "+eventcategory';
content: kontent
});
var infoWindow=new google.maps.infoWindow({
var kontent='“加入事件”
“+”事件标题“+eventtitle+”
“+”事件时间“+eventtime+”
“+”事件持续时间“+eventduration+”
“+”事件类别“+eventcategory”;
内容:康腾特
});
致:
var kontent='“加入事件”
“+”事件标题“+eventtitle+”
“+”事件时间“+eventtime+”
“+”事件持续时间“+eventduration+”
“+”事件类别“+eventcategory”;
var infoWindow=new google.maps.infoWindow({
内容:康腾特
});