I'm able to use a clicked point for an input facility in a Service Area solve. I can't figure out how to use a selected point from a feature layer in the same Service Area operation.
function initSelectToolbar(map) {
selectionToolbar = new esri.toolbars.Draw(map);
var selectQuery = new esri.tasks.Query();
selectQuery.returnGeometry = true;
dojo.connect(selectionToolbar, "onDrawEnd", function(geometry) {
selectionToolbar.deactivate();
selectQuery.geometry = geometry;
featureSLayer.selectFeatures(selectQuery, esri.layers.FeatureLayer.SELECTION_NEW);
var results = [];
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])
);
// var inPoint = new esri.geometry.Point(evt.mapPoint,map.spatialReference);
//var location = new esri.Graphic(inPoint,pointSymbol);
featureSLayer.getselectedfeatures();
var facilities = new esri.tasks.FeatureSet();
facilities.features = features;
params.facilities = facilities;
//solve
serviceAreaTask.solve(params,function(solveResult){
var result = solveResult;
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])
);
var polygonSymbol = 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(solveResult.serviceAreaPolygons, function(serviceArea){
serviceArea.setSymbol(polygonSymbol);
map.graphics.add(serviceArea);
var query = new esri.tasks.Query();
query.geometry = serviceArea.geometry;
var symbol = new esri.symbol.SimpleMarkerSymbol();
symbol.style = esri.symbol.SimpleMarkerSymbol.STYLE_SQUARE;
symbol.setSize(8);
symbol.setColor(new dojo.Color([255,255,0,0.5]));
featureSLayer.setSelectionSymbol(symbol);
dojo.byId('messages').innerHTML = "<b>Selecting Features...</b>";
featureSLayer.selectFeatures(query, esri.layers.FeatureLayer.SELECTION_NEW);
});
Anyone know how to use a selected feature as an input into a Service Area?Thanks!