Palette issue in combination with Leaflet


I have problems to use a palette in combination with Leaflet. Since I want all the “dropped” nodes from the palette to stay on the geographic position, I am calculatiing the lat/lng pair ,with the Leflet method, using the location of the node.

var location = diagram.findNodeForData(nodeDataArray[i]).location;
var coordinates = map.containerPointToLatLng({ x: location.x, y: location.y });
diagram.findNodeForData(nodeDataArray[i]).Vd.latlong[0] =; diagram.findNodeForData(nodeDataArray[i]).Vd.latlong[1] = coordinates.lng;

The field “Vd” stores all the properties of the node, including the array “latlong”, which is used to get the location of the node correct, using this binding:
new go.Binding("location","latlong)....

Now I get to my issue, every time I drop a node from the palette on the map it will stay as one would expect, but as soon as the map is moved the will change its position. I know that is because this method is called. diagram.updateAllTargetBindings("latlong");
I figured out what the cause of my issue is. The value inside location is wrong. I always get the same exact value for the location of the node. The picture below shows the value of var location and below that the value of var coordinates
These two values are always the same. This value is calculated inside “addModelChangedListener”, so way before the item is dropped.

So the easiest way to fix this (in my opinion, correct me if I am wrong) is to calculate the the lat/lng as soon as the item has been dropped on the map.
How can I achieve this?
If there is no way to detect when a node is dropped from the palette, do you see any other solution for my problem?

I hope you guys understand what my issue is, if not I am happy to explain it in more detail.

Best regards!

You may be able to keep it really simple. When I tried integrating a palette into our Leaflet sample, I was able to drag nodes from the palette onto the diagram and their locations would update properly upon moving the map.

Have you tried just letting the binding handle the calculation of the latitude/longitude. Do you have a codepen or jsfiddle of your current issues?