Update graphic location

2307
10
Jump to solution
04-03-2019 01:56 AM
KennethLindhardt1
Occasional Contributor II

Hi, I need to update a graphic point, so that it always stays in front of the camera:

This is what I’m trying, but although the cameraX and cameraY are perfectly updating with the prober coordinates I can’t figure out how to clone the graphic with the new coordinates, so basically it needs to refresh the points XY with the new values, when I move the camera and then redraw the point. I’ve been searching for a long time for an answer, so I hope I can get some help

var cameraX;
watchUtils.whenTrue(view, "stationary", function() {
cameraX = view.camera.position.longitude ;
});
var cameraY;
watchUtils.whenTrue(view, "stationary", function() {
cameraY = view.camera.position.latitude + 0.05;
});
var point = {
type: "point", // autocasts as new Point()
x: cameraX,
y: cameraY,
0 Kudos
10 Replies
KennethLindhardt1
Occasional Contributor II

This helped, now I just need to remove the graphic, so I only got one:

var cameraX, cameraY, point, markerSymbol, pointGraphic, graphicsLayer;
watchUtils.whenTrue(view, "stationary", function() {
cameraX = view.camera.position.longitude;
cameraY = view.camera.position.latitude + 0.20;
point = {
type: "point", // autocasts as new Point()
x: cameraX,
y: cameraY
};
markerSymbol= {
type: "simple-marker", // autocasts as new SimpleMarkerSymbol()
color: [226, 119, 40],
size : 100,
outline: { // autocasts as new SimpleLineSymbol()
color: [255, 255, 255],
//width:
}
};

pointGraphic = new Graphic({
geometry: point,
symbol: markerSymbol,
});
graphicsLayer = new GraphicsLayer();
map.add(graphicsLayer);

graphicsLayer.add(pointGraphic);
});
0 Kudos