Feature Collection Layer
Points are added on load
by schlomm
HTML
<script src="http://js.arcgis.com/3.12/init.js"></script>
<link rel="stylesheet" href="http://js.arcgis.com/3.12/esri/css/esri.css">
<link rel="stylesheet" href="http://js.arcgis.com/3.12/dijit/themes/claro/claro.css">
<div id="map">
</div>
SCSS
html,body, body>div{height:100%, width:100%}
JavaScript
var map;
var graphicsArray = [];
require(["esri/map",
"esri/geometry/Geometry",
"esri/geometry/Point",
"esri/geometry/Polyline",
"esri/geometry/Polygon",
"esri/graphic",
"esri/tasks/FeatureSet",
"esri/symbols/SimpleMarkerSymbol",
"esri/symbols/SimpleLineSymbol",
"esri/symbols/SimpleFillSymbol",
"esri/Color",
"esri/InfoTemplate",
"esri/geometry"
], function(Map,
Geometry,
Point,
Polyline,
Polygon,
Graphic,
FeatureSet,
SimpleMarkerSymbol,
SimpleLineSymbol,
SimpleFillSymbol,
Color,
InfoTemplate,
geometry) {
map = new Map("map", {
basemap: "topo",
center: [-106.61, 35.1107],
zoom: 13
});
map.on("load", addSomeGraphics);
var point = new Point(-106.61, 35.1107);
var pointSymbol = new SimpleMarkerSymbol();
var pointAttributes = {
city: "Albuquerque",
state: "New Mexico"
};
var pointInfoTemplate = new InfoTemplate("Albuquerque");
var pointGraphic = new Graphic(point, pointSymbol, pointAttributes).setInfoTemplate(pointInfoTemplate);
var point2 = new Point(-106.61, 35.1107);
var pointSymbol2 = new SimpleMarkerSymbol();
var pointAttributes2 = {
city: "COOL",
state: "COOL"
};
var pointInfoTemplate2 = new InfoTemplate("COOL");
var pointGraphic2 = new Graphic(point2, pointSymbol2, pointAttributes2).setInfoTemplate(pointInfoTemplate2);
graphicsArray.push(pointGraphic);
graphicsArray.push(pointGraphic2);
/*function addSomeGraphics() {
for (i = 0; i < graphicsArray.length; ++i) {
map.graphics.add(graphicsArray[i]);
}
}*/
var featureSet = new FeatureSet();
featureSet.features = graphicsArray;
function addSomeGraphics() {
for (var i = 0, il = featureSet.features.length; i < il; i++) {
// Get the current feature from the featureSet.
// Feature is a graphic
var graphic = featureSet.features[i];
graphic.setSymbol(pointSymbol2);
graphic.setInfoTemplate(pointInfoTemplate);
//Add graphic to the map...