我正在使用 gMap2,我想在单击按钮时将标记图像从“marker1.png”更改为“marker2.png” 。我有以下代码:
// Declare the marker
var customMarker = "img/marker1.png";
// Initialize the map
$('#map').gMap({
address: "Paris, France, cité Nollez 3.",
zoom: 12,
markers:[
{
address: "Paris, France, cité Nollez 3.",
html: "_address"
}
],
icon: {
image: customMarker,
iconsize: [61, 63],
iconanchor: [12, 46]
}
});
// Change marker image on button click
$("button").click(function(){
customMarker === "img/marker2.png";
});
这是 jsFiddle:http: //jsfiddle.net/hrLga/
非常感谢!