FeatureLayer with points

447
3
04-25-2013 01:28 AM
CristinaJacome
New Contributor
Hello

I have an array of esri.Graphic:
var features = [];

...
//add 6000 points

            var point = new esri.geometry.Point(x, y, new esri.SpatialReference({ wkid: 102100 }));
            var symbol = new esri.symbol.SimpleMarkerSymbol().setStyle(esri.symbol.SimpleMarkerSymbol.STYLE_DIAMOND);
            var graphic = new esri.Graphic(point, symbol);

            features.push(graphic);


Now, I want to draw all that points on a layer, only draw, without events.
How can I do?

I thought add a FeatureLayer, but I get an error:

var featureSet = new esri.tasks.FeatureSet();
featureSet.features = features;
            
            var featureCollection = {
                featureSet: featureSet
            };

            try {

                var layer = new esri.layers.FeatureLayer(featureCollection);

                map.addLayer(layer);
            } catch (err) {
                alert(err.message);
            }



Error: path is not defined.

Thanks
0 Kudos
3 Replies
JohnGravois
Frequent Contributor
if you've already created the graphics, you should be able to pass them to the default map graphics layer using map.graphics.add(graphic)
0 Kudos
CristinaJacome
New Contributor
Thank you for the reply.

The problem is that they are 6000 points. Is there another more efficient way?
Once points are added, the actions on the maps are very slow.
0 Kudos
JohnGravois
Frequent Contributor
there is more than one technique you could use to improve performance.  check out the following article on featureLayer/graphicLayer performance for a more in depth discussion.

here are a couple things to try:

1.  perhaps you could set the minScale property on the map graphics layer so that the features only draw when you're zoomed in closer?

2.  if you are working with a featureLayer from an ArcGIS Server map service, you could display the data in a dynamicMapServiceLayer instead and work with the featureLayer class in selection mode instead to query for individual geometries and attributes on the click of the map. (see sample of this in action)
0 Kudos