Hi Walter!
It does indeed offers the connection that I thought I would need, but unfortunately that does not seem to solve the problem.
I’ll try to explain the problem and a way to produce the bug very detailed, so perhaps you can recognize, where the problem could be.
This is the initial situation:
I placed a node in the center of UK and another one in the center of Denmark. You can see the initial coordinates and that there are no transactions in the console.
In the next step, I moved the left node to the southern part of UK:
So, of course, coordinates change accordingly and there is a first transaction (move).
After that I zoomed out, still having the same undo history and coordinates:
Then, I undoed the Move transaction leading to this:
The coordinates are correct (the second node has the coordinates again from the beginning), but it is not displayed correctly and the link is a complete mess.
After moving the left node just a tiny bit, its that way:
So, link is corrected, but the coordinates from the nodedataarray somehow dont fit with the map anymore.
Zooming in and out leaves again to the correct locations:
That’s how I handle locations:
The Bindings:
new go.Binding("location", "location", (data) => this.setMapLocation(data)).makeTwoWay((pt, data) => this.setMapLocationTwoWay(pt, data))
setMapLocation(data){
var point;
if(this.myLeafletMap){
point = this.myLeafletMap.latLngToContainerPoint(data);
}
else{
point = new L.Point(data[0], data[1]);
}
return new go.Point(point.x, point.y);
}
setMapLocationTwoWay(pt, data){
if (this.myUpdatingGoJS) {
return data.location; // no-op
} else {
if(this.myLeafletMap){
var ll = (this.myLeafletMap.containerPointToLatLng([pt.x, pt.y]));
return [ll.lat, ll.lng];
}
else{
return [pt.x, pt.y];
}
}
}
After Map Moving:
this.myLeafletMap.on("moveend", e => this.onMoveEnd(e));
onMoveEnd(e){
this.myUpdatingGoJS = true;
this.myDiagram.updateAllTargetBindings("location"); // Without virtualization this can be slow if there are many nodes
this.myDiagram.redraw(); // At the expense of performance, this will make sure GoJS positions are updated immediately
this.myUpdatingGoJS = false;
this.myDiagram.skipsUndoManager = false;
}
After Map Zooming:
this.myLeafletMap.on('zoomend', e => this.onZoomEnd(e));
onZoomEnd(e: L.LeafletEvent){
this.adaptNodeScales();
this.myUpdatingGoJS = true;
this.myDiagram.updateAllTargetBindings("location");
this.myDiagram.redraw();
this.myUpdatingGoJS = false;
this.adaptLabelPositions();
}
And finally the change from first question:
[...]
"undoManager.isEnabled": true,
"ModelChanged": e => {
if (e.isTransactionFinished && this.myLeafletMap) {
this.myUpdatingGoJS = true;
this.myDiagram.updateAllTargetBindings("location");
this.myDiagram.redraw();
this.myUpdatingGoJS = false;
this.adaptLabelPositions();
}
},
[...]
So, the nodes should always be feeded with the correct lat/lng coordinates, which is also underlined by the example above, but still I cannot seem to have it displayed correctly.
Perhaps you have an idea how to solve this issue cause I dont.
Thanks again!
Jonas