Select to view content in your preferred language

add geometry to feature layer

3141
2
11-01-2010 07:37 PM
ChrisSeeger
New Contributor II
I am looking for an example that will take a provided lat/long and attribute from a form and then create the point (or line) feature in a feature service layer


Any help would be appreciated.
0 Kudos
2 Replies
TimRourke
New Contributor
FeatureLayer inherits from GraphicsLayer, so you should be able to use the add() method. See http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi/graphicslayer.htm#add.

To create a point graphic to add, where pointX and pointY are the x and y from your form:


// Create the Point
var point = new esri.geometry.Point(pointX, pointY, new esri.SpatialReference({ wkid: 4326 }));

// Create a point image symbol:
var symbol = new esri.symbol.PictureMarkerSymbol("/Images/point.png", widthInPixels, heightInPixels);

// Set up the template for the info window.
var infoTemplate = new esri.InfoTemplate("Point attributes", "${*}");

// Create a graphic from the point:
var graphic = new esri.Graphic(point, symbol, infoTemplate);

// Add the graphic
featureLayer.add(graphic);
Substitute your own spatial reference ID for 4326.
0 Kudos
KellyHutchins
Esri Frequent Contributor
The feature layer has an applyedits method that you can use to add new features to a feature layer. The following samples show how to use this method.
http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples_start.htm#jssamples/ed_feature_cre...
http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples_start.htm#jssamples/mobile_geoloca...
0 Kudos