Rotate symbol with map

1033
1
12-18-2019 03:22 AM
BerendVeldkamp
Occasional Contributor II

It seems that between version 4.9 and 4.10, display of a graphic's symbol was changed so that it's rotation is always relative to the screen rather than the mapview.

I have added some features to a graphicslayer that I want to point in a certain compass direction, which obviously does not work now. Is there an option to override the default behavior, and set the angle relative to the mapview's rotation?

0 Kudos
1 Reply
UndralBatsukh
Esri Regular Contributor

Hi there, 

You can watch View's rotation property and set the graphic's symbol to match the view.rotation as shown below:

view.watch("rotation", function(r){
  graphic.symbol = {
    type: "picture-marker",
    url: "http://static.arcgis.com/images/Symbols/Transportation/RedTriangleDaymark.png",
    width: 60,
    height: 40,
    yoffset: 20,
    angle: view.rotation
  },
  console.log("view rotation: ", Math.round(r));
  console.log("symbol angle: ", graphic.symbol.angle)
});

Here is a simple app that shows how to rotate the symbol when view rotates.

-Undral