function Init() { $.ajax( { url: "<%=System.Web.HttpContext.Current.Request.ApplicationPath.ToString() %>/Projects/GetProjectDates", cache: false, success: function (data) { loadConstructionDates(data.ProjectDataTable); } } ); var iniExtent = new esri.geometry.Extent({"xmin": 4249987, "ymin": 238755, "xmax": 4315098, "ymax": 274866, "spatialReference":{"wkid":2270}}); map = new esri.Map("map", { extent:iniExtent,logo: false}); map.enableScrollWheelZoom(); var layer = new esri.layers.ArcGISTiledMapServiceLayer(BaseMap); map.addLayer(layer); var streets = new esri.layers.ArcGISTiledMapServiceLayer(TransportationMap); map.addLayer(streets); featureLayer = new esri.layers.FeatureLayer(FeatureMap, { outFields: ["*"], mode: esri.layers.FeatureLayer.MODE_SELECTION, id: "streetsFeatureLayer" }); var fieldsSelectionSymbol = new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255, 255, 255, 0.95]), 2); featureLayer.setSelectionSymbol(fieldsSelectionSymbol); map.addLayer(featureLayer); dojo.connect(featureLayer, "onSelectionComplete", selectionComplete); } function loadConstructionDates(constructionDates) { m_constructionProjectDates = constructionDates; if (m_constructionProjectDates.length > 0) { showConstructionProjects(); } } function showConstructionProjects() { var streetIDs = ""; for (p in m_constructionProjectDates) { var project = m_constructionProjectDates; if (project.StreetIDNUM.length > 0) { var id = project.StreetIDNUM; var query = new esri.tasks.Query(); query.where = "IDNUM = " + id; featureLayer.selectFeatures(query, esri.layers.FeatureLayer.SELECTION_NEW); } } } function selectionComplete() { console.log("This one is done"); }
function showConstructionProjects() { var fieldsSelectionSymbol = new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color("#FF0000"), 4); for (p in m_constructionProjectDates) { var project = m_constructionProjectDates ; if (project.StreetIDNUM.length > 0) { var query = new esri.tasks.Query(); query.where = "IDNUM = " + project.StreetIDNUM; featureLayer.selectFeatures(query, esri.layers.FeatureLayer.SELECTION_NEW, function (features) { for (var i = 0; i < features.length; i++) { var graphic = features; graphic.setSymbol(fieldsSelectionSymbol); streetGraphicsLayer.add(graphic); console.log("Got a graphic"); } }); } } }
function Init() { var iniExtent = new esri.geometry.Extent({"xmin": 4249987, "ymin": 238755, "xmax": 4315098, "ymax": 274866, "spatialReference":{"wkid":2270}}); map = new esri.Map("map", { extent:iniExtent,logo: false}); var layer = new esri.layers.ArcGISTiledMapServiceLayer(BaseMap); map.addLayer(layer); var streets = new esri.layers.ArcGISTiledMapServiceLayer(TransportationMap); map.addLayer(streets); dojo.connect(map, "onLoad", function() { $.ajax( { url: "<%=System.Web.HttpContext.Current.Request.ApplicationPath.ToString() %>/Projects/GetProjectDates", cache: false, success: function (data) { loadConstructionDates(data.ProjectDataTable); } }); }); } function loadConstructionDates(constructionDates) { m_constructionProjectDates = constructionDates; if (m_constructionProjectDates.length > 0) { showConstructionProjects(); } } function showConstructionProjects() { var streetIds = ""; for (p in m_constructionProjectDates) { var project = m_constructionProjectDates ; if (streetIds.length < 1) { streetIds = project.StreetIDNUM; } else { streetIds = streetIds + "," + project.StreetIDNUM; } } var fieldsSelectionSymbol = new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255,255,255,0.95]), 2); var service = '<%= System.Configuration.ConfigurationManager.AppSettings["StreetsFeatureService"].ToString() %>'; featureLayer = new esri.layers.FeatureLayer(service, { mode: esri.layers.FeatureLayer.MODE_SNAPSHOT, outFields: ["*"], infoTemplate: infoTemplate }); dojo.connect(featureLayer,"onMouseOut",mouseOutHandler); featureLayer.setDefinitionExpression("IDNUM IN '" + streetIds + "'"); featureLayer.setSelectionSymbol(fieldsSelectionSymbol); map.addLayer(featureLayer); }