7
Google지도 api v3은 다각형 또는 폴리선의 시작 또는 끝 편집을 지원하지 않으므로 내 자신을 구성하려고합니다.이벤트 리스너를 제거하지 않고 비활성화 할 수 있습니까?
나는 각 점에 대한 마커를 그린 다음 편집을 마친다. 첫 번째 인덱스 점 ("0")을 클릭 할 때 숨기도록 마커를 설정 한 다음 클릭 가능으로 설정된 다각형을 true로 설정합니다. 그러나 사용자는 여전히지도를 클릭하고 다각형 그리기를 계속할 수 있습니다. 그 이벤트 listner를 사용하지 못하게하고 싶지만 마우스로 다시 사용 가능하게 할 수 있습니다.이 작업을 수행 할 수 있습니까? Remove Listner를 사용하면 다른 listner를 mouseover 할 때 다각형에 다시 부착 할 수있어서 편집 할 수 있습니까?
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});
}
});
+1 아주 좋은 솔루션 (및 설정 disableListener = 사실은 그것을 해제하기) –