AnsweredAssumed Answered

Scaling a graphic

Question asked by hali@lmkt.com on Aug 5, 2016
Latest reply on Aug 8, 2016 by hali@lmkt.com

I want to scale a  line graphic on scale event and below is the the code of what i am doing

 

myEditor.editToolbar.on('scale', function(e) {

     var tt = transform(e.graphic.geometry, e.info.scaleX, e.info.scaleY);

 

     tsymbolGraphic.setGeometry(tt);

 

          // and then drawing the tsymbolGraphic on map

});

 

///and my transform function

 

function transform(geometry,scaleX,scaleY)

  {  // currently for polyline

 

  var poly = new Polyline(geometry.spatialReference);

  var screenPoint,mapPoint;

 

  arrayUtils.forEach(geometry.paths,function(path,i)

  {

  poly.paths[i] = [];

  arrayUtils.forEach(path,function(pnt,j)

  {

  screenPoint = map.toScreen(new Point(pnt[0],pnt[1], geometry.spatialReference));

 

  screenPoint.x = screenPoint.x * scaleX  + 5  ;

  screenPoint.y = screenPoint.y * scaleY  + 5 ;

 

  mapPoint =  map.toMap(screenPoint);

  poly.paths[i][j] = [mapPoint.x,mapPoint.y];

  });

  });

  return poly;

  }

 

here is the link of full code https://jsfiddle.net/0fy3v8yr/

Outcomes