Google地图如何将图像添加到InfoWindow中 [英] Google Maps How to add Image into InfoWindow
本文介绍了Google地图如何将图像添加到InfoWindow中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好我正在尝试将图片添加到Google地图infoWindow中,我的代码就像这样一个脚本
var ContactUs = function(){
return {
//主函数启动模块
init:function(){
var map;
$(document).ready(function(){
map = new GMaps({$ b $ div:'#map',
lat:-13.004333,
ng :-38.494333,
});
var marker = map.addMarker({
lat:-13.004333,
lng:-38.494333,
title:'Loop,
infoWindow:{
content:< b> Loop,Inc.< b> 795 Park Ave,Suite 120<旧金山,CA 94107"
}
});
marker.infoWindow.open(map,marker);
});
}
};
}();
然后在我的HTML中就像这样调用:
< div class =row-fluid>
< div id =mapclass =gmaps margin-bottom-40style =height:400px;>< / div>
< / div>
我尝试在脚本文件中添加图片标记,但它不起作用,我知道我有在html文件中添加一些代码,而不是确定是什么?使用这个,我试过这个在我的app:
infoWindow.setContent(html);
infoWindow.open(map,marker);
而不是:
infoWindow:{
content:< b> Loop,Inc.< / b> 795 Park Ave,Suite 120< br>旧金山,CA 94107
}
Hi I am trying to add an image into a google maps infoWindow, my code is like this a script
var ContactUs = function () {
return {
//main function to initiate the module
init: function () {
var map;
$(document).ready(function(){
map = new GMaps({
div: '#map',
lat: -13.004333,
lng: -38.494333,
});
var marker = map.addMarker({
lat: -13.004333,
lng: -38.494333,
title: 'Loop, Inc.',
infoWindow: {
content: "<b>Loop, Inc.</b> 795 Park Ave, Suite 120<br>San Francisco, CA 94107"
}
});
marker.infoWindow.open(map, marker);
});
}
};
}();
Then in my HTML it gets called like this:
<div class="row-fluid">
<div id="map" class="gmaps margin-bottom-40" style="height:400px;"></div>
</div>
I tried adding an image tag into the script file but it doesn't work, I understand I have to add some code in the html file instead but not sure as to what?
解决方案
Use this, I tried this one in my app:
infoWindow.setContent(html);
infoWindow.open(map, marker);
Instead of:
infoWindow: {
content: "<b>Loop, Inc.</b> 795 Park Ave, Suite 120<br>San Francisco, CA 94107"
}
这篇关于Google地图如何将图像添加到InfoWindow中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文