require(["esri/Graphic"], function(Graphic) { /* code goes here */ });
Class: esri/Graphic
Inheritance: Graphic Accessor
Since: ArcGIS API for JavaScript 4.0

A Graphic is a vector representation of real world geographic phenomena. It can contain geometry, a symbol, and attributes. A Graphic is displayed in the GraphicsLayer.

To learn how to work with graphics, see the Get started with graphics tutorial.

See also:

Constructors

new Graphic(properties)

Parameter:
properties Object
optional

See the properties for a list of all the properties that may be passed into the constructor.

Property Overview

Any properties can be set, retrieved or listened to. See the Working with Properties topic.
NameTypeSummary
Object

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

more details
more details
String

The name of the class.

more details
more details
Geometry

The geometry that defines the graphic's location.

more details
more details
FeatureLayer | GraphicsLayer

If applicable, references the layer in which the graphic is stored.

more details
more details
PopupTemplate

The template for displaying content in a Popup when the graphic is selected.

more details
more details
Symbol

The Symbol for the graphic.

more details
more details
Boolean

Indicates the visibility of the graphic.

more details
more details

Property Details

attributesObject

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

Example:
var graphic = new Graphic();
graphic.attributes = {
  "name": "Spruce",
  "family": "Pinaceae",
  "count": 126
};

declaredClassStringreadonly

The name of the class. The declared class name is formatted as esri.folder.className.

geometryGeometry

The geometry that defines the graphic's location.

Z-values defined in a geographic or metric coordinate system are expressed in meters. However, in local scenes that use a projected coordinate system, vertical units are assumed to be the same as the horizontal units specified by the service.

If applicable, references the layer in which the graphic is stored.

popupTemplatePopupTemplate autocast

The template for displaying content in a Popup when the graphic is selected. The PopupTemplate may be used to access a graphic's attributes and display their values in the view's default popup. See the documentation for PopupTemplate for details on how to display attribute values in the popup.

symbolSymbol

The Symbol for the graphic. Choosing a symbol for a graphic depends on the View type (SceneView or MapView), and the geometry type of the graphic.

If the symbol is not specified for a graphic in a FeatureLayer, it displays using the symbol defined in the layer's renderer. Each graphic may have its own symbol specified when the parent layer is a GraphicsLayer.

visibleBoolean

Indicates the visibility of the graphic.

Default Value: true

Method Overview

NameReturn TypeSummary
Graphic

Creates a deep clone of the graphic object.

more details
more details
*

Creates a new instance of this class and initializes it with values from a JSON object generated from a product in the ArcGIS platform.

more details
more details
*

Returns the value of the specified attribute.

more details
more details
PopupTemplate

Returns the graphic's popup template.

more details
more details

Sets a new value to the specified attribute.

more details
more details
Object

Converts an instance of this class to its ArcGIS Portal JSON representation.

more details
more details

Method Details

clone(){Graphic}

Creates a deep clone of the graphic object.

Returns:
TypeDescription
GraphicReturns a deep clone of the graphic.

fromJSON(json){*}static

Creates a new instance of this class and initializes it with values from a JSON object generated from a product in the ArcGIS platform. The object passed into the input json parameter often comes from a response to a query operation in the REST API or a toJSON() method from another ArcGIS product. See the Using fromJSON() topic in the Guide for details and examples of when and how to use this function.

Parameter:
json Object

A JSON representation of the instance in the ArcGIS format. See the ArcGIS REST API documentation for examples of the structure of various input JSON objects.

Returns:
TypeDescription
*Returns a new instance of this class.

getAttribute(name){*}

Returns the value of the specified attribute.

Parameter:
name String

The name of the attribute.

Returns:
TypeDescription
*Returns the value of the attribute specified by name.

getEffectivePopupTemplate(){PopupTemplate}

Returns the graphic's popup template.

Returns:
TypeDescription
PopupTemplateReturns the popup template of the graphic.

setAttribute(name, newValue)

Sets a new value to the specified attribute.

Parameters:
name String

The name of the attribute to set.

newValue *

The new value to set on the named attribute.

toJSON(){Object}

Converts an instance of this class to its ArcGIS Portal JSON representation. See the Using fromJSON() topic in the Guide for more information.

Returns:
TypeDescription
ObjectThe ArcGIS Portal JSON representation of an instance of this class.

API Reference search results

NameTypeModule

There were no match results from your search criteria.