Note that there are some explanatory texts on larger screens.

plurals
  1. POcan you disable an event listner without removing it?
    primarykey
    data
    text
    <p>Since google maps api v3 doesn't support start or end editing of a polygon or polyline I am trying to constuct one of my own.</p> <p>I am drawing markers for each point, then to finish editing I set all marker to hide when the first index point ("0") is clicked then set the polygon to clickable is true. But the user can still click the map and continue drawing the polygon. I want to disable that event listner but re-enable it on mouse over.. Can this be done? If I use Remove Listner can I reattached another listner to the polygon on mouseover so they can edit it?</p> <pre class="lang-js prettyprint-override"><code>MapShaper.Feature.prototype.poly = function(type) { var color = MapShaper.getColor(false), path = new google.maps.MVCArray, poly, self = this, el = type + "_b"; if(type=="shape"){ poly = self.createShape( {strokeWeight: 3, fillColor: color}, path ); }else if(type=="line"){ poly = self.createLine( {strokeWeight: 3, strokeColor: color }, path ); } poly.markers = new google.maps.MVCArray; google.maps.event.addListener(poly, "mouseover", function(){ poly.markers.forEach(function(polyMarker, index){ polyMarker.setVisible(true); }); }); MapShaper.Feature.prototype.createShape = function(opts, path) { var poly; poly = new google.maps.Polygon({ clickable:false, strokeWeight: opts.strokeWeight, fillColor: opts.fillColor }); poly.setPaths(new google.maps.MVCArray([path])); return poly; } MapShaper.Feature.prototype.createShape = function(opts, path) { var poly; poly = new google.maps.Polygon({ clickable:false, strokeWeight: opts.strokeWeight, fillColor: opts.fillColor }); poly.setPaths(new google.maps.MVCArray([path])); return poly; } google.maps.event.addListener(marker, 'click', function() { if (!marker.index == 0) { marker.setMap(null); markers.removeAt(marker.index); path.removeAt(marker.index); MapShaper.reindex(markers); if(markers.getLength() == 0){ MapShaper.removeFeature(poly.id); } } else { markers.forEach(function(marker, index) { marker.setVisible(false) }); poly.setOptions({clickable: true}); } }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload