Multiple service areas
Hi everyone,
I new to using the ESRI JS API, and I have a hard time working with arrays and the ESRI ServiceAreaTask. What I would like to do is allow a user to place multiple points and see a 1 and 2 minute response area around each point.
Here is my code
I keep getting the following warning with Firebug: "Graphic is not defined" I am confused since I am defining Graphic as new.
Any help would be greatly appreciated.
function mapClickHandler(evt){
map.graphics.clear(); //clear existing graphics
//define the symbology used to display the results and input point
var pointSymbol = new esri.symbol.SimpleMarkerSymbol(
esri.symbol.SimpleMarkerSymbol.STYLE_DIAMOND,
20,
new esri.symbol.SimpleLineSymbol(
esri.symbol.SimpleLineSymbol.STYLE_SOLID,
new dojo.Color([88,116,152]),
2
),
new dojo.Color([88,116,152,0.45])
);
//map.graphics.add(new esri.Graphic(evt.mapPoint, pointSymbol)).getDojoShape().moveToBack();
//alert(evt.mapPoint.toString());
var geometry = new esri.geometry.Point(evt.mapPoint.x,evt.mapPoint.y,map.spatialReference);
var graphic = new Graphic(geometry);
var inPoint = new array();
for (var i = 1; i < evt.geometry.length; i++) {
inPoint.push();
}
//alert(evt.inPoint.toString());
//var inPoint = new esri.geometry.Point(evt.mapPoint.x,evt.mapPoint.y,map.spatialReference);
//var location = new esri.Graphic(inPoint,pointSymbol);
//map.graphics.add(location);
var features = [];
features.push(location);
var facilities = new esri.tasks.FeatureSet();
facilities.features = features;
params.facilities = facilities;
//solve
serviceAreaTask.solve(params, function(serviceAreaSolveResult){
var serviceAreaSymbol = new esri.symbol.SimpleFillSymbol(
esri.symbol.SimpleFillSymbol.STYLE_SOLID,
new esri.symbol.SimpleLineSymbol(
esri.symbol.SimpleLineSymbol.STYLE_SOLID,
new dojo.Color([232,104,80]),
2
),
new dojo.Color([232,104,80,0.25])
);
dojo.forEach(serviceAreaSolveResult.serviceAreaPolygons,function(serviceArea){
serviceArea.setSymbol(serviceAreaSymbol);
map.graphics.add(serviceArea);
});
}, function(err){
console.log(err.message);
});
}
Thanks