2017-01-26 5 views
0

グラフィックスの移動中に次のコードを読み込みます(スケーリングとローテーションで同様のコードが使用されます)。arcgisを使用してmove/scale/rotateに正しいアンドゥ/リドゥ操作を追加できません

//Obtaining the graphic before it is moved 
moveToolbar.on("graphic-move-start", function (evt) { 
oldGraphicMove = evt.graphic; 
}); 

//Updating the graphic on move end 
moveToolbar.on("graphic-move-stop", function (evt) { 

    //Creating the operation to add to the undomanager 
    var operation = new Update({ 
    featureLayer: evt.graphic._graphicsLayer, //The layer that will contain the modified graphic 
    preUpdatedGraphics: [oldGraphicMove], //The graphic before the changes are created 
    postUpdatedGraphics: [evt.graphic] //The graphic after the changes are made 
}); 

//Adding the undo/redo operation 
undoManager.add(operation); 
//Updating the graphic 
evt.graphic._graphicsLayer.applyEdits(null, [evt.graphic], null); 

});

何らかの理由で、前の古い図形は新しい図形と同じ状態を維持します。操作が追加された後は、前と後の図形が等しくなっているので元に戻す/やり直すことはありません。

私は何が間違っているかも知りません、これについての手がかりは?

+0

JSBINでいくつかのサンプルを共有できますか?助けが簡単になります。私はmoveToolbarがグラフィックレイヤーだと思うが、より多くの情報が良いだろう。ところで、あなたは範囲外のevtを使用していますか? BTW:[このサンプル](https://developers.arcgis.com/javascript/3/sandbox/sandbox.html?sample=graphics_undoredo)を知っているでしょうか? – hhkaos

+0

JSBIN? moveToolbarはesriのツールバーです。ツールバーに割り当てられた操作と割り当てられたレイヤーに応じて、マップ上のレイヤーに影響を与えます。moveToolbar.activate(esri.toolbars.Edit.MOVE | esri.toolbars.Edit.SCALE | esri.toolbars .Edit.ROTATE、tempMoveLayer.graphics [graphicNum]) また、私はそれについて知っているし、グラフィックスの追加、編集、削除については、問題はないし、頂点の動きを元に戻したりやり直したりすることもできます。問題は、移動、スケール、回転です – Maeglin77

答えて

0

編集開始時のoldGraphicMove変数は、編集終了時のevt.graphicによって上書きされていたようです。これは、それがむしろ変数に直接グラフィックを割り当てるよりも、編集された前のグラフィックの仕様に新しいグラフィックを作成することで解決されました:

//Obtaining the graphic before it is scaled 
moveToolbar.on("scale-first-move", function (evt) { 
    oldGraphicScale = new esri.Graphic(evt.graphic.geometry,evt.graphic.symbol,evt.graphic.attributes); 
                }); 

//Updating the graphic on scale end 
moveToolbar.on("scale-stop", function (evt) { 

    newGraphicScale = new esri.Graphic(evt.graphic.geometry, evt.graphic.symbol, evt.graphic.attributes); 

    //Creating the operation to add to the undomanager 
    var operation = new Update({ 
     featureLayer: evt.graphic._graphicsLayer, //The layer that will contain the modified graphic 
     preUpdatedGraphics: [oldGraphicScale], //The graphic before the changes are created 
     postUpdatedGraphics: [newGraphicScale] //The graphic after the changes are made 
                 }); 

//Adding the undo/redo operation 
undoManager.add(operation); 

//Updating the graphic 
evt.graphic._graphicsLayer.applyEdits(null, [evt.graphic], null); 
                }); 

は、元に戻す/やり直しの動き、しかし、この方法にはいくつかの問題が残っていますスケールと回転の元に戻す/やり直すことができます。

関連する問題