我正在使用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/
非常感谢!
答案 0 :(得分:0)
我相信你需要在更改customMarker后再次调用gMap。