HI GiS folks, Can anyone answer to problem with my code below. I am using Geocode widget to find locations around the world. Once I found the POI, then used the Buffer parameters to buffer around the POI. Up until here the code below work fine, when I further want to use buffered POI or region to query against my custom FeatureLayer service, to find out only points that fall within my buffered areas within distances, it can't identify the features that fall inside the buffered area. can anyone look into to this please to boost my energy levels.
var map; var gPoint; var gsvc; var gGraphic; var graphic; var locator; var currentLocation; var watchLocation; var myQueryTask; var myQuery;
esri.config.defaults.io.proxyUrl = "http://localhost:53303/proxy/proxy.ashx"; // for ASP.net application use this proxy. // esri.config.defaults.io.proxyUrl = "/proxy";
// var startExtent = new Extent(2264982.7047277316, 6425602.130388378, 1726864.6604362514, 8240522.929991121, // new SpatialReference({ wkid: 102100 }));
function buffer() { map.graphics.clear(); var bufferParameters = new BufferParameters(); bufferParameters.distances = [dojo.byId("distance").value]; // bufferParameters.distances = [1]; bufferParameters.bufferSpatialReference = new SpatialReference({ wkid:102100 }); bufferParameters.outSpatialReference = map.spatialReference; bufferParameters.unit = GeometryService[dojo.byId("unit").value]; bufferParameters.geometries = [gPoint]; gsvc.buffer(bufferParameters, bufferDraw); //gsvc.buffer(bufferParameters);
}
/* gsvc.on("buffer-complete", function(result) {
var symbol = new SimpleFillSymbol( SimpleFillSymbol.STYLE_NULL, new SimpleLineSymbol( SimpleLineSymbol.STYLE_SHORTDASHDOTDOT, new Color([105, 105, 105]), 2 ), new Color([255, 255, 0, 0.25]) ); var bufferGeometry = result.geometries[0] var graphic = new Graphic(bufferGeometry, symbol); map.graphics.add(graphic);
//Select features within the buffered polygon. To do so we'll create a query to use the buffer graphic //as the selection geometry. var mySBIquery = new Query(); mySBIquery.geometry = bufferGeometry; flSBI.selectFeatures(mySBIquery, FeatureLayer.SELECTION_NEW);
});*/
// SBI Branch Locations - Feature Service created by Ganesh var infoSBITemplate = new InfoTemplate("SBI Bank Locations", "Bank Name: ${BankName}<br/>" + "Bank Address: ${BankAddres}<br/>" + "Manager Name: ${Manager}<br/>" + "Opening Time: ${Time}");
var mySBIQueryTask = new QueryTask(flSBIUrl); var mySBIQuery = new Query(); mySBIQuery.returnGeometry = true; mySBIQuery.outFields = ["*"];
// buffer - navigator point location
function bufferDraw(geometries) { var symbol = new esri.symbol.SimpleFillSymbol("none", new esri.symbol.SimpleLineSymbol("solid", new dojo.Color([255, 0, 0]), 2), new dojo.Color([255, 255, 0, 0.25])); var graphic = new esri.Graphic(geometries[0], symbol); map.graphics.add(graphic);
/* var mySBIQuery = new Query(); mySBIQuery.geometry = geometries.geometries[0]; flSBI.selectFeatures(mySBIQuery, FeatureLayer.SELECTION_NEW);*/
}
dojo.connect(mySBIQueryTask, "onComplete", function (fset) {
alert("Finally Reached!!!"); var symbol = new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_SQUARE, 10, new
esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255, 0, 0]), 1), new dojo.Color([0, 255, 0, 0.25]));
var resultFeatures = fset.features; for (var i = 0, il = resultFeatures.length; i < il; i++) { var pt_graphic = resultFeatures; pt_graphic.setSymbol(symbol); pt_graphic.setInfoTemplate(infoTemplate); map.graphics.add(pt_graphic); } });
function enableSpotlight() { var html = "<div id='spotlight' class='spotlight'></div>" domConstruct.place(html, dom.byId("map_container"), "first"); }
esri.config.defaults.io.proxyUrl = "http://localhost:53303/proxy/proxy.ashx"; // for ASP.net application use this proxy. // esri.config.defaults.io.proxyUrl = "/proxy";
// var startExtent = new Extent(2264982.7047277316, 6425602.130388378, 1726864.6604362514, 8240522.929991121, // new SpatialReference({ wkid: 102100 }));
var bufferParameters = new BufferParameters(); bufferParameters.distances = [dojo.byId("distance").value]; // bufferParameters.distances = [1]; bufferParameters.bufferSpatialReference = new SpatialReference({ wkid: 102100 }); bufferParameters.outSpatialReference = map.spatialReference; bufferParameters.unit = GeometryService[dojo.byId("unit").value];
bufferParameters.geometries = [gPoint];
gsvc.buffer(bufferParameters, bufferDraw); }
function bufferDraw(geometries) { var symbol = new esri.symbol.SimpleFillSymbol("none", new esri.symbol.SimpleLineSymbol("solid", new dojo.Color([255, 0, 0]), 2), new dojo.Color([255, 255, 0, 0.25])); var graphic = new esri.Graphic(geometries[0], symbol); map.graphics.add(graphic);
addSBILocations(graphic);
}
function addSBILocations(Results) {
// SBI Branch Locations - Feature Service created by Ganesh var infoSBITemplate = new InfoTemplate("SBI Bank Locations", "Bank Name: ${BankName}<br/>" + "Bank Address: ${BankAddres}<br/>" + "Manager Name: ${Manager}<br/>" + "Opening Time: ${Time}");