我正在使用 jQuery 插件 gmap3。我可以将多个标记添加到地图中,但我试图为其中一个提供信息窗口时遇到了困难。
如果我删除注释“//添加带有信息窗口的标记”下的代码,则会创建标记但没有信息窗口。使用代码如何创建没有地图。
$('#test').gmap3(
//create the map
{ action:'init'
},
//add a marker with info window
{ action: 'addInfoWindow',
address: "London"
},
infowindow:{
options:{
content: 'This is London'
},
apply:[
{ action:'setContent',
args:[
'<span style="color:#000">Here is a new content !<span>'
]
}
]
},
//add a marker
{ action: 'addMarker',
address: "Paris",
},
//add a marker
{ action: 'addMarker',
address: "Madrid",
}
//autofit the map view
,
"autofit"
);
我假设这是一个语法问题,但我完全卡住了,所以非常感谢任何帮助。谢谢
更新除了自动调整功能不起作用外,我已经让它与以下内容一起使用。
$('#test').gmap3({
action: 'addMarker',
address: "place de l'étoile, Paris",
marker:{
options:{
draggable: false
}
},
infowindow:{
options:{
content: 'Hello World !'
},
events:{
closeclick: function(){
alert("closing : " + $(this).attr("id"));
}
}
}
},
//add a marker
{ action: 'addMarker',
address: "London",
},
"autofit"
);