Graphic

(esrith/amos/map/Graphic)

Extended from esri/graphic.

Description
new Graphic(geometry?symbol?attributes?infoTemplate?)

Creates a new Graphic object.

new Graphic(json)

Creates a new Graphic object using a JSON object.

Return type Description
redo() Graphic

set geometry to next operation.

startEdit(arg) Esri/toolbars/edit

start operation for edit a graphic such as move, resize and rotate.

stopEdit(saveEdit) None

stop operation.

undo() Graphic

set geometry to previously operation.

Constructors Detail
new Graphic(geometry?symbol?attributes?infoTemplate?)

Creates a new Graphic object.

Parameters:
  • <Esri/geometry/Geometry> geometry Optional

    The geometry that defines the graphic.

  • <Esri/symbols/Symbol> symbol Optional

    Symbol used for drawing the graphic.

  • <Object> attributes Optional

    Name value pairs of fields and field values associated with the graphic.

  • <Esri/InfoTemplate> infoTemplate Optional

    The content for display in an InfoWindow.

new Graphic(json)

Creates a new Graphic object using a JSON object.

Parameters:
  • <Object> json Required

    JSON object representing the esri/graphic.

Sample:
     //Create a line
             require([
               "esri/graphic", ... 
             ], function(Graphic, ... ) {
               var myLine ={geometry:{"paths":[[[-91.40625,6.328125],[6.328125,19.3359375]]],
                 "spatialReference":{"wkid":4326}},
                 "symbol":{"color":[0,0,0,255],"width":1,"type":"esriSLS","style":"esriSLSSolid"}};
               var gra= new Graphic(myLine);
               ...
             });
     //Create a polygon
             require([
               "esri/graphic", ... 
             ], function(Graphic, ... ) {
               var myPolygon = {"geometry":{"rings":[[[-115.3125,37.96875],[-111.4453125,37.96875],
                 [-99.84375,36.2109375],[-99.84375,23.90625],[-116.015625,24.609375],
                 [-115.3125,37.96875]]],"spatialReference":{"wkid":4326}},
                 "symbol":{"color":[0,0,0,64],"outline":{"color":[0,0,0,255],
                 "width":1,"type":"esriSLS","style":"esriSLSSolid"},
                 "type":"esriSFS","style":"esriSFSSolid"}};
               var gra = new Graphic(myPolygon);
               ...
             });
Methods Detail
<Graphic>
redo
()

set geometry to next operation.

<Esri/toolbars/edit>
startEdit
(
  • arg
)

start operation for edit a graphic such as move, resize and rotate.

Parameters
  • <Object> arg Required
    • <String> tool Optional

      see constant of esri/toolbars/edit default: Edit.EDIT_TEXT | Edit.EDIT_VERTICES | Edit.MOVE | Edit.ROTATE | Edit.SCALE

    • <Object> options Optional

      see options in activate method of esri/toolbars/edit

    • <String[]> events] see options in activate method of esri/toolbars/edit default: ["graphic-move-stop", "rotate-stop", "scale-stop", "vertex-add", "vertex-delete", "vertex-move-stop" Optional
    • <Function> callback Optional

      function to call when graphic will be edited.

stopEdit
(
  • saveEdit
)

stop operation.

Parameters
  • <Boolean> saveEdit Required

    If false, operation will be cancel (undo to first operation).

<Graphic>
undo
()

set geometry to previously operation.