1

I've set a mousedown listener on google map v3 to draw a polyline.

map.setOptions({
   draggable: false, 
   zoomControl: false, 
   scrollwheel: false, 
   disableDoubleClickZoom: true,
   disableDefaultUI: true
});

google.maps.event.addDomListener(map.getDiv(),'mousedown',function(e){
   drawPolyline()
});

If the drawing finishes on google's POI then the description bubble opens and kills my function behavior.

If I use one of the built-in tools (drawing a polygon), all POI listeners are disabled.

Can I do the same?

gil
  • 93
  • 1
  • 12

3 Answers3

4

Don't know if this is still relevant, but you can now simply call the setClickableIcons(false) method on your map object when you want to disable clicks.If you want to turn them back on just give the method a true argument instead.

Have a look at this demo I prepared: http://jsbin.com/liyamecoqa/edit?html,output

Wolf Bergenheim
  • 416
  • 5
  • 7
1

you can disable POI this way

            var mlwStyles =[
                {
                    featureType: "poi",
                    elementType: "labels",
                    stylers: [
                          { visibility: "off" }
                    ]
                }
            ];
            var mapOptions = {
                center: new google.maps.LatLng(initLat, initLng),
                zoom: initZoom,
                mapTypeId: google.maps.MapTypeId.SATELLITE,
                mapTypeControl:false,
                scaleControl: true, 
                tilt: 0,
                styles: mlwStyles                   
            };

eventually you can use setOptions for disabling and/or reenabling when you draw your polygon

ScaisEdge
  • 131,976
  • 10
  • 91
  • 107
  • I wish to disable the click listener of POI. Your example will hide the POI and I need to show them at all times. – gil Nov 27 '15 at 16:52
  • 1
    I think you can't because you can only work with POI object not with their behavior., Google do not plan to allow the icons (POI) to be shown without clickability see this for other reference http://stackoverflow.com/questions/7478069/google-map-api-v3-disable-point-of-interest-info-window https://code.google.com/p/gmaps-api-issues/issues/detail?id=3866 – ScaisEdge Nov 27 '15 at 16:57
0

Temporarily put a transparent div over the map to capture click/mouse events, use mouse events on that div to draw the polyline, remove it (or get it out of the way) once the polyline is complete.

geocodezip
  • 158,664
  • 13
  • 220
  • 245