0

我正在使用 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/

非常感谢!

4

1 回答 1

0

我相信您需要在 customMarker 更改后再次调用 gMap 。

于 2013-07-08T06:17:34.883 回答