Hello, i have this problem: I created a Button "Locate" that create a new m

Hello, i have this problem:
I created a Button “Locate” that create a new marker in a certain position that comes from two TextFields that contain Longitude and Latitude.
I need that everytime the button is clicked the marker changes his position to the new one.
I tried a lot of time but i haven’t a solution to this problem.
I tried this:

	GoogleMap gmaps = new GoogleMap(apiKey, null, null); 
	gmaps.setMapType(MapType.SATELLITE);
	gmaps.setWidth("500px");
	gmaps.setHeight("330px");
	gmaps.setCenter(new LatLon(44.4997935, 11.3509379));
	GoogleMapMarker marker = new GoogleMapMarker("Location", new LatLon(44.4997935, 11.3509379), true, "");
	gmaps.addMarker(marker);
		//Creating Coords Textfields
	TextField xcoord = new TextField("Latitude.");
	TextField ycoord = new TextField("Longitude");

	//Creating Locate Button
	Button locate = new Button("Locate");
	locate.getStyle().set("margin-top","37px");
	locate.addClickListener(listener ->{
	String x = xcoord.getValue();
	String y = ycoord.getValue();
	gmaps.setCenter(new LatLon(Double.parseDouble(x), Double.parseDouble(y)));
	marker.setPosition(new LatLon(Double.parseDouble(x), Double.parseDouble(y)));
	});

but it doesn’t works.
I tried also to remove the marker and create a new one but it doesn’t works.
I don’t know how to do this.
It seems that the method .setPosition() is not enough, and the marker needs an update somehow.

Can someone help me?
Thanks in advance!

EDIT:
After two days of try i found a solution in 20 minutes since i wrote here.

	gmaps.getElement().removeAllChildren();
	gmaps.addMarker("Location", new LatLon(Double.parseDouble(x), Double.parseDouble(y)), true, "");

gmaps.getElement().removeAllChildren(); removes all markers :)