0

我正在使用此示例中的代码:https ://google-developers.appspot.com/maps/articles/mvcfun/step6

我想在用户进行 dblclick 事件时更改圆圈的颜色,但它不起作用,我不知道如何制作。我也想在双击后隐藏/禁用调整大小标记。

这是我的代码:http: //jsfiddle.net/e4s8P/5/

    google.maps.event.addListener(marker, 'dblclick', function() {

      marker.setDraggable(false);
      marker.setVisible(false);

      //change color of the circle here and hide marker of radius


    });

感谢您的帮助,祝您有愉快的一天!

4

3 回答 3

4

Didn't understand the accepted answer. To change the colours of an existing circle you need to use the setOptions method on Circle.

e.g.

marker.setOptions({
    strokeColor: 'red',
    fillColor: 'red'
});
于 2014-01-08T17:21:26.990 回答
0

这是如何更改圆圈颜色的示例

function DrawCircle(rad) {

rad *= 1600; // convert to meters if in miles
if (draw_circle != null) {
    draw_circle.setMap(null);
}
draw_circle = new google.maps.Circle({
    center: center,
    radius: rad,
    strokeColor: "#FF0000",
    strokeOpacity: 0.8,
    strokeWeight: 2,
    fillColor: "#dedede",
    fillOpacity: 0.35,
    map: map
});

或者

 circleOptions: {
     fillColor: '#dedede'
 }

至于删除标记它只是

google.maps.event.addListener(marker, "dblclick", function() {
    marker.setMap(null);
});
于 2013-05-24T08:51:07.717 回答
0

好的,我通过这个例子找到了答案:https ://google-developers.appspot.com/maps/articles/mvcfun/twittersearch

我改变了我的代码,它可以工作(但不是在 jsfiddle):http: //jsfiddle.net/QQbtM/6/

see jsfiddle
于 2013-05-24T21:30:10.753 回答