0
我已經調整openlayers basic draw example,每當我切換從點到線段形式或多邊形繪圖模式,它只是爲首次正常工作,但失敗的加時賽切換。改變繪圖儀器上飛
F.I.使用線段形式後,我無法回到繪圖點(它繼續吸引我的線串,但日誌drawingtool是打印點)
我的HTML的按鈕模式:
<div class="modal-body row">
<div class="col-xs-12 col-sm-3">
<a id="Point" href="#" class="draw btn btn-primary btn-block"><span class="icon ion-android-pin"></span> Point</a>
</div>
<div class="col-xs-12 col-sm-3">
<a id="LineString" href="#" class="draw btn btn-primary btn-block"><span class="icon ion-android-pin"></span> Polyline</a>
</div>
<div class="col-xs-12 col-sm-3">
<a id="Polygon" href="#" class="draw btn btn-primary btn-block"><span class="ion ion-ios-grid-view-outline"></span> Polygon</a>
</div>
<div class="col-xs-12 col-sm-3">
<a href="#" class="btn btn-primary btn-block"><span class="ion ion-pinpoint"></span> Coordinates</a>
</div>
</div>
</div>
這裏是JS的一部分:
function addInteraction() {
draw = new ol.interaction.Draw({
features: features,
type: /** @type {ol.geom.GeometryType} */ (drawtool)
});
map.addInteraction(draw);
}
$('.draw').on("click", function(e) {
//e.preventDefault(); - commented by me - no difference
drawtool = $(this).attr('id');
$("#drawModal").modal('toggle');
addInteraction();
});
您還可以找到整個代碼上jsFiddle
謝謝,我無法弄清楚如何刪除現有的互動。你也可以給方向更清潔和更周到的方向是什麼? – Kaha