是否有可能,如果标记半径相互交叉而不是绘制标记?

时间:2016-01-12 07:42:17

标签: javascript google-maps google-maps-api-3

这是我的代码谷歌地图带圆圈的标记,所以我想要点击不要绘制标记如果theres圆圈相互交叉

  google.maps.event.addListener(map, 'click', function(event) {
     var marker3 = placeMarker(event.latLng);
       google.maps.event.addListener(marker3, 'click', function(event) {
       });
  });
  function placeMarker(location) {
      var marker3 = new google.maps.Marker({
          position: location,
          map: map,
          draggable:true,   
      });
      radius = new google.maps.Circle(circleRadius);
      radius.bindTo('center', marker3, 'position');
      return marker3;
  }

1 个答案:

答案 0 :(得分:1)

可能的方法: 为每个标记创建2个圆圈,现有的和另一个透明圆圈,第一个标记的半径为半圆。

第二个圆圈在地图上不可见,但仍会在那里阻止地图触发点击事件。

  radius = new google.maps.Circle(circleRadius);
  radius2 = new  google.maps.Circle({fillOpacity:.0001,
                                     strokeWeight:0,
                                     map:radius.getMap(),
                                     radius:radius.getRadius()*2});
  radius.bindTo('center', marker3, 'position');
  radius2.bindTo('center', marker3, 'position');