Leaflet geoman setLatLngs not restoring object to the getLatLngs position - leaflet

I have an issue that when leaflet geoman removes a vertex on for example polygon, I cannot restore the latLngs of the object.
What im doing:
On object click -> object.getLatLngs(). Works fine.
If I start editing the object and then object.setLatLngs(ObjectClickLatLngs) it works fine.
But the issue is: Click object -> start editing -> Right click vertex(to delete vertex) -> object.setLatLngs(ObjectclickLatLngs). Now the vertex is deleted and did not restore to the latLngs it had previously.
Try to click the polygon, change a vertex then click "restore object to initial position" (works as expected)
Then click the polygon, but right click a vertex(to delete) without moving it then click "restore object to initial position" (now the object is not in the state it should be, expected it to restore to same position as initial)
https://jsfiddle.net/6tzxg2ds/2/

The Problem is that JavaScript refrence the variable to the source, so when the latlng of the layer is changed, then the restoreLatLngs is also updated.
You can "destroy" the refrence with this:
restoreLatLngs = JSON.parse(JSON.stringify(x.target.getLatLngs()));

Related

Change car size on runtime in AnyLogic

Cars are moving on the road, and I want to use a button to change the scale of the cars.
Once I press the button, the scale of all the cars that are in the system and are being produced by the source should change.
My approach
1. I make a variable "carSize" and put it in "car" 3Objact properties "Additional Scale." shown in image below.
2 Then in "Main" I put this code in a button.
LineCarAgent LineCar = new LineCarAgent();
LineCar.set_carSize(11);
traceln("New car size " + LineCar.carSize);
Now, when I run the model and press the button, I can see the new value printed in the console, but the size of the car does not change, neither for existing cars nor for upcoming cars.
If you know which car you want to have the shape scale change, use:
cars.get(i).car.setScale(s);
We can use a loop to go through "cars" population and change the scale of all the cars one by one.
The only issue is that if we include "loop" in the button, then only the scale of the existing population will change. So what we can do is put the loop in the cyclic event to keep changing the scale of the new coming car.
Step 1: Create an cyclic event and put this code in the action
for (int i = 0; i < cars.size(); i++) {
cars.get(i).car.setScale(0.9);
}
Step 2: We don't want the code in the event to start executing unless we press the button, so "on startup" write event.suspend(); and in the button action, write event.restart();.
Now event will only start once we press the button. Which means that all the cars scale will only change when we press the button.

Unity3D How to copy object to paste at same position?

I want to copy object and paste at same position by using Ctrl+c Barn1_Door_A at the center of map like this image.
when I paste by Ctrl+v the object is out of map like this image.
The component value of object is same value but why it paste out of map. How to fix it?
Highlight Barn1_Door_A and press Ctrl+d. It should duplicate the gameobject in the same location.
The only reason I can think of why your object isn't located in the same spot as the other one is the it is being made in a different place in the hierarchy (i.e not as a child of LockedBuildings)

How to track down in which application is signal handler defined gtk/gtkmm for some button

The problem:
You wanna contribute to the some gnome/gtk/gtkmm project since you've noticed and know a way that things could be made better / you wanna fix some bug. Here are steps to get you started.
Example problem:
"Clean" button in Gnome Builder isn't doing anything to my project and since at this point I believe it is just empty function with placeholder button I wanna implement actual action.
Here are steps:
open application that you wanna modify in terminal where environment GTK_DEBUG=interactive environment variable is set. so run GTK_DEBUG=interactive gnome-builder
Gtk inspector should have opened and you should see bunch of Objects displayed. If you click on Object in inspector, that object should light up in your application
Gtk has clear hierarchy, so parent contains children, and your job is to detect in which parent is child that you want to modify
When you figure which parent you want click on arrow next to the name of that parent to reveal its children
Repeat steps 3. and 4. by applying 2. to get to the child that you want to modify
For example my path is IdePrimaryWorkspace -> GtkPopover -> GtkBox -> DzlPriorityBox -> GbpBuilduiOmniBarSection -> GtkBox -> GtkBox -> GtkButton
Double click last interactive entry (such as GtkButton
on the left, in drop-down switch to Properties view
find property that you want, mine is GtkActionable, and it's value is builder-manager.clean
open source folder in terminal of application that you are interested in (clone source of that application)
type in command tree | grep build-manager
if there are entries with that filename type in find . --name=filenameof.your.file
get file path, open that file in text editor/IDE, change stuff inside
submit patches

KineticJS: Animate an item to go back to initial position when not dropped in drop target

I made an application which performs drag and drop of different items: images and shapes. I limited the drop target to a specific layer: rightLayer in my case using a simple test with if ... else. Everything works great, except that I want to make an item revert back to its original position in the leftLayer when it doesn't attempt the borders of rightLayer (just like jquery, but in kineticJS). Or just disappear instantly.
Here's a JSFIDDLE . For a better understanding, try this use case:
drag the rectangle,
drop it right before the grid,
click on an item from the left layer.
You can self-destruct any clone dropped other than in the dropzone with a test in dragend.
A Demo: http://jsfiddle.net/m1erickson/2T68g/
clone1.on("dragend",function(){
// destroy this clone if dropped outside the dropzone
if(this.x()<dropzone.x()){
this.destroy();
layer.draw();
}
});

open and play a scene in Unity3d

I have done a project with many scenes in Unity3D.
In the first scene there are buttons, each of them will play a scene when clicked.
For example, if the player clicks the button “Show the balloon”, then the scene called Balloon (which contains a balloon object and its animation) will be opened.
How can I do it using JavaScript code?
See Application.LoadLevel(...).
From the documentation:
[...]. Before you can load a level you have to add it to the list of levels
used in the game. [...]
// Loads the level with index 0
Application.LoadLevel (0);
// Load the level named "HighScore".
Application.LoadLevel ("HighScore");
First thing you have to do is add all the levels you want into the Build Settings Property.
Go to Unity or File Menu, Build Settings, and drag and drop your scenes into the scroll window. Then it'll assign them a logical number (or you can reference by name).
Application.LoadLevel(0); // this loads the first level in the list
Application.LoadLevel("nameoflevel"); //does the same thing numerically except by name
Application.LoadLevel(Application.loadedLevel); //reloads current level
Application.LoadLevel(Application.loadedLevel + 1); //loads the next level in order
Application.LoadLevel(Application.loadedLevel - 1); //loads the prior level in order
Application.LoadLevel(Application.levelCount - 1); //loads the last level in list
The int version of LoadLevel takes the id from build settings.
You can also call the string version, which takes the scene name from the project view (Though it still has to be in build settings for it to be found)
Go to File->Build Settings and drag your scenes there then use following.
Application.LoadLevel("Ballon");
If you want to reload the current level, you can use
Application.LoadLevel (Application.loadedLevel);
You'll, of course, need to make sure to manually reset or destroy anything that was created by the scene and marked as DontDestroyOnLoad.
And yes, the only way to put levels in any order in your build is from the build settings menu. You can jump around to which level is loaded by specifying its name or build order, but if you wanted to insert your levels in order in the build sequence and just want to jump from one level to the next (ie, Menu->Level1->Level2->EndGame), you can use
Application.LoadLevel (Application.loadedLevel + 1);