/* File: map.js Creation Date: 2015-05-28 Author: Larry Wilbourn Copyright: AEgis Technologies * This script is required for mainapp and should be place at the top of the page within map css/scripts, after jquery but before mainapp-head * jQuery actions: */ log_msg('map.js loaded'); var LayerUrl = "http://ec2-54-163-148-251.compute-1.amazonaws.com:6080/arcgis/rest/services/BackgroundService/MapServer/"; var layers = []; var NewLayersUrl = "http://ec2-54-163-148-251.compute-1.amazonaws.com:6080/arcgis/rest/services/BackgroundService2/MapServer/"; var NewLayers = []; var LayerUrlNew = "http://ec2-54-163-148-251.compute-1.amazonaws.com:6080/arcgis/rest/services/EDPANewData/MapServer/"; var layersNew = []; var LayerUrl2 = "http://ec2-54-163-148-251.compute-1.amazonaws.com:6080/arcgis/rest/services/BackgroundService2/MapServer/"; var layers2 = []; var LayerUrl3 = "http://ec2-54-163-148-251.compute-1.amazonaws.com:6080/arcgis/rest/services/FinalAdditions/MapServer/"; var layers3 = []; var DoCountySelectTool = false; /* var controlled by .CountySelectToolBtn, defined in mainapp-bottom.js */ var HasUserSearchedforABuildingYet = false; var HasUserSearchedforASiteYet = false; var HasUserChangedTheDefaultMapView = false; var PartnerUsePolygon = false; var PartnerUseRadius = false; var Partnergeometry = ""; var PartnerCircleGeo = ""; var BuildingUsePolygon = false; var BuildingUseRadius = false; var Buildinggeometry = ""; var BuildingCircleGeo = ""; var SiteUsePolygon = false; var SiteUseRadius = false; var Sitegeometry = ""; var SiteCircleGeo = ""; var IncUsePolygon = false; var IncUseRadius = false; var Incgeometry = ""; var IncCircleGeo = ""; var DidUserChangeMapView = false; var map, dialog, locator, tb, tb2, tb3, tb4; require([ "esri/map", "dojo/parser", "esri/layers/FeatureLayer", "esri/tasks/locator", "esri/config", "esri/layers/ArcGISDynamicMapServiceLayer", "esri/geometry/webMercatorUtils", "esri/units", "esri/layers/GraphicsLayer", "esri/layers/ImageParameters", "esri/symbols/SimpleFillSymbol", "esri/symbols/SimpleLineSymbol", "esri/renderers/SimpleRenderer", "esri/symbols/SimpleMarkerSymbol", "esri/symbols/PictureMarkerSymbol", "esri/graphic", "esri/geometry/normalizeUtils", "esri/tasks/GeometryService", "esri/tasks/BufferParameters", "esri/toolbars/draw", "esri/lang", "dojo/_base/Color", "dojo/number", "dojo/dom-style", "esri/tasks/query", "esri/tasks/QueryTask", "esri/renderers/UniqueValueRenderer", "dojo/dom", "dojo/on", "dijit/TooltipDialog", "dojo/_base/array", "dijit/popup", "dojo/json", "esri/graphicsUtils", "esri/geometry/Extent", "esri/geometry/Point", "esri/geometry/Polygon", "esri/geometry/Circle", "esri/dijit/Directions", "esri/SpatialReference", "dojo/dom-attr", "dojo/domReady!" ], function ( Map, parser, FeatureLayer, Locator, esriConfig, ArcGISDynamicMapServiceLayer, webMercatorUtils, units, GraphicsLayer, ImageParameters, SimpleFillSymbol, SimpleLineSymbol, SimpleRenderer, SimpleMarkerSymbol, PictureMarkerSymbol, Graphic, normalizeUtils, GeometryService, BufferParameters, Draw, esriLang, Color, number, domStyle, Query, QueryTask, UniqueValueRenderer, dom, on, TooltipDialog, arrayUtils, dijitPopup, JSON, graphicsUtils, Point, Polygon, Circle, Directions, SpatialReference, domAttr, Extent ) { esriConfig.defaults.geometryService = "http://ec2-54-163-148-251.compute-1.amazonaws.com:6080/arcgis/rest/services/Utilities/Geometry/GeometryServer"; gsvc = new esri.tasks.GeometryService("http://ec2-54-163-148-251.compute-1.amazonaws.com:6080/arcgis/rest/services/Utilities/Geometry/GeometryServer"); //esri.config.defaults.map.zoomDuration = 2000; //time in milliseconds; default is 500 //esri.config.defaults.map.zoomRate = 10; //refresh rate of zoom animation; default is 25 var countyLayer = new GraphicsLayer(); map = new Map("map", { basemap: "national-geographic", //gray //osm center: [-86.694, 33.06], navigationMode: 'css-transforms', sliderStyle: "large", displayGraphicsOnPan: false, nav: true, zoom: 7, slider: true, sliderOrientation: "horizontal", sliderPosition: "top-right", spatialReference: { wkid: 32616 }, logo: false //fadeOnZoom: true }); /* var AlabamaCounties = new FeatureLayer("http://ec2-54-163-148-251.compute-1.amazonaws.com:6080/arcgis/rest/services/BackgroundService/MapServer/23", { mode: FeatureLayer.MODE_SNAPSHOT, outFields: ["NAME", "POP2000", "POP00_SQMI"] }); AlabamaCounties.setDefinitionExpression("STATE_NAME = 'Alabama'"); var symbol = new SimpleFillSymbol( SimpleFillSymbol.STYLE_SOLID, new SimpleLineSymbol( SimpleLineSymbol.STYLE_SOLID, new Color([255, 255, 255, 0.35]), 1 ), new Color([125, 125, 125, 0.25]) ); AlabamaCounties.setRenderer(new SimpleRenderer(symbol));*/ var imageParameters = new ImageParameters(); imageParameters.format = "jpeg"; var dynamicMapServiceLayer = new ArcGISDynamicMapServiceLayer("http://ec2-54-163-148-251.compute-1.amazonaws.com:6080/arcgis/rest/services/BackgroundService/MapServer", { "opacity": 1.0, "imageParameters": imageParameters, "loadError" : function() { console.log('load error'); } }); //map.addLayer(AlabamaCounties); // no need for this it appears... map.addLayer(dynamicMapServiceLayer); /* dont worry about error. is fixed when combined into one */ //SITE SEARCH var SiteObjectsToPlaceOnMap = []; var SiteResultsCount = 0; var sitesql = ''; var query2Task = new QueryTask("http://ec2-54-163-148-251.compute-1.amazonaws.com:6080/arcgis/rest/services/Sites2/MapServer/0"); var query2 = new Query(); query2.returnGeometry = true; query2.outFields = [ "site_prop_name", "site_city_name", "site_county_name", "site_total_acre_num", "site_avail_acre_num", "site_rail_track_status", "site_zoning_desc", "site_prop_id", "site_type", "site_adv_site_ind", "site_comment", "site_use_code" ]; query2.orderByFields = ["site_prop_name"]; query2.outSpatialReference = { wkid: 4326 }; /*search by radius/poly*/ //var SiteUsePolygon = false; // var SiteUseRadius = false; $(document.body).on("click", "#freehandpolygon_Site", function (e) { SiteUsePolygon = true; console.log("SiteUsePolygon?" + SiteUsePolygon); if (SiteUsePolygon) { if (tb2) { tb2.activate("freehandpolygon"); $(this).css('background-color', '#fc0'); } } }); $(".reset_all").click(function () { query2.geometry = ""; }); $(document.body).on("click", "#circle_Site", function (e) { SiteUseRadius = true; $(this).css('background-color', '#fc0'); }); map.on("load", initToolbarSite); function initToolbarSite(evtObj) { tb2 = new Draw(evtObj.map); tb2.on("draw-end", doBufferSite); } //var Sitegeometry = ""; //var SiteCircleGeo = ""; function doBufferSite(evtObj) { console.log("doBufferSite"); console.log(evtObj); tb2.deactivate(); symbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_NONE, new SimpleLineSymbol(SimpleLineSymbol.STYLE_DASHDOT, new Color([255, 0, 0]), 2), new Color([255, 255, 0, 0.25])); Sitegeometry = evtObj.geometry, symbol; var graphic = new Graphic(Sitegeometry, symbol); map.graphics.add(graphic); SiteUsePolygon = false; console.log("Sitegeometry", Sitegeometry); query2.geometry = Sitegeometry; $("#freehandpolygon_Site").css('background-color', '#fff'); } function doSiteRadiusBuffer(evt) { var TheValuetoCheckis = $('#circle_Site_input').val(); if (TheValuetoCheckis < 1) { TheValuetoCheckis = 10; } map.graphics.clear(); var params = new esri.tasks.BufferParameters(); params.geometries = [evt.mapPoint]; //buffer in linear units such as meters, km, miles etc. params.distances = [0.1, TheValuetoCheckis]; // change the 5 to user input.. params.unit = esri.tasks.GeometryService.UNIT_STATUTE_MILE; params.outSpatialReference = map.spatialReference; gsvc.buffer(params, showBufferSite); } function showBufferSite(geometries) { var symbol = new esri.symbol.SimpleFillSymbol( esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol( esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([0, 0, 255, 0.65]), 2 ), new dojo.Color([0, 0, 255, 0.35]) ); dojo.forEach(geometries, function (geometry) { var graphic = new esri.Graphic(geometry, symbol); map.graphics.add(graphic); console.log("graphic", graphic.geometry); SiteCircleGeo = graphic.geometry; }); query2.geometry = SiteCircleGeo; console.log("SiteCircleGeo", SiteCircleGeo); SiteUseRadius = false; } map.on("click", function (e) { if (SiteUseRadius) { doSiteRadiusBuffer(e); $("#circle_Site").css('background-color', '#fff'); } }); // search by radius/poly END on(dom.byId("site_search_btn"), "click", execute_search_site); function execute_search_site() { HasUserSearchedforASiteYet = true; console.log("Searching__Loader"); $('#SearchingLoader').show(); clearSearchResults(); console.log('turn off county select tool'); DoCountySelectTool = false; $('.CountySelectToolBtn').css('background-color', '#fff'); ///// GOT TO FIGURE THIS OUT... map.graphics.clear(); //e.preventDefault(); sitesql = "site_prop_status_code = 'A' "; if ($("#site_prop_type").val().length > 0) { sitesql += " AND site_type = '" + $("#site_prop_type").val() + "' "; } //if ($("#site_prop_id").val().length > 0) { sitesql += " AND site_prop_id = '" + $("#site_prop_id").val().replace(',', '') + "' "; } if ($("#site_prop_id").val().length > 0) { if ($("#site_prop_id").val().indexOf(',') > -1) { console.log('site_prop_id has comma, search for mutli'); var propids = $("#site_prop_id").val().split(','); var site_sql = ""; for (index = 0; index < propids.length; ++index) { var site_counter = index + 1; console.log('mutli prop id #' + index, propids[index]); if (site_counter == propids.length) { site_sql += " site_prop_id = '" + propids[index] + "'"; } else { site_sql += " site_prop_id = '" + propids[index] + "' OR "; } } sitesql += " AND ( " + site_sql + " )"; } else { console.log('site_prop_id has only 1'); sitesql += " AND site_prop_id = '" + $("#site_prop_id").val() + "' "; } } if ($("#site_prop_name").val().length > 0) { sitesql += " AND site_prop_name LIKE '%" + $("#site_prop_name").val() + "%' "; } if ($("#site_prop_keyword").val().length > 0) { sitesql += " AND (site_prop_name LIKE '%" + $("#site_prop_keyword").val() + "%' OR " + " site_comment LIKE '%" + $("#site_prop_keyword").val() + "%' OR " + " site_use_code LIKE '%" + $("#site_prop_keyword").val() + "%') "; } if ($("#site_county_code option:selected").text().length > 1) { var counties = []; var county_sql = ''; $('#site_county_code option:selected').each(function () { counties.push($(this).val()); }); if (counties.length == 1) { sitesql += " AND site_county_code = '" + $("#site_county_code option:selected").val() + "' "; } else { for (index = 0; index < counties.length; ++index) { var county_counter = index + 1; if (county_counter == counties.length) { county_sql += "site_county_code = '" + counties[index] + "'"; } else { county_sql += "site_county_code = '" + counties[index] + "' OR "; } } sitesql += " AND ( " + county_sql + " )"; } } // site_county_name sitesql /* if ($('.unit_option_metric').is(":checked")) { var tmp_sq_num_002 = $("#bldg_total_acre_num_MAX").val() / 2.4711; sql += " AND bldg_total_acre_num >= " + tmp_sq_num_002; } else { */ if ($("#site_total_acre_num_MIN").val().length > 0) { if ($("#site_total_acre_num_MIN").val() == 0) { } else { if ($('.unit_option_metric2').is(":checked")) { var tmp_sq_num_010 = $("#site_total_acre_num_MIN").val().replace(',', '') / 2.4711; sitesql += " AND site_total_acre_num >= " + tmp_sq_num_010; } else { sitesql += " AND site_total_acre_num >= " + $("#site_total_acre_num_MIN").val().replace(',', ''); } } } if ($("#site_total_acre_num_MAX").val().length > 0) { if ($("#site_total_acre_num_MAX").val() == 0) { } else { if ($('.unit_option_metric2').is(":checked")) { var tmp_sq_num_011 = $("#site_total_acre_num_MAX").val().replace(',', '') / 2.4711; sitesql += " AND site_total_acre_num <= " + tmp_sq_num_011; } else { sitesql += " AND site_total_acre_num <= " + $("#site_total_acre_num_MAX").val().replace(',', ''); } } } if ($("#site_avail_acre_num_MIN").val().length > 0) { if ($("#site_avail_acre_num_MIN").val() == 0) { } else { if ($('.unit_option_metric2').is(":checked")) { var tmp_sq_num_012 = $("#site_avail_acre_num_MIN").val().replace(',', '') / 2.4711; sitesql += " AND site_avail_acre_num >= " + tmp_sq_num_012; } else { sitesql += " AND site_avail_acre_num >= " + $("#site_avail_acre_num_MIN").val().replace(',', ''); } } } if ($("#site_avail_acre_num_MAX").val().length > 0) { if ($("#site_avail_acre_num_MAX").val() == 0) { } else { if ($('.unit_option_metric2').is(":checked")) { var tmp_sq_num_015 = $("#site_avail_acre_num_MAX").val().replace(',', '') / 2.4711; sitesql += " AND site_avail_acre_num <= " + tmp_sq_num_015; } else { sitesql += " AND site_avail_acre_num <= " + $("#site_avail_acre_num_MAX").val().replace(',', ''); } } } if ($("#site_sm_ctg_tract_num").val().length > 0) { if ($("#site_sm_ctg_tract_num").val() == 0) { } else { if ($('.unit_option_metric2').is(":checked")) { var tmp_sq_num_013 = $("#site_sm_ctg_tract_num").val().replace(',', '') / 2.4711; sitesql += " AND site_sm_ctg_tract_num >= " + tmp_sq_num_013; } else { sitesql += " AND site_sm_ctg_tract_num >= " + $("#site_sm_ctg_tract_num").val().replace(',', ''); } } } if ($("#site_lg_ctg_tract_num").val().length > 0) { if ($("#site_lg_ctg_tract_num").val() == 0) { } else { if ($('.unit_option_metric2').is(":checked")) { var tmp_sq_num_014 = $("#site_lg_ctg_tract_num").val().replace(',', '') / 2.4711; sitesql += " AND site_lg_ctg_tract_num <= " + tmp_sq_num_014; } else { sitesql += " AND site_lg_ctg_tract_num <= " + $("#site_lg_ctg_tract_num").val().replace(',', ''); } } } if( $( "#site_zoning_desc option:selected" ).text().length>1) { sitesql+= " AND site_zoning_desc = '" + $( "#site_zoning_desc option:selected" ).text() + "' "; } if( $( "#site_industrialpark_ind:checked" ).val() == "Yes" ) { sitesql += " AND site_indu_park_ind = 'Yes' "; } if( $( "#site_adv_site_ind:checked" ).val() == "Yes" ) { sitesql+= " AND site_adv_site_ind = 'Yes' "; } if( $( "#site_rail_track_status option:selected" ).val() == "A" ) { } else { if( $( "#site_rail_track_status option:selected" ).val() == "B" ) { sitesql+= " AND site_rail_track_status = 'B'"; } else if( $( "#site_rail_track_status option:selected" ).val() == "C" ) { sitesql+= " AND (site_rail_track_status = 'B' OR site_rail_track_status = 'C')"; } else if( $( "#site_rail_track_status option:selected" ).val() == "D" ) { sitesql+= " AND (site_rail_track_status = 'B' OR site_rail_track_status = 'C' OR site_rail_track_status = 'D')"; } else if( $( "#site_rail_track_status option:selected" ).val() == "E" ) { sitesql+= " AND (site_rail_track_status = 'B' OR site_rail_track_status = 'C' OR site_rail_track_status = 'D' OR site_rail_track_status = 'E')"; } else if( $( "#site_rail_track_status option:selected" ).val() == "F" ) { sitesql+= " AND (site_rail_track_status = 'B' OR site_rail_track_status = 'C' OR site_rail_track_status = 'D' OR site_rail_track_status = 'E' OR site_rail_track_status = 'F')"; } else if( $( "#site_rail_track_status option:selected" ).val() == "G" ) { sitesql+= " AND (site_rail_track_status = 'B' OR site_rail_track_status = 'C' OR site_rail_track_status = 'D' OR site_rail_track_status = 'E' OR site_rail_track_status = 'F' OR site_rail_track_status = 'G')"; } else if( $( "#site_rail_track_status option:selected" ).val() == "H" ) { sitesql+= " AND (site_rail_track_status = 'B' OR site_rail_track_status = 'C' OR site_rail_track_status = 'D' OR site_rail_track_status = 'E' OR site_rail_track_status = 'F' OR site_rail_track_status = 'G' OR site_rail_track_status = 'H')"; } else if( $( "#site_rail_track_status option:selected" ).val() == "I" ) { sitesql+= " AND site_rail_track_status = 'I' "; } } if ($("#site_dock_status option:selected").val() == "A") { } else { if ($("#site_dock_status option:selected").val() == "B") { sitesql += " AND site_dock_status= 'B'"; } else if ($("#site_dock_status option:selected").val() == "C") { sitesql += " AND (site_dock_status= 'B' OR site_dock_status= 'C')"; } else if ($("#site_dock_status option:selected").val() == "D") { sitesql += " AND (site_dock_status= 'B' OR site_dock_status= 'C' OR site_dock_status= 'D')"; } else if ($("#site_dock_status option:selected").val() == "E") { sitesql += " AND (site_dock_status= 'B' OR site_dock_status= 'C' OR site_dock_status= 'D' OR site_dock_status= 'E')"; } else if ($("#site_dock_status option:selected").val() == "F") { sitesql += " AND (site_dock_status= 'B' OR site_dock_status= 'C' OR site_dock_status= 'D' OR site_dock_status= 'E' OR site_dock_status= 'F')"; } else if ($("#site_dock_status option:selected").val() == "G") { sitesql += " AND (site_dock_status= 'B' OR site_dock_status= 'C' OR site_dock_status= 'D' OR site_dock_status= 'E' OR site_dock_status= 'F' OR site_dock_status= 'G')"; } else if ($("#site_dock_status option:selected").val() == "H") { sitesql += " AND (site_dock_status= 'B' OR site_dock_status= 'C' OR site_dock_status= 'D' OR site_dock_status= 'E' OR site_dock_status= 'F' OR site_dock_status= 'G' OR site_dock_status= 'H')"; } else if ($("#site_dock_status option:selected").val() == "I") { sitesql += " AND site_dock_status= 'I' "; } //sitesql+= " AND site_dock_status = '" + $( "#site_dock_status option:selected" ).val() + "' "; } if ($("#site_miles_from_interstate").val().length > 0) { sitesql += " AND site_int_mi <= '" + $("#site_miles_from_interstate").val().replace(',', '') + "' "; } if ($("#site_miles_from_4_lane").val().length > 0) { sitesql += " AND site_4lane_mi <= '" + $("#site_miles_from_4_lane").val().replace(',', '') + "' "; } query2.where = sitesql; log_usr('search query2 activated -> ' + query2.where); query2Task.execute(query2, showSitesResults); return false; } function showSitesResults(results) { SiteObjectsToPlaceOnMap = []; //reset var tempResults; SiteResultsCount = 0; var resultItems = []; var resultCount = results.features.length; log_search("Sites", sitesql, resultCount); //global.js for (var i = 0; i < resultCount; i++) { var tmpTrackStatus = ''; var AdvSiteIcon = ''; var fa = results.features[i].attributes; var featureGeo = results.features[i].geometry; var pictureMarkerSymbol = new PictureMarkerSymbol('/images/icons/site.png', 20, 20); console.log(fa); var graphic = results.features[i]; graphic.setSymbol(pictureMarkerSymbol); $('.count_results').html(resultCount + ' result' + (resultCount == 1 ? "" : "s")); if (!isNaN(featureGeo['x']) && !isNaN(featureGeo['y'])) { map.graphics.add(graphic); if (fa['site_rail_track_status'] == "A") { tmpTrackStatus = "Not Specified"; } else if (fa['site_rail_track_status'] == "B") { tmpTrackStatus = "Onto Site"; } else if (fa['site_rail_track_status'] == "C") { tmpTrackStatus = "Spur Available"; } else if (fa['site_rail_track_status'] == "D") { tmpTrackStatus = "Adjacent Track"; } else if (fa['site_rail_track_status'] == "E") { tmpTrackStatus = "<500 ft"; } else if (fa['site_rail_track_status'] == "F") { tmpTrackStatus = "<1500 ft"; } else if (fa['site_rail_track_status'] == "G") { tmpTrackStatus = "<3000 ft"; } else if (fa['site_rail_track_status'] == "H") { tmpTrackStatus = "<1 Mile"; } else if (fa['site_rail_track_status'] == "I") { tmpTrackStatus = "Not Available"; } else { tmpTrackStatus = "Not Specified"; } if (fa['site_adv_site_ind'] == "Yes") { AdvSiteIcon = ''; } else { AdvSiteIcon = ''; } tempResults += "" + " " + "img" + "" + fa["site_prop_id"] + "" + "" + fa["site_prop_name"] + "" + "" + fa["site_county_name"] + "" + "" + fa["site_city_name"] + "" + /* ??? */ // total acres //zonning "" + fa['site_total_acre_num'] + "" + "" + fa['site_avail_acre_num'] + "" + // "" + fa['site_zoning_desc'] + "" + "" + tmpTrackStatus + "" + "" + AdvSiteIcon + "" + ""; SiteObjectsToPlaceOnMap.push(fa["site_prop_id"]); } // end if x and y are numbers // console.log('%c ADD POINT TO MAP %c ' + fa['site_prop_id'] + ' ~ ' + fa['site_prop_name'] + ' ', 'background-color: #3366FF; color: #fff;', ''); } // end for each result in list of results if (resultCount == 0) { tempResults += "no results found"; $('.count_results').html("no results found. try another search"); } $("#search-results").show(); $("#ajax_content_site_search_results").html(tempResults); process_table('#site-search-result'); update_search_tabsize(true); console.log(resultCount); SiteResultsCount = resultCount; map.addLayer(query2Task); $('.loader').hide(); sitesql = ''; process_table('#site-search-result'); console.log('site bounds to place on map:', SiteObjectsToPlaceOnMap); execute_SiteBoundss(); } // show_results SITES // to get the BOUNDS on the map: // OLD: http://ec2-54-163-148-251.compute-1.amazonaws.com:6080/arcgis/rest/services/Sites2/MapServer/2 // NEW: http://ec2-54-163-148-251.compute-1.amazonaws.com:6080/arcgis/rest/services/SitePolys/MapServer/0 (before jason left) // NEW: http://ec2-54-163-148-251.compute-1.amazonaws.com:6080/arcgis/rest/services/SitePolys_merge/MapServer/0 (the one Chris did) var SiteBoundsqueryTask = new QueryTask("http://ec2-54-163-148-251.compute-1.amazonaws.com:6080/arcgis/rest/services/SitePolys_merge/MapServer/0"); var SiteBoundssql = ""; var SiteBoundsquery = new Query(); SiteBoundsquery.returnGeometry = true; SiteBoundsquery.outFields = ["*"]; SiteBoundsquery.orderByFields = ["Id"]; SiteBoundsquery.outSpatialReference = { wkid: 3857 }; function execute_SiteBoundss() { //SiteBoundssql = "archpatent_id = " + SiteObjectsToPlaceOnMap.join(" OR archpatent_id = "); //SiteBoundssql = "archpatent_id = 5728893"; //SiteBoundssql = "1=1"; //console.log("SiteObjectsToPlaceOnMap", SiteObjectsToPlaceOnMap); //console.log("archpatent_id = " + SiteObjectsToPlaceOnMap.join(" OR archpatent_id = ")); if (SiteResultsCount > 100) { SiteBoundssql = "1=1"; } else { SiteBoundssql = "Id = " + SiteObjectsToPlaceOnMap.join(" OR Id = "); } console.log(SiteBoundssql); SiteBoundsquery.where = SiteBoundssql; SiteBoundsqueryTask.execute(SiteBoundsquery, showSitePoints); } function showSitePoints(results) { var tempResults; var resultItems = []; var resultCount = results.features.length; console.log('site bounds search results count', resultCount); console.log('site bounds search results', results); for (var i = 0; i < resultCount; i++) { var fa = results.features[i].attributes; var featureGeo = results.features[i].geometry; console.log(results.features[i]); var graphic = results.features[i]; var symbol = new SimpleFillSymbol( SimpleFillSymbol.STYLE_SOLID, new SimpleLineSymbol( SimpleLineSymbol.STYLE_SOLID, new Color([0, 0, 0, 1]), 1 ), new Color([255, 255, 255, .2]) ); graphic.setSymbol(symbol); map.graphics.add(graphic); //map.graphics.reorderLayer(graphic, 1); //var pictureMarkerSymbol = new PictureMarkerSymbol('/images/icons/patent.png', 20, 20); //var graphic = results.features[i]; //graphic.setSymbol(pictureMarkerSymbol); /* var symbol = new SimpleFillSymbol( SimpleFillSymbol.STYLE_SOLID, new SimpleLineSymbol( SimpleLineSymbol.STYLE_SOLID, new Color([255, 255, 255, 1]), 6 ), new Color([125, 125, 125, 1]) ); graphic.setRenderer(new SimpleRenderer(symbol));*/ //$('.count_results').html(resultCount + ' result' + (resultCount == 1 ? "" : "s")); } map.addLayer(SiteBoundsqueryTask); //SiteBoundsqueryTask.disableMouseEvents(); //map.reorderLayer(SiteBoundsqueryTask, 2);/ }  //BUILDING SEARCH /** https://developers.arcgis.com/javascript/jssamples/query_buffer.html https://developers.arcgis.com/javascript/jssamples/util_buffergraphic.html /* can you place points directly on the map via lat, lon? * -9536993.636743583 4049418.2686260813 */ // var sql = ''; var queryTask = new QueryTask("http://ec2-54-163-148-251.compute-1.amazonaws.com:6080/arcgis/rest/services/Buildiings/MapServer/0"); var query = new Query(); query.returnGeometry = true; query.outFields = [ "bldg_prop_name", "bldg_county_name", "bldg_city_name", "bldg_avail_sq_ft_num", "bldg_tot_sq_ft_num", "bldg_eave_hght_ft_num", "bldg_total_acre_num", "bldg_rail_track_status", "bldg_prop_type", "bldg_dock_status", "bldg_prop_id", "bldg_tot_trk_dock_num", "bldg_max_ceil_hght_ft_num", "bldg_spec_ind", "bldg_exp_bldg_ind", "bldg_mi_cmcl_air_num", "bldg_cm_cnt_num", "bldg_county_code", "bldg_address_1", "bldg_key_features_comment", "bldg_former_use_desc", "bldg_comment", "bldg_vtour_ind"]; query.orderByFields = ["bldg_prop_name"]; query.outSpatialReference = { wkid: 4326 }; //var BuildingUsePolygon = false; //var BuildingUseRadius = false; $(document.body).on("click", "#freehandpolygon_building", function (e) { BuildingUsePolygon = true; console.log("BuildingUsePolygon?" + BuildingUsePolygon); if (BuildingUsePolygon) { if (tb) { tb.activate("freehandpolygon"); $(this).css('background-color', '#fc0'); } } }); $(document.body).on("click", "#circle_building", function (e) { BuildingUseRadius = true; $(this).css('background-color', '#fc0'); }); map.on("load", initToolbar); function initToolbar(evtObj) { tb = new Draw(evtObj.map); tb.on("draw-end", doBuffer); } //var Buildinggeometry = ""; //var BuildingCircleGeo = ""; function doBuffer(evtObj) { console.log("doBuffer"); console.log(evtObj); tb.deactivate(); symbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_NONE, new SimpleLineSymbol(SimpleLineSymbol.STYLE_DASHDOT, new Color([255, 0, 0]), 2), new Color([255, 255, 0, 0.25])); Buildinggeometry = evtObj.geometry, symbol; var graphic = new Graphic(Buildinggeometry, symbol); map.graphics.add(graphic); BuildingUsePolygon = false; console.log("Buildinggeometry", Buildinggeometry); query.geometry = Buildinggeometry; $("#freehandpolygon_building").css('background-color', '#fff'); } function doBuildingRadiusBuffer(evt) { var TheValuetoCheckis = $('#circle_building_input').val(); if (TheValuetoCheckis < 1) { TheValuetoCheckis = 10; } map.graphics.clear(); var params = new esri.tasks.BufferParameters(); params.geometries = [evt.mapPoint]; //buffer in linear units such as meters, km, miles etc. params.distances = [0.1, TheValuetoCheckis]; // change the 5 to user input.. params.unit = esri.tasks.GeometryService.UNIT_STATUTE_MILE; params.outSpatialReference = map.spatialReference; gsvc.buffer(params, showBuffer); } function showBuffer(geometries) { var symbol = new esri.symbol.SimpleFillSymbol( esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol( esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([0, 0, 255, 0.65]), 2 ), new dojo.Color([0, 0, 255, 0.35]) ); dojo.forEach(geometries, function (geometry) { var graphic = new esri.Graphic(geometry, symbol); map.graphics.add(graphic); console.log("graphic", graphic.geometry); BuildingCircleGeo = graphic.geometry; }); query.geometry = BuildingCircleGeo; console.log("BuildingCircleGeo", BuildingCircleGeo); BuildingUseRadius = false; } map.on("click", function (e) { if (BuildingUseRadius) { doBuildingRadiusBuffer(e); $("#circle_building").css('background-color', '#fff'); } }); /* // this works var symbolX = new SimpleFillSymbol().setColor(null).outline.setColor("blue"); function addCircle(e) { console.log("ADD CIRCLE (E) clicked the map: ", e); var pt, radius, circle, ring, pts, angle; radius = 20; pt = e.mapPoint; console.log(pt); circle = new esri.geometry.Polygon(map.spatialReference); ring = []; // point that make up the circle pts = 40; // number of points on the circle angle = 360 / pts; // used to compute points on the circle for (var i = 1; i <= pts; i++) { // convert angle to raidans var radians = i * angle * Math.PI / 180; // add point to the circle ring.push([pt.x + radius * Math.cos(radians), pt.y + radius * Math.sin(radians)]); } ring.push(ring[0]); // start point needs to == end point circle.addRing(ring); console.log(ring); console.log(circle); map.graphics.add(new esri.Graphic(circle, symbolX)); console.log("added a graphic"); } map.on("click", function (e) { addCircle(e); }); */ /* var circleSymb = new SimpleMarkerSymbol({ "style": "esriSMSCircle" }); var circle; map.on("click", function (evt) { circle = new Circle({ center: evt.mapPoint, geodesic: true, radius: 200, radiusUnit: units.MILES }); //if (BuildingUsePolygon) { console.log('place circle'); console.log(circle); var graphic = new Graphic(circle, circleSymb); map.graphics.add(graphic); //} }); map.on("click", projectToWebMercator); function projectToWebMercator(evt) { // map.graphics.clear(); var point = evt.mapPoint; var symbol = new SimpleMarkerSymbol({ "style": "esriSMSCircle" }); var graphic = new Graphic(point, symbol); map.graphics.add(graphic); } */ // radius search end on(dom.byId("bldg_search_btn"), "click", execute_search_building); function execute_search_building(e) { HasUserSearchedforABuildingYet = true; console.log(Buildinggeometry); clearSearchResults(); console.log('turn off county select tool'); DoCountySelectTool = false; $('.CountySelectToolBtn').css('background-color', '#fff'); console.log("Searching__Loader"); $('#SearchingLoader').show(); map.graphics.clear(); //e.preventDefault(); sql = "bldg_prop_status_code = 'A' "; if ($("#bldg_prop_type").val().length > 0) { sql += " AND bldg_prop_type = '" + $("#bldg_prop_type").val() + "' "; } if ($("#bldg_prop_id").val().length > 0) { if ($("#bldg_prop_id").val().indexOf(',') > -1) { console.log('bldg_prop_id has comma, search for mutli'); var propids = $("#bldg_prop_id").val().split(','); var bldg_sql = ""; for (index = 0; index < propids.length; ++index) { var bldg_counter = index + 1; console.log('mutli prop id #' + index, propids[index]); if (bldg_counter == propids.length) { bldg_sql += " bldg_prop_id = '" + propids[index] + "'"; } else { bldg_sql += " bldg_prop_id = '" + propids[index] + "' OR "; } } sql += " AND ( " + bldg_sql + " )"; } else { console.log('bldg_prop_id has only 1'); sql += " AND bldg_prop_id = '" + $("#bldg_prop_id").val() + "' "; } } if ($("#bldg_prop_name").val().length > 0) { sql += " AND bldg_prop_name LIKE '%" + $("#bldg_prop_name").val() + "%' "; } if ($("#bldg_prop_keyword").val().length > 0) { sql += " AND (bldg_prop_name LIKE '%" + $("#bldg_prop_keyword").val() + "%' OR bldg_former_use_desc LIKE '%" + $("#bldg_prop_keyword").val() + "%' OR bldg_key_features_comment LIKE '%" + $("#bldg_prop_keyword").val() + "%' OR bldg_comment LIKE '%" + $("#bldg_prop_keyword").val() + "%') "; } if ($("#bldg_county_name option:selected").text().length > 1) { var counties = []; var county_sql = ''; $('#bldg_county_name option:selected').each(function () { counties.push($(this).text()); }); if (counties.length == 1) { sql += " AND bldg_county_name = '" + $("#bldg_county_name option:selected").text() + "' "; } else { for (index = 0; index < counties.length; ++index) { var county_counter = index + 1; if (county_counter == counties.length) { county_sql += " bldg_county_name = '" + counties[index] + "'"; } else { county_sql += " bldg_county_name = '" + counties[index] + "' OR "; } } sql += " AND ( " + county_sql + " )"; } } // bldg_county_name sql if ($("#bldg_total_acre_num_MIN").val().length > 0) { if ($("#bldg_total_acre_num_MIN").val() == 0) { } else { if ($('.unit_option_metric').is(":checked")) { var tmp_sq_num_001 = $("#bldg_total_acre_num_MIN").val().replace(',', '') / 2.4711; sql += " AND bldg_total_acre_num >= " + tmp_sq_num_001; } else { sql += " AND bldg_total_acre_num >= " + $("#bldg_total_acre_num_MIN").val().replace(',', ''); } } } if ($("#bldg_total_acre_num_MAX").val().length > 0) { if ($("#bldg_total_acre_num_MAX").val() == 0) { } else { if ($('.unit_option_metric').is(":checked")) { var tmp_sq_num_002 = $("#bldg_total_acre_num_MAX").val().replace(',', '') / 2.4711; sql += " AND bldg_total_acre_num >= " + tmp_sq_num_002; } else { sql += " AND bldg_total_acre_num <= " + $("#bldg_total_acre_num_MAX").val().replace(',', ''); } } } //avail_sq_ft_num if ($("#bldg_avail_sq_ft_num_MIN").val().length > 0) { if ($("#bldg_avail_sq_ft_num_MIN").val() == 0) { } else { if ($('.unit_option_metric').is(":checked")) { var tmp_sq_num_010 = $("#bldg_avail_sq_ft_num_MIN").val().replace(',', '') / 10.764; sql += " AND bldg_avail_sq_ft_num >= " + tmp_sq_num_010; } else { sql += " AND bldg_avail_sq_ft_num >= " + $("#bldg_avail_sq_ft_num_MIN").val().replace(',', ''); } } } if ($("#bldg_avail_sq_ft_num_MAX").val().length > 0) { if ($("#bldg_avail_sq_ft_num_MAX").val() == 0) { } else { if ($('.unit_option_metric').is(":checked")) { var tmp_sq_num_004 = $("#bldg_avail_sq_ft_num_MAX").val().replace(',', '') / 10.764; sql += " AND bldg_avail_sq_ft_num >= " + tmp_sq_num_004; } else { sql += " AND bldg_avail_sq_ft_num <= " + $("#bldg_avail_sq_ft_num_MAX").val().replace(',', ''); } } } //bldg_tot_sq_ft_num if ($("#bldg_tot_sq_ft_num_MIN").val().length > 0) { if ($("#bldg_tot_sq_ft_num_MIN").val() == 0) { } else { if ($('.unit_option_metric').is(":checked")) { var tmp_sq_num_003 = $("#bldg_tot_sq_ft_num_MIN").val().replace(',', '') / 10.764; sql += " AND bldg_tot_sq_ft_num >= " + tmp_sq_num_003; } else { sql += " AND bldg_tot_sq_ft_num >= " + $("#bldg_tot_sq_ft_num_MIN").val().replace(',', ''); } } } if ($("#bldg_tot_sq_ft_num_MAX").val().length > 0) { if ($("#bldg_tot_sq_ft_num_MAX").val() == 0) { } else { if ($('.unit_option_metric').is(":checked")) { var tmp_sq_num_004 = $("#bldg_tot_sq_ft_num_MAX").val().replace(',', '') / 10.764; sql += " AND bldg_tot_sq_ft_num >= " + tmp_sq_num_004; } else { sql += " AND bldg_tot_sq_ft_num <= " + $("#bldg_tot_sq_ft_num_MAX").val().replace(',', ''); } } } if ($("#bldg_eave_hght_ft_num_MIN").val().length > 0) { if ($("#bldg_eave_hght_ft_num_MIN").val() == 0) { } else { sql += " AND bldg_eave_hght_ft_num >= " + $("#bldg_eave_hght_ft_num_MIN").val().replace(',', ''); } } if ($("#bldg_eave_hght_ft_num_MAX").val().length > 0) { if ($("#bldg_eave_hght_ft_num_MAX").val() == 0) { } else { sql += " AND bldg_eave_hght_ft_num <= " + $("#bldg_eave_hght_ft_num_MAX").val().replace(',', ''); } } if ($("#bldg_max_ceil_hght_ft_num_MIN").val().length > 0) { if ($("#bldg_max_ceil_hght_ft_num_MIN").val() == 0) { } else { sql += " AND bldg_max_ceil_hght_ft_num >= " + $("#bldg_max_ceil_hght_ft_num_MIN").val().replace(',', ''); } } if ($("#bldg_max_ceil_hght_ft_num_MAX").val().length > 0) { if ($("#bldg_max_ceil_hght_ft_num_MAX").val() == 0) { } else { sql += " AND bldg_max_ceil_hght_ft_num <= " + $("#bldg_max_ceil_hght_ft_num_MAX").val().replace(',', ''); } } if ($("#bldg_tot_trk_dock_num_MIN").val().length > 0) { if ($("#bldg_tot_trk_dock_num_MIN").val() == 0) { } else { sql += " AND bldg_tot_trk_dock_num >= " + $("#bldg_tot_trk_dock_num_MIN").val().replace(',', ''); } } if ($("#bldg_tot_trk_dock_num_MAX").val().length > 0) { if ($("#bldg_tot_trk_dock_num_MAX").val() == 0) { } else { sql += " AND bldg_tot_trk_dock_num <= " + $("#bldg_tot_trk_dock_num_MAX").val().replace(',', ''); } } if ($("#bldg_spec_ind:checked").val() == "Yes") { sql += " AND bldg_spec_ind = 'Yes' "; } if ($("#bldg_exp_bldg_ind:checked").val() == "Yes") { sql += " AND bldg_exp_bldg_ind = 'Yes' "; } if ($("#bldg_cm_cnt_num:checked").val() == "Yes") { sql += " AND bldg_cm_cnt_num > 0 "; } if ($("#bldg_rail_track_status option:selected").val() == "A") { } else { if ($("#bldg_rail_track_status option:selected").val() == "B") { sql += " AND bldg_rail_track_status = 'B' "; } else if ($("#bldg_rail_track_status option:selected").val() == "C") { sql += " AND (bldg_rail_track_status = 'B' OR bldg_rail_track_status = 'C') "; } else if ($("#bldg_rail_track_status option:selected").val() == "D") { sql += " AND (bldg_rail_track_status = 'B' OR bldg_rail_track_status = 'C' OR bldg_rail_track_status = 'D') "; } else if ($("#bldg_rail_track_status option:selected").val() == "E") { sql += " AND (bldg_rail_track_status = 'B' OR bldg_rail_track_status = 'C' OR bldg_rail_track_status = 'D' OR bldg_rail_track_status = 'E') "; } else if ($("#bldg_rail_track_status option:selected").val() == "F") { sql += " AND (bldg_rail_track_status = 'B' OR bldg_rail_track_status = 'C' OR bldg_rail_track_status = 'D' OR bldg_rail_track_status = 'E' OR bldg_rail_track_status = 'F') "; } else if ($("#bldg_rail_track_status option:selected").val() == "G") { sql += " AND (bldg_rail_track_status = 'B' OR bldg_rail_track_status = 'C' OR bldg_rail_track_status = 'D' OR bldg_rail_track_status = 'E' OR bldg_rail_track_status = 'F' OR bldg_rail_track_status = 'G') "; } else if ($("#bldg_rail_track_status option:selected").val() == "H") { sql += " AND (bldg_rail_track_status = 'B' OR bldg_rail_track_status = 'C' OR bldg_rail_track_status = 'D' OR bldg_rail_track_status = 'E' OR bldg_rail_track_status = 'F' OR bldg_rail_track_status = 'G' OR bldg_rail_track_status = 'H') "; } else if ($("#bldg_rail_track_status option:selected").val() == "I") { sql += " AND bldg_rail_track_status = 'I' "; } else { } // sql += " AND bldg_rail_track_status = '" + $("#bldg_rail_track_status option:selected").val() + "' "; } if ($("#bldg_dock_status option:selected").val() == "A") { } else { if ($("#bldg_dock_status option:selected").val() == "B") { sql += " AND bldg_dock_status = 'B' "; } else if ($("#bldg_dock_status option:selected").val() == "C") { sql += " AND (bldg_dock_status = 'B' OR bldg_dock_status = 'C') "; } else if ($("#bldg_dock_status option:selected").val() == "D") { sql += " AND (bldg_dock_status = 'B' OR bldg_dock_status = 'C' OR bldg_dock_status = 'D') "; } else if ($("#bldg_dock_status option:selected").val() == "E") { sql += " AND (bldg_dock_status = 'B' OR bldg_dock_status = 'C' OR bldg_dock_status = 'D' OR bldg_dock_status = 'E') "; } else if ($("#bldg_dock_status option:selected").val() == "F") { sql += " AND (bldg_dock_status = 'B' OR bldg_dock_status = 'C' OR bldg_dock_status = 'D' OR bldg_dock_status = 'E' OR bldg_dock_status = 'F') "; } else if ($("#bldg_dock_status option:selected").val() == "G") { sql += " AND (bldg_dock_status = 'B' OR bldg_dock_status = 'C' OR bldg_dock_status = 'D' OR bldg_dock_status = 'E' OR bldg_dock_status = 'F' OR bldg_dock_status = 'G') "; } else if ($("#bldg_dock_status option:selected").val() == "H") { sql += " AND (bldg_dock_status = 'B' OR bldg_dock_status = 'C' OR bldg_dock_status = 'D' OR bldg_dock_status = 'E' OR bldg_dock_status = 'F' OR bldg_dock_status = 'G' OR bldg_dock_status = 'H') "; } else if ($("#bldg_dock_status option:selected").val() == "I") { sql += " AND (bldg_dock_status = 'B' OR bldg_dock_status = 'C' OR bldg_dock_status = 'D' OR bldg_dock_status = 'E' OR bldg_dock_status = 'F' OR bldg_dock_status = 'G' OR bldg_dock_status = 'H' OR bldg_dock_status = 'I') "; } else { } //sql += " AND bldg_dock_status = '" + $("#bldg_dock_status option:selected").val() + "' "; //sql += " AND bldg_dock_status = '" + $("#bldg_dock_status option:selected").val() + "' "; } if ($("#bldg_miles_from_interstate").val().length > 0) { sql += " AND bldg_int_mi <= '" + $("#bldg_miles_from_interstate").val().replace(',', '') + "' "; } if ($("#bldg_miles_from_4_lane").val().length > 0) { sql += " AND bldg_4lane_mi <= '" + $("#bldg_miles_from_4_lane").val().replace(',', '') + "' "; } if ($("#bldg_mi_cmcl_air_num").val().length > 0) { sql += " AND bldg_mi_cmcl_air_num <= '" + $("#bldg_mi_cmcl_air_num").val().replace(',', '') + "' "; } query.where = sql; log_usr('search query activated -> ' + query.where); //console.log(query.where); queryTask.execute(query, showResults); return false; } var XCords = []; var YCords = []; function showCoordinates(evt) { //the map is in web mercator but display coordinates in geographic (lat, long) console.log("LOOK!!", evt.mapPoint); var mp = webMercatorUtils.webMercatorToGeographic(evt.mapPoint); //display mouse coordinates console.log(mp.x.toFixed(3) + ", " + mp.y.toFixed(3)); $('input[name="latitude"]').val(mp.x.toFixed(5)); $('input[name="longitude"]').val(mp.y.toFixed(5)); $('#submit_btn').show(); } $(document.body).on("click", "#addgraphic", function (e) { console.log('testAddGraphic'); //console.log(showCoordinates(e)); // console.log(webMercatorUtils.lngLatToXY(33,-84)); //34.7166194,-86.6936257 var mp = webMercatorUtils.lngLatToXY(-86.6936257, 34.7166194); var pictureMarkerSymbol = new PictureMarkerSymbol('/images/icons/building.png', 20, 20); console.log(mp); //console.log(mp.x.toFixed(3) + ", " + mp.y.toFixed(3)); map.graphics.add(new esri.Graphic( // Point coordinates are 0, 0 new esri.geometry.Point(mp[0],mp[1], new SpatialReference({ wkid: 102100 })), ////////////////////////////////////////////// CANT BOOKMARK?? WTF MICROSOFT pictureMarkerSymbol )); }); function testAddGraphic(x, y) {/* console.log('testAddGraphic'); var pictureMarkerSymbol = new PictureMarkerSymbol('/images/icons/building.png', 20, 20); graphic.setSymbol(pictureMarkerSymbol); map.graphics.add(graphic);*/ } function showResults(results) { var tempResults; var resultItems = []; var resultCount = results.features.length; log_search("Building", sql, resultCount); //global.js for (var i = 0; i < resultCount; i++) { var tmpTrackStatus = ''; var fa = results.features[i].attributes; var featureGeo = results.features[i].geometry; //console.log(fa); /* var map_points = new SimpleMarkerSymbol(); map_points.style = map_points.STYLE_SQUARE; map_points.setSize(8); map_points.setColor(new Color([255, 98, 0, 1.0])); */ var pictureMarkerSymbol = new PictureMarkerSymbol('/images/icons/building.png', 20, 20); //var renderer = new SimpleRenderer(map_points); var graphic = results.features[i]; //graphic.setSymbol(map_points); graphic.setSymbol(pictureMarkerSymbol); $('.count_results').html(resultCount + ' result' + (resultCount == 1 ? "" : "s")); if (!isNaN(featureGeo['x']) && !isNaN(featureGeo['y'])) { if (OffsiteLink) { console.log('do zoom'); XCords.push(featureGeo['x']); YCords.push(featureGeo['y']); } // fails for some reason when items are undefine. /* console.log('go ' + fa['bldg_prop_id']); console.log(fa['bldg_prop_name']) console.log(fa['bldg_county_name']) console.log(fa['bldg_city_name']) console.log(fa['bldg_tot_sq_ft_num']) console.log(fa['bldg_eave_hght_ft_num']) console.log(fa['bldg_total_acre_num']) console.log(fa['bldg_rail_track_status']) console.log(fa['bldg_prop_type']) console.log(fa['bldg_dock_status']) console.log(fa['bldg_prop_id']) console.log(fa['bldg_tot_trk_dock_num']) console.log(fa['bldg_max_ceil_hght_ft_num']) console.log(fa['bldg_spec_ind']) console.log(fa['bldg_exp_bldg_ind']) console.log(fa['bldg_mi_cmcl_air_num']) console.log(fa['bldg_cm_cnt_num']) console.log(fa['bldg_county_code'])*/ map.graphics.add(graphic); // this shouldn't be like this but a hack } else { featureGeo['y'] = 32.9446883;//zoomTo(32.96095807953156,-87.17406234034225) featureGeo['x'] = -87.139836; //32.9446883,-87.139836 map.graphics.add(graphic); } // end hack var tmpEaveHeight = fa['bldg_eave_hght_ft_num']; var bldg_tot_sq_ft_num = ''; var bldg_avail_sq_ft_num = ''; var vtour = ""; if (fa['bldg_vtour_ind'] == "null" || !fa['bldg_vtour_ind']) { } else { vtour = "vtour"; } if (tmpEaveHeight == "null" || !tmpEaveHeight) { tmpEaveHeight = ""; } if (fa['bldg_rail_track_status'] == "A") { tmpTrackStatus = "Not Specified"; } else if (fa['bldg_rail_track_status'] == "B") { tmpTrackStatus = "Into Building"; } else if (fa['bldg_rail_track_status'] == "C") { tmpTrackStatus = "Spur Available"; } else if (fa['bldg_rail_track_status'] == "D") { tmpTrackStatus = "Adjacent Track"; } else if (fa['bldg_rail_track_status'] == "E") { tmpTrackStatus = "<500 ft"; } else if (fa['bldg_rail_track_status'] == "F") { tmpTrackStatus = "<1500 ft"; } else if (fa['bldg_rail_track_status'] == "G") { tmpTrackStatus = "<3000 ft"; } else if (fa['bldg_rail_track_status'] == "H") { tmpTrackStatus = "<1 Mile"; } else if (fa['bldg_rail_track_status'] == "I") { tmpTrackStatus = "Not Available"; } else { tmpTrackStatus = "Not Specified"; } if (fa['bldg_tot_sq_ft_num'] == "null" || !fa['bldg_tot_sq_ft_num']) { bldg_tot_sq_ft_num = "n/a"; } else { //bldg_tot_sq_ft_num = "" + fa["bldg_tot_sq_ft_num"] + "" + commaSeparateNumber(fa["bldg_tot_sq_ft_num"]); bldg_tot_sq_ft_num = commaSeparateNumber(fa["bldg_tot_sq_ft_num"]); } if (fa['bldg_avail_sq_ft_num'] == "null" || !fa['bldg_avail_sq_ft_num']) { bldg_avail_sq_ft_num = "n/a"; } else { //bldg_avail_sq_ft_num = "" + fa["bldg_avail_sq_ft_num"] + "" + commaSeparateNumber(fa["bldg_avail_sq_ft_num"]); bldg_avail_sq_ft_num = commaSeparateNumber(fa["bldg_avail_sq_ft_num"]); } tempResults += "" + "" + vtour + "" + "img" + "" + fa["bldg_prop_id"] + "" + "" + fa["bldg_prop_name"] + "" + "" + fa["bldg_county_name"] + "" + "" + fa["bldg_city_name"] + "" + "" + bldg_tot_sq_ft_num + "" + "" + bldg_avail_sq_ft_num + "" + "" + tmpEaveHeight + "" + "" + tmpTrackStatus + "" + ""; // orginal end of the if x,y are numbers //} // end if x and y are numbers /*console.log( featureGeo['y'] + "," + featureGeo['x'] + '%c ADD POINT TO MAP %c ' + fa['bldg_prop_id'] + ' ~ bldg_prop_name = ' + fa['bldg_prop_name'] + ' bldg_county_name = ' + fa["bldg_county_name"] + ' bldg_city_name = ' + fa["bldg_city_name"] + ' bldg_tot_sq_ft_num = ' + fa["bldg_tot_sq_ft_num"] + ' /tmpEaveHeight = ' + tmpEaveHeight + " /tmpTrackStatus = " + tmpTrackStatus, 'background-color: #3366FF; color: #fff;', '');*/ } // end for each result in list of results if (resultCount == 0) { tempResults += "no results found"; $('.count_results').html("no results found. try another saerch"); } if (OffsiteLink) { var xmin = Math.min.apply(Math, XCords); var xmax = Math.max.apply(Math, XCords); var ymin = Math.min.apply(Math, YCords); var ymax = Math.max.apply(Math, YCords); console.log('x min', Math.min.apply(Math, XCords)); console.log('x max', Math.max.apply(Math, XCords)); console.log('y min', Math.min.apply(Math, YCords)); console.log('y max', Math.max.apply(Math, YCords)); //=((A1-A2)/2)-A1 // to get middle point: /* (xmin - xman) + xmin */ var xmiddle = (((xmin - xmax) / 2) - xmin) * -1; console.log('xmiddle', xmiddle); var ymiddle = (((ymin - ymax) / 2) - ymin) * -1; console.log('ymiddle', ymiddle); /*zoomto y,x */ SimplezoomTo(ymiddle, xmiddle); } $("#ajax_content_building_search_results").html(tempResults); $("#search-results").show(); process_table('#building-search-result'); update_search_tabsize(true); console.log(resultCount); map.addLayer(queryTask); $('.loader').hide(); sql = ''; process_table('#building-search-result'); //console.log(graphicsUtils.graphicsExtent(myFeatureSet.features)); /* map.on("mouse-over", function (evt) { var t = "adfadf"; //var content = esriLang.substitute(evt.graphic.attributes, t); //var highlightGraphic = new Graphic(evt.graphic.geometry, highlightSymbol); //map.graphics.add(highlightGraphic); dialog.setContent("blah"); domStyle.set(dialog.domNode, "opacity", 0.85); dijitPopup.open({ popup: dialog, x: evt.pageX, y: evt.pageY }); });*/ } // show_results // end BUILDING SEARCH /******************************************************************************* QUERY FOR partners ********************************/ var partnersql = " Status = 'A' "; var partnerqueryTask = new QueryTask("http://ec2-54-163-148-251.compute-1.amazonaws.com:6080/arcgis/rest/services/Partners/MapServer/0"); var partnerquery = new Query(); partnerquery.returnGeometry = true; partnerquery.outFields = [ "Company_Name", "Street_Address", "City_1", "Zip_1", "NumEmps", "AlabamaBased", "logo", "Marketing_Text", "ObjectID"]; partnerquery.orderByFields = ["Company_Name"]; partnerquery.outSpatialReference = { wkid: 4326 }; /*search by radius/poly*/ //var PartnerUsePolygon = false; //var PartnerUseRadius = false; $(document.body).on("click", "#freehandpolygon_Partner", function (e) { PartnerUsePolygon = true; console.log("PartnerUsePolygon?" + PartnerUsePolygon); if (PartnerUsePolygon) { if (tb3) { tb3.activate("freehandpolygon"); $(this).css('background-color', '#fc0'); } } }); $(document.body).on("click", "#circle_Partner", function (e) { PartnerUseRadius = true; $(this).css('background-color', '#fc0'); }); $(".reset_all").click(function () { partnerquery.geometry = ""; }); map.on("load", initToolbarPartner); function initToolbarPartner(evtObj) { tb3 = new Draw(evtObj.map); tb3.on("draw-end", doBufferPartner); } //var Partnergeometry = ""; //var PartnerCircleGeo = ""; function doBufferPartner(evtObj) { console.log("doBufferPartner"); console.log(evtObj); tb3.deactivate(); symbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_NONE, new SimpleLineSymbol(SimpleLineSymbol.STYLE_DASHDOT, new Color([255, 0, 0]), 2), new Color([255, 255, 0, 0.25])); Partnergeometry = evtObj.geometry, symbol; var graphic = new Graphic(Partnergeometry, symbol); map.graphics.add(graphic); PartnerUsePolygon = false; console.log("Partnergeometry", Partnergeometry); partnerquery.geometry = Partnergeometry; $("#freehandpolygon_Partner").css('background-color', '#fff'); } function doPartnerRadiusBuffer(evt) { var TheValuetoCheckis = $('#circle_Partner_input').val(); if (TheValuetoCheckis < 1) { TheValuetoCheckis = 10; } map.graphics.clear(); var params = new esri.tasks.BufferParameters(); params.geometries = [evt.mapPoint]; //buffer in linear units such as meters, km, miles etc. params.distances = [0.1, TheValuetoCheckis]; // change the 5 to user input.. params.unit = esri.tasks.GeometryService.UNIT_STATUTE_MILE; params.outSpatialReference = map.spatialReference; gsvc.buffer(params, showBufferPartner); } function showBufferPartner(geometries) { var symbol = new esri.symbol.SimpleFillSymbol( esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol( esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([0, 0, 255, 0.65]), 2 ), new dojo.Color([0, 0, 255, 0.35]) ); dojo.forEach(geometries, function (geometry) { var graphic = new esri.Graphic(geometry, symbol); map.graphics.add(graphic); console.log("graphic", graphic.geometry); PartnerCircleGeo = graphic.geometry; }); partnerquery.geometry = PartnerCircleGeo; console.log("PartnerCircleGeo", PartnerCircleGeo); PartnerUseRadius = false; } map.on("click", function (e) { if (PartnerUseRadius) { doPartnerRadiusBuffer(e); $("#circle_Partner").css('background-color', '#fff'); } }); // search by radius/poly END on(dom.byId("partner_search_btn"), "click", execute_partner); function execute_partner() { console.log("Searching__Loader"); $('#SearchingLoader').show(); partnersql = " Status = 'A' " clearSearchResults(); console.log('turn off county select tool'); DoCountySelectTool = false; $('.CountySelectToolBtn').css('background-color', '#fff'); // map.graphics.clear(); partnersql += " AND Company_Name LIKE '%" + $("#partner_Company_Name").val() + "%'"; //partner_prop_id if ($("#partner_prop_id").val().length > 0) { if ($("#partner_prop_id").val().indexOf(',') > -1) { console.log('partner_prop_id has comma, search for mutli'); var propids = $("#partner_prop_id").val().split(','); var partner_sql = ""; for (index = 0; index < propids.length; ++index) { var partner_counter = index + 1; console.log('mutli prop id #' + index, propids[index]); if (partner_counter == propids.length) { partner_sql += " ObjectID = '" + propids[index] + "'"; } else { partner_sql += " ObjectID = '" + propids[index] + "' OR "; } } partnersql += " AND ( " + partner_sql + " )"; } else { console.log('partner_prop_id has only 1'); partnersql += " AND ObjectID = '" + $("#partner_prop_id").val() + "' "; } } if ($("#partner_Marketing_Text").val().length > 0) { partnersql += " AND Marketing_Text LIKE '%" + $("#partner_Marketing_Text").val() + "%' "; } if ($("#partner_County option:selected").text().length > 1) { var counties = []; var county_sql = ''; $('#partner_County option:selected').each(function () { counties.push($(this).val()); }); if (counties.length == 1) { partnersql += " AND County = '" + $("#partner_County option:selected").text() + "' "; } else { for (index = 0; index < counties.length; ++index) { var county_counter = index + 1; if (county_counter == counties.length) { county_sql += "County = '" + counties[index] + "'"; } else { county_sql += "County = '" + counties[index] + "' OR "; } } partnersql += " AND ( " + county_sql + " )"; } } if ($("#partner_Ind_Ser option:selected").val() == "Agriculture") { partnersql += " AND Agriculture = 1 "; } if ($("#partner_Ind_Ser option:selected").val() == "Mining") { partnersql += " AND Mining = 1 "; } if ($("#partner_Ind_Ser option:selected").val() == "Utilities") { partnersql += " AND Utilities = 1 "; } if ($("#partner_Ind_Ser option:selected").val() == "Construction") { partnersql += " AND Construction = 1 "; } if ($("#partner_Ind_Ser option:selected").val() == "Manufacturing") { partnersql += " AND Manufacturing = 1 "; } if ($("#partner_Ind_Ser option:selected").val() == "Wholesale_Trade") { partnersql += " AND Wholesale_Trade = 1 "; } if ($("#partner_Ind_Ser option:selected").val() == "Retail_Trade") { partnersql += " AND Retail_Trade = 1 "; } if ($("#partner_Ind_Ser option:selected").val() == "Transportation_and_Warehousing") { partnersql += " AND Transportation_and_Warehousing = 1 "; } if ($("#partner_Ind_Ser option:selected").val() == "Information") { partnersql += " AND Information = 1 "; } if ($("#partner_Ind_Ser option:selected").val() == "Finance_and_Insurance") { partnersql += " AND Finance_and_Insurance = 1 "; } if ($("#partner_Ind_Ser option:selected").val() == "Real_Estate_and_Rental_and_Leas") { partnersql += " AND Real_Estate_and_Rental_and_Leas = 1 "; } if ($("#partner_Ind_Ser option:selected").val() == "Professional_Scientific_and_Tec") { partnersql += " AND Professional_Scientific_and_Tec = 1 "; } if ($("#partner_Ind_Ser option:selected").val() == "Management_of_Companies_and_Ent") { partnersql += " AND Management_of_Companies_and_Ent = 1 "; } if ($("#partner_Ind_Ser option:selected").val() == "Administrative_and_Support_and_") { partnersql += " AND Administrative_and_Support_and_ = 1 "; } if ($("#partner_Ind_Ser option:selected").val() == "Educational_Services") { partnersql += " AND Educational_Services = 1 "; } if ($("#partner_Ind_Ser option:selected").val() == "Health_Care_and_Social_Assistan") { partnersql += " AND Health_Care_and_Social_Assistan = 1 "; } if ($("#partner_Ind_Ser option:selected").val() == "Arts_Entertainment_and_Recreati") { partnersql += " AND Arts_Entertainment_and_Recreati = 1 "; } if ($("#partner_Ind_Ser option:selected").val() == "Accomodation_and_Food_Services") { partnersql += " AND Accomodation_and_Food_Services = 1 "; } if ($("#partner_Ind_Ser option:selected").val() == "Other_Services_except_Public_Ad") { partnersql += " AND Other_Services_except_Public_Ad = 1 "; } if ($("#partner_Ind_Ser option:selected").val() == "Public_Administration") { partnersql += " AND Public_Administration = 1 "; } if ($("#partner_Ind_Ser2 option:selected").val() == "Agriculture2") { partnersql += " AND Agriculture2 = 1 "; } if ($("#partner_Ind_Ser2 option:selected").val() == "Mining2") { partnersql += " AND Mining2 = 1 "; } if ($("#partner_Ind_Ser2 option:selected").val() == "Utilities2") { partnersql += " AND Utilities2 = 1 "; } if ($("#partner_Ind_Ser2 option:selected").val() == "Construction2") { partnersql += " AND Construction2 = 1 "; } if ($("#partner_Ind_Ser2 option:selected").val() == "Manufacturing2") { partnersql += " AND Manufacturing2 = 1 "; } if ($("#partner_Ind_Ser2 option:selected").val() == "Wholesale_Trade2") { partnersql += " AND Wholesale_Trade2 = 1 "; } if ($("#partner_Ind_Ser2 option:selected").val() == "Retail_Trade2") { partnersql += " AND Retail_Trade2 = 1 "; } if ($("#partner_Ind_Ser2 option:selected").val() == "Transportation_and_Warehousing2") { partnersql += " AND Transportation_and_Warehousing2 = 1 "; } if ($("#partner_Ind_Ser2 option:selected").val() == "Information2") { partnersql += " AND Information2 = 1 "; } if ($("#partner_Ind_Ser2 option:selected").val() == "Finance_and_Insurance2") { partnersql += " AND Finance_and_Insurance2 = 1 "; } if ($("#partner_Ind_Ser2 option:selected").val() == "Real_Estate_and_Rental_and_Le_1") { partnersql += " AND Real_Estate_and_Rental_and_Le_1 = 1 "; } if ($("#partner_Ind_Ser2 option:selected").val() == "Professional_Scientific_and_T_1") { partnersql += " AND Professional_Scientific_and_T_1 = 1 "; } if ($("#partner_Ind_Ser2 option:selected").val() == "Management_of_Companies_and_E_1") { partnersql += " AND Management_of_Companies_and_E_1 = 1 "; } if ($("#partner_Ind_Ser2 option:selected").val() == "Administrative_and_Support_and1") { partnersql += " AND Administrative_and_Support_and1 = 1 "; } if ($("#partner_Ind_Ser2 option:selected").val() == "Educational_Services2") { partnersql += " AND Educational_Services2 = 1 "; } if ($("#partner_Ind_Ser2 option:selected").val() == "Health_Care_And_Social_Assist_1") { partnersql += " AND Health_Care_And_Social_Assist_1 = 1 "; } if ($("#partner_Ind_Ser2 option:selected").val() == "Arts_Entertainment_and_Recrea_1") { partnersql += " AND Arts_Entertainment_and_Recrea_1 = 1 "; } if ($("#partner_Ind_Ser2 option:selected").val() == "Accomodation_and_Food_Services2") { partnersql += " AND Accomodation_and_Food_Services2 = 1 "; } if ($("#partner_Ind_Ser2 option:selected").val() == "Other_Services_except_Public__1") { partnersql += " AND Other_Services_except_Public__1 = 1 "; } if ($("#partner_Ind_Ser2 option:selected").val() == "Public_Administration2") { partnersql += " AND Public_Administration2 = 1 "; } if ($("#PAlabamaBased:checked").val() == "true") { partnersql += " AND AlabamaBased = '2' "; } partnerquery.where = partnersql; partnerqueryTask.execute(partnerquery, showpartnersResults); } /* "Company_Name", "Street_Address", "City_1", "Zip_1", "NumEmps", "AlabamaBased", "Marketing_Text", "ObjectID" ]; */ function showpartnersResults(results) { var tempResults; var resultItems = []; var resultCount = results.features.length; log_search("Partners", partnersql, resultCount); //global.js for (var i = 0; i < resultCount; i++) { console.log(resultCount); var tmpTrackStatus = ''; var fa = results.features[i].attributes; var featureGeo = results.features[i].geometry; var pictureMarkerSymbol = new PictureMarkerSymbol('/images/icons/partner.png', 20, 20); console.log(fa); var graphic = results.features[i]; graphic.setSymbol(pictureMarkerSymbol); $('.count_results').html(resultCount + ' result' + (resultCount == 1 ? "" : "s")); if (!isNaN(featureGeo['x']) && !isNaN(featureGeo['y'])) { map.graphics.add(graphic); //console.log(i + " || " + fa['ObjectID']); tempResults += "" + "" + "" + fa["Company_Name"] + "" + "" + fa["Street_Address"] + "" + "" + fa["City_1"] + "" + "" + fa["NumEmps"] + "" + ""; } // end if x and y are numbers // console.log('%c ADD POINT TO MAP %c ' + fa['ObjectID'] + ' ~ ' + fa['Company_Name'] + ' ', 'background-color: #3366FF; color: #fff;', ''); } // end for each result in list of results // console.log('Stuff'); /* $("#search-results").show(); $("#ajax_content_site_search_results").html(tempResults); process_table('#site-search-result'); update_search_tabsize(true); console.log(resultCount); map.addLayer(query2Task); $('.loader').hide(); sitesql = ''; process_table('#site-search-result');*/ if (resultCount == 0) { tempResults += "no results found"; $('.count_results').html("no results found. try another saerch"); } $("#search-results").show(); $("#ajax_content_partner_search_results").html(tempResults); process_table('#partner-search-result'); update_search_tabsize(true); console.log(resultCount); map.addLayer(partnerqueryTask); $('.loader').hide(); partnersql = ''; process_table('#partner-search-result'); } // show_results PARTNERS  var incubsql = ''; var incubqueryTask = new QueryTask("http://ec2-54-163-148-251.compute-1.amazonaws.com:6080/arcgis/rest/services/Incubators/MapServer/0"); var incubquery = new Query(); incubquery.returnGeometry = true; incubquery.outFields = [ "Company_Name", "Street_Address", "Nearest_Incorporated_City", "City", "Zip_1", "Number_of_Staff", "Company_Expertise__Marketing_Te", "ObjectID"]; incubquery.orderByFields = ["Company_Name"]; incubquery.outSpatialReference = { wkid: 4326 }; /*search by radius/poly*/ //var IncUsePolygon = false; //var IncUseRadius = false; $(document.body).on("click", "#freehandpolygon_Inc", function (e) { IncUsePolygon = true; console.log("IncUsePolygon?" + IncUsePolygon); if (IncUsePolygon) { if (tb4) { tb4.activate("freehandpolygon"); $(this).css('background-color', '#fc0'); } } }); $(document.body).on("click", "#circle_Inc", function (e) { IncUseRadius = true; $(this).css('background-color', '#fc0'); }); $(".reset_all").click(function () { incubquery.geometry = ""; }); map.on("load", initToolbarInc); function initToolbarInc(evtObj) { tb4 = new Draw(evtObj.map); tb4.on("draw-end", doBufferInc); } //var Incgeometry = ""; //var IncCircleGeo = ""; function doBufferInc(evtObj) { console.log("doBufferInc"); console.log(evtObj); tb4.deactivate(); symbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_NONE, new SimpleLineSymbol(SimpleLineSymbol.STYLE_DASHDOT, new Color([255, 0, 0]), 2), new Color([255, 255, 0, 0.25])); Incgeometry = evtObj.geometry, symbol; var graphic = new Graphic(Incgeometry, symbol); map.graphics.add(graphic); IncUsePolygon = false; console.log("Incgeometry", Incgeometry); incubquery.geometry = Incgeometry; $("#freehandpolygon_Inc").css('background-color', '#fff'); } function doIncRadiusBuffer(evt) { var TheValuetoCheckis = $('#circle_Inc_input').val(); if (TheValuetoCheckis < 1) { TheValuetoCheckis = 10; } map.graphics.clear(); var params = new esri.tasks.BufferParameters(); params.geometries = [evt.mapPoint]; //buffer in linear units such as meters, km, miles etc. params.distances = [0.1, TheValuetoCheckis]; // change the 5 to user input.. params.unit = esri.tasks.GeometryService.UNIT_STATUTE_MILE; params.outSpatialReference = map.spatialReference; gsvc.buffer(params, showBufferInc); } function showBufferInc(geometries) { var symbol = new esri.symbol.SimpleFillSymbol( esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol( esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([0, 0, 255, 0.65]), 2 ), new dojo.Color([0, 0, 255, 0.35]) ); dojo.forEach(geometries, function (geometry) { var graphic = new esri.Graphic(geometry, symbol); map.graphics.add(graphic); console.log("graphic", graphic.geometry); IncCircleGeo = graphic.geometry; }); incubquery.geometry = IncCircleGeo; console.log("IncCircleGeo", IncCircleGeo); IncUseRadius = false; } map.on("click", function (e) { if (IncUseRadius) { doIncRadiusBuffer(e); $("#circle_Inc").css('background-color', '#fff'); } }); // search by radius/poly END on(dom.byId("incubator_search_btn"), "click", execute_incub); function execute_incub() { console.log("Searching__Loader"); $('#SearchingLoader').show(); incubsql = ''; clearSearchResults(); console.log('turn off county select tool'); DoCountySelectTool = false; $('.CountySelectToolBtn').css('background-color', '#fff'); //map.graphics.clear(); incubsql += "Status='A' AND Company_Name LIKE '%" + $("#Incub_Company_Name").val() + "%'"; /* if ($("#Incub_Keyword").val().length > 0) { incubsql += " AND Company_Expertise__Marketing_Te = '%" + $("#Incub_Keyword").val() + "%' "; }*/ if ($("#Incub_prop_id").val().length > 0) { if ($("#Incub_prop_id").val().indexOf(',') > -1) { console.log('Incub_prop_id has comma, search for mutli'); var propids = $("#Incub_prop_id").val().split(','); var incub_sql = ""; for (index = 0; index < propids.length; ++index) { var incub_counter = index + 1; console.log('mutli prop id #' + index, propids[index]); if (incub_counter == propids.length) { incub_sql += " ObjectID = '" + propids[index] + "'"; } else { incub_sql += " ObjectID = '" + propids[index] + "' OR "; } } incubsql += " AND ( " + incub_sql + " )"; } else { console.log('Incub_prop_id has only 1'); incubsql += " AND ObjectID = '" + $("#Incub_prop_id").val() + "' "; } } if ($("#Incub_expertise").val().length > 0) { incubsql += " AND Company_Expertise__Marketing_Te = '%" + $("#Incub_Keyword").val() + "%' "; } if ($("#Incub_County option:selected").text().length > 1) { var counties = []; var county_sql = ''; $('#Incub_County option:selected').each(function () { counties.push($(this).val()); }); if (counties.length == 1) { incubsql += " AND County = '" + $("#Incub_County option:selected").text() + "' "; } else { for (index = 0; index < counties.length; ++index) { var county_counter = index + 1; if (county_counter == counties.length) { county_sql += "County = '" + counties[index] + "'"; } else { county_sql += "County = '" + counties[index] + "' OR "; } } incubsql += " AND ( " + county_sql + " )"; } } if ($("#Incub_Ind_Ser option:selected").val() == "Agriculture_Forestry_Fishing_Hu") { incubsql += " AND Agriculture_Forestry_Fishing_Hu = 1 "; } if ($("#Incub_Ind_Ser option:selected").val() == "Mining") { incubsql += " AND Mining = 1 "; } if ($("#Incub_Ind_Ser option:selected").val() == "Utilities") { incubsql += " AND Utilities = 1 "; } if ($("#Incub_Ind_Ser option:selected").val() == "Construction") { incubsql += " AND Construction = 1 "; } if ($("#Incub_Ind_Ser option:selected").val() == "Manufacturing") { incubsql += " AND Manufacturing = 1 "; } if ($("#Incub_Ind_Ser option:selected").val() == "Wholesale_Trade") { incubsql += " AND Wholesale_Trade = 1 "; } if ($("#Incub_Ind_Ser option:selected").val() == "Retail_Trade") { incubsql += " AND Retail_Trade = 1 "; } if ($("#Incub_Ind_Ser option:selected").val() == "Transportation_and_Warehousing") { incubsql += " AND Transportation_and_Warehousing = 1 "; } if ($("#Incub_Ind_Ser option:selected").val() == "Information") { incubsql += " AND Information = 1 "; } if ($("#Incub_Ind_Ser option:selected").val() == "Finance_and_Insurance") { incubsql += " AND Finance_and_Insurance = 1 "; } if ($("#Incub_Ind_Ser option:selected").val() == "Real_Estate_and_Rental_and_Leas") { incubsql += " AND Real_Estate_and_Rental_and_Leas = 1 "; } if ($("#Incub_Ind_Ser option:selected").val() == "Professional_Scientific_and_Tec") { incubsql += " AND Professional_Scientific_and_Tec = 1 "; } if ($("#Incub_Ind_Ser option:selected").val() == "Management_of_Companies_and_Ent") { incubsql += " AND Management_of_Companies_and_Ent = 1 "; } if ($("#Incub_Ind_Ser option:selected").val() == "Administrative_and_Support_and_") { incubsql += " AND Administrative_and_Support_and_ = 1 "; } if ($("#Incub_Ind_Ser option:selected").val() == "Educational_Services") { incubsql += " AND Educational_Services = 1 "; } if ($("#Incub_Ind_Ser option:selected").val() == "Health_Care_and_Social_Assistan") { incubsql += " AND Health_Care_and_Social_Assistan = 1 "; } if ($("#Incub_Ind_Ser option:selected").val() == "Arts_Entertainment_and_Recreati") { incubsql += " AND Arts_Entertainment_and_Recreati = 1 "; } if ($("#Incub_Ind_Ser option:selected").val() == "Accommodation_and_Food_Services") { incubsql += " AND Accommodation_and_Food_Services = 1 "; } if ($("#Incub_Ind_Ser option:selected").val() == "Other_Services") { incubsql += " AND Other_Services = 1 "; } if ($("#Incub_Ind_Ser option:selected").val() == "Public_Administration") { incubsql += " AND Public_Administration = 1 "; } console.log(incubquery); //incubquery+= " AND ObjectID != '4' " incubquery.where = incubsql; incubqueryTask.execute(incubquery, showincubsResults); } function showincubsResults(results) { var resultItems = []; var resultCount = results.features.length; var tempResults = ""; log_search("Incubators", incubsql, resultCount); //global.js console.log(results); for (var i = 0; i < resultCount; i++) { var fa = results.features[i].attributes; var featureGeo = results.features[i].geometry; console.log(fa); /*var map_points = new SimpleMarkerSymbol(); map_points.style = map_points.STYLE_SQUARE; map_points.setSize(8); map_points.setColor(new Color([255, 0, 144, 1.0]));*/ var pictureMarkerSymbol = new PictureMarkerSymbol('/images/icons/incubator.png?', 20, 20); //var renderer = new SimpleRenderer(map_points); var graphic = results.features[i]; //graphic.setSymbol(map_points); graphic.setSymbol(pictureMarkerSymbol); $('.count_results').html(resultCount + ' result' + (resultCount == 1 ? "" : "s")); if (!isNaN(featureGeo['x']) && !isNaN(featureGeo['y'])) { map.graphics.add(graphic); var NumberofStaff = fa["Number_of_Staff"]; if (NumberofStaff == "null" || !NumberofStaff) { NumberofStaff = ""; } tempResults += "" + "" + "" + fa["Company_Name"] + "" + "" + fa["Street_Address"] + "" + "" + fa["Nearest_Incorporated_City"] + "" + "" + fa["Zip_1"] + "" + "" + NumberofStaff + "         " + ""; // console.log('%c ADD POINT TO MAP %c ' + fa['ObjectID'] + ' ~ ' + fa['Company_Name'] + ' ', 'background-color: #3366FF; color: #fff;', ''); } } if (resultCount == 0) { tempResults += "no results found"; $('.count_results').html("no results found. try another saerch"); } $("#search-results").show(); $("#ajax_content_incubator_search_results").html(tempResults); process_table('#incubator-search-result'); update_search_tabsize(true); console.log(resultCount); map.addLayer(queryTask); $('.loader').hide(); incubsql = ''; process_table('#incubator-search-result'); } /******************************************************************************* QUERY FOR County ********************************/ console.log('County'); on(dom.byId("County_search_btn"), "click", execute_County); function execute_County() { $('#SearchingLoader').show(); clearSearchResults(); map.graphics.clear(); CountySql = ""; if ($("#County_Search_Counties option:selected").text().length > 1) { var counties = []; var County_sql = ''; $('#County_Search_Counties option:selected').each(function () { counties.push($(this).val()); }); if (counties.length == 1) { CountySql += $("#County_Search_Counties option:selected").val(); } else { for (index = 0; index < counties.length; ++index) { var Msa_counter = index + 1; County_sql += counties[index] + ","; } CountySql += County_sql; } } else { CountySql = "all"; } searchCountyViaAjax(CountySql); } function searchCountyViaAjax(sql) { console.log('searchCountyViaAjax'); console.log(sql); $.ajax({ url: '/search/search-ajax.aspx?type=county&sql=' + sql, method: "GET", success: function (r) { console.log(r); var rs = r.split("~"); $('.count_results').html(rs[0] + ' result' + (rs[0] == 1 ? "" : "s")); console.log(rs[0]); $("#ajax_content_county_search_results").html(rs[1]); $("#search-results").show(); process_table('#county-search-result'); update_search_tabsize(true); $('.loader').hide(); if (rs[0] == 0) { tempResults += "no results found"; $('.count_results').html("no results found. try another saerch"); } } }); } /******************************************************************************* QUERY FOR Countys ******************************** console.log('county'); var Countysql = " cnty_state_code = '01' "; var CountyqueryTask = new QueryTask("http://ec2-54-163-148-251.compute-1.amazonaws.com:6080/arcgis/rest/services/BackgroundService/MapServer/24"); var Countyquery = new Query(); Countyquery.returnGeometry = true; Countyquery.outFields = [ "cnty_county_code", "cnty_name", "cnty_cur_dec_pop_num", "cnty_cur_pop_num", "cnty_civil_labor_force_num", "cnty_unemployment_rate_num", "cnty_proj_pop_num" ]; Countyquery.orderByFields = ["cnty_name"]; Countyquery.outSpatialReference = { wkid: 4326 }; on(dom.byId("County_search_btn"), "click", execute_County); function execute_County() { console.log("Searching__Loader"); $('#SearchingLoader').show(); Countysql = " cnty_state_code = '01' " clearSearchResults(); console.log('turn off county select tool'); DoCountySelectTool = false; $('.CountySelectToolBtn').css('background-color', '#fff'); map.graphics.clear(); //Countysql += " AND CNTY_FIPS LIKE '%" + $("#County_Search_Counties").val() + "%'"; if ($("#County_Search_Counties option:selected").text().length > 1) { var counties = []; var county_sql = ''; $('#County_Search_Counties option:selected').each(function () { counties.push($(this).val()); }); if (counties.length == 1) { Countysql += " AND cnty_county_code = '" + $("#County_Search_Counties option:selected").val() + "' "; } else { for (index = 0; index < counties.length; ++index) { var county_counter = index + 1; if (county_counter == counties.length) { county_sql += "cnty_county_code = '" + counties[index] + "'"; } else { county_sql += "cnty_county_code = '" + counties[index] + "' OR "; } } Countysql += " AND ( " + county_sql + " )"; } } console.log(Countysql); Countyquery.where = Countysql; CountyqueryTask.execute(Countyquery, showCountysResults); } /* "Company_Name", "Street_Address", "City_1", "Zip_1", "NumEmps", "AlabamaBased", "Marketing_Text", "ObjectID" ]; * function showCountysResults(results) { var tempResults; var resultItems = []; var resultCount = results.features.length; var cnty_cur_dec_pop_num = ""; var cnty_cur_pop_num = ""; var cnty_civil_labor_force_num = ""; var cnty_proj_pop_num = ""; log_search("County", Countysql, resultCount); //global.js for (var i = 0; i < resultCount; i++) { console.log(resultCount); var fa = results.features[i].attributes; //var featureGeo = results.features[i].geometry; //var pictureMarkerSymbol = new PictureMarkerSymbol('/images/icons/County.png', 20, 20); console.log(fa); //var graphic = results.features[i]; //graphic.setSymbol(pictureMarkerSymbol); $('.count_results').html(resultCount + ' result' + (resultCount == 1 ? "" : "s")); //if (!isNaN(featureGeo['x']) && !isNaN(featureGeo['y'])) { //map.graphics.add(graphic); //console.log(i + " || " + fa['ObjectID']); if (fa['cnty_cur_dec_pop_num'] == "null" || !fa['cnty_cur_dec_pop_num']) { cnty_cur_dec_pop_num = ""; } else { cnty_cur_dec_pop_num = commaSeparateNumber(fa["cnty_cur_dec_pop_num"]); } if (fa['cnty_cur_pop_num'] == "null" || !fa['cnty_cur_pop_num']) { cnty_cur_pop_num = ""; } else { cnty_cur_pop_num = commaSeparateNumber(fa["cnty_cur_pop_num"]); } if (fa['cnty_civil_labor_force_num'] == "null" || !fa['cnty_civil_labor_force_num']) { cnty_civil_labor_force_num = ""; } else { cnty_civil_labor_force_num = commaSeparateNumber(fa["cnty_civil_labor_force_num"]); } if (fa['cnty_proj_pop_num'] == "null" || !fa['cnty_proj_pop_num']) { cnty_proj_pop_num = ""; } else { cnty_proj_pop_num = commaSeparateNumber(fa["cnty_proj_pop_num"]); } tempResults += "" + "" + fa['cnty_county_code'] + "" + "" + fa["cnty_name"] + "" + "" + cnty_cur_dec_pop_num + "" + "" + cnty_cur_pop_num + "" + "" + cnty_proj_pop_num + "" + "" + cnty_civil_labor_force_num + "" + "" + fa['cnty_unemployment_rate_num'] + "%" + ""; //} // end if x and y are numbers // console.log('%c ADD POINT TO MAP %c ' + fa['ObjectID'] + ' ~ ' + fa['Company_Name'] + ' ', 'background-color: #3366FF; color: #fff;', ''); } // end for each result in list of results // console.log('Stuff'); /* $("#search-results").show(); $("#ajax_content_site_search_results").html(tempResults); process_table('#site-search-result'); update_search_tabsize(true); console.log(resultCount); map.addLayer(query2Task); $('.loader').hide(); sitesql = ''; process_table('#site-search-result');* if (resultCount == 0) { tempResults += "no results found"; $('.count_results').html("no results found. try another saerch"); } $("#search-results").show(); $("#ajax_content_county_search_results").html(tempResults); process_table('#county-search-result'); update_search_tabsize(true); console.log(resultCount); map.addLayer(CountyqueryTask); $('.loader').hide(); Countysql = ''; process_table('#county-search-result'); } // show_results CountyS *//******************************************************************************* QUERY FOR Msas ********************************/ console.log('Msa'); on(dom.byId("msa_search_btn"), "click", execute_Msa); function execute_Msa() { $('#SearchingLoader').show(); clearSearchResults(); map.graphics.clear(); Msasql = ""; if ($("#Msa_Search_Counties option:selected").text().length > 1) { var counties = []; var Msa_sql = ''; $('#Msa_Search_Counties option:selected').each(function () { counties.push($(this).val()); }); if (counties.length == 1) { Msasql += $("#Msa_Search_Counties option:selected").val(); } else { for (index = 0; index < counties.length; ++index) { var Msa_counter = index + 1; Msa_sql += counties[index] + ","; } Msasql += Msa_sql; } } else { Msasql = "all"; } searchMsaViaAjax(Msasql); } function searchMsaViaAjax(sql) { console.log('searchMsaViaAjax'); console.log(sql); $.ajax({ url: '/search/search-ajax.aspx?type=msa&sql=' + sql, method: "GET", success: function (r) { console.log(r); var rs = r.split("~"); $('.count_results').html(rs[0] + ' result' + (rs[0] == 1 ? "" : "s")); console.log(rs[0]); $("#ajax_content_msa_search_results").html(rs[1]); $("#search-results").show(); process_table('#msa-search-result'); update_search_tabsize(true); $('.loader').hide(); if (rs[0] == 0) { tempResults += "no results found"; $('.count_results').html("no results found. try another saerch"); } } }); } /******************************************************************************* QUERY FOR TECHOPPS ********************************/ var TechOppsql = /*" ObjectID > 0 "*/ ""; var TechOppqueryTask = new QueryTask("http://ec2-54-163-148-251.compute-1.amazonaws.com:6080/arcgis/rest/services/TechOpps2/MapServer/0"); var TechOppquery = new Query(); TechOppquery.returnGeometry = true; TechOppquery.outFields = [ "ObjectID", "State_of_Development", "Technology_Title", "University_Name"]; TechOppquery.orderByFields = ["Technology_Title"]; TechOppquery.outSpatialReference = { wkid: 4326 }; on(dom.byId("TechOpp_search_btn"), "click", execute_TechOpp); function execute_TechOpp() { console.log("Searching__Loader"); $('#SearchingLoader').show(); //TechOppsql = " 1=1 " var CountSqlWheres = 0; clearSearchResults(); map.graphics.clear(); /* if ($("#TechOpp_Title").val().length > 0) { TechOppsql += " AND Technology_Title = '%" + $("#TechOpp_Title").val() + "%' "; }*/ var WasThereAPrevDefine = false; if ($("#TechOpp_Title").val().length > 0) { TechOppsql += (WasThereAPrevDefine ? "AND" : "") + " Technology_Title LIKE '%" + $("#TechOpp_Title").val() + "%' "; WasThereAPrevDefine = true; CountSqlWheres++; } //TechOpp_Id if ($("#TechOpp_Id").val().length > 0) { if ($("#TechOpp_Id").val().indexOf(',') > -1) { console.log('TechOpp_Id has comma, search for mutli'); var propids = $("#TechOpp_Id").val().split(','); var techopp_sql = ""; for (index = 0; index < propids.length; ++index) { var techopp_counter = index + 1; console.log('mutli prop id #' + index, propids[index]); if (techopp_counter == propids.length) { techopp_sql += " ObjectID = '" + propids[index] + "'"; } else { techopp_sql += " ObjectID = '" + propids[index] + "' OR "; } } TechOppsql += (WasThereAPrevDefine ? "AND" : "") + " ( " + techopp_sql + " )"; } else { console.log('TechOpp_Id has only 1'); TechOppsql += (WasThereAPrevDefine ? "AND" : "") + " ObjectID = '" + $("#TechOpp_Id").val() + "' "; } CountSqlWheres++; WasThereAPrevDefine = true; } if ($("#TechOpp_Organization").val().length > 0) { TechOppsql += (WasThereAPrevDefine ? "AND" : "") + " Organization LIKE '%" + $("#TechOpp_Organization").val() + "%' "; WasThereAPrevDefine = true; CountSqlWheres++; } if ($("#Detailed_Technology_Description").val().length > 0) { TechOppsql += (WasThereAPrevDefine ? "AND" : "") + " Detailed_Technology_Description LIKE '%" + $("#Detailed_Technology_Description").val() + "%' "; WasThereAPrevDefine = true; CountSqlWheres++; } if ($("#TechOpp_Inventor_Name").val().length > 0) { TechOppsql += (WasThereAPrevDefine ? "AND" : "") + " (Inventor_Name LIKE '%" + $("#TechOpp_Inventor_Name").val() + "%' OR Inventor_Name_2 LIKE '%" + $("#TechOpp_Inventor_Name").val() + "%' OR Inventor_Name_3 LIKE '%" + $("#TechOpp_Inventor_Name").val() + "%' OR Inventor_Name_4 LIKE '%" + $("#TechOpp_Inventor_Name").val() + "%') "; WasThereAPrevDefine = true; CountSqlWheres++; } if ($("#TechOpp_Patent_Number").val().length > 0) { TechOppsql += (WasThereAPrevDefine ? "AND" : "") + " (Patent_Number_1 LIKE '%" + $("#TechOpp_Patent_Number").val() + "%' OR Patent_Number_2 LIKE '%" + $("#TechOpp_Patent_Number").val() + "%' OR Patent_Number_3 LIKE '%" + $("#TechOpp_Patent_Number").val() + "%' OR Patent_Number_4 LIKE '%" + $("#TechOpp_Patent_Number").val() + "%') "; WasThereAPrevDefine = true; CountSqlWheres++; } if (CountSqlWheres == 0) { TechOppsql = "1=1"; } TechOppquery.where = TechOppsql; TechOppqueryTask.execute(TechOppquery, showTechOppsResults); } /* "Company_Name", "Street_Address", "City_1", "Zip_1", "NumEmps", "AlabamaBased", "Marketing_Text", "ObjectID" ]; */ function showTechOppsResults(results) { var tempResults; var resultItems = []; var resultCount = results.features.length; log_search("Technology", TechOppsql, resultCount); //global.js for (var i = 0; i < resultCount; i++) { var featureGeo = results.features[i].geometry; console.log(resultCount); var fa = results.features[i].attributes; console.log(fa); var pictureMarkerSymbol = new PictureMarkerSymbol('/images/icons/techopps.png', 20, 20); //var renderer = new SimpleRenderer(map_points); var graphic = results.features[i]; //graphic.setSymbol(map_points); graphic.setSymbol(pictureMarkerSymbol); $('.count_results').html(resultCount + ' result' + (resultCount == 1 ? "" : "s")); if (!isNaN(featureGeo['x']) && !isNaN(featureGeo['y'])) { map.graphics.add(graphic); //console.log(i + " || " + fa['ObjectID']); tempResults += "" + "" + fa["Technology_Title"] + "" + "" + fa["University_Name"] + "" + "" + (fa["State_of_Development"] == null ? "n/a" : fa["State_of_Development"]) + "" + ""; } // end if x and y are numbers // console.log('%c ADD POINT TO MAP %c ' + fa['ObjectID'] + ' ~ ' + fa['Company_Name'] + ' ', 'background-color: #3366FF; color: #fff;', ''); } // end for each result in list of results if (resultCount == 0) { tempResults += "no results found"; $('.count_results').html("no results found. try another saerch"); } // console.log('Stuff'); /* $("#search-results").show(); $("#ajax_content_site_search_results").html(tempResults); process_table('#site-search-result'); update_search_tabsize(true); console.log(resultCount); map.addLayer(query2Task); $('.loader').hide(); sitesql = ''; process_table('#site-search-result');*/ $("#search-results").show(); $("#ajax_content_techopp_search_results").html(tempResults); process_table('#techopp-search-result'); update_search_tabsize(true); console.log(resultCount); map.addLayer(TechOppqueryTask); $('.loader').hide(); TechOppsql = ''; process_table('#techopp-search-result'); } // show_results TechOppS /******************************************************************************* QUERY FOR PATENTS ********************************/ var PatentResultCountForPointsOnMap = 0; var ObjectsToPlaceOnMap = []; var patentsql = /*" ObjectID > 0 "*/ ""; var patentqueryTask = new QueryTask("http://ec2-54-163-148-251.compute-1.amazonaws.com:6080/arcgis/rest/services/Patents/MapServer/1"); var patentquery = new Query(); patentquery.returnGeometry = true; patentquery.outFields = [ "archpatent_id", "invention_title", "abstract", "us_patent_classifications", "publication_number", "publication_date", "main_us_classification"]; patentquery.orderByFields = ["invention_title"]; patentquery.outSpatialReference = { wkid: 4326 }; on(dom.byId("patent_search_btn"), "click", execute_patent); function execute_patent() { console.log("Searching__Loader"); $('#SearchingLoader').show(); //patentsql = " 1=1 " var CountSqlWheres = 0; clearSearchResults(); // map.graphics.clear(); /* if ($("#patent_Title").val().length > 0) { patentsql += " AND Technology_Title = '%" + $("#patent_Title").val() + "%' "; }*/ var WasThereAPrevDefine = false; if ($("#patent_Title").val().length > 0) { patentsql += (WasThereAPrevDefine ? "AND" : "") + " invention_title LIKE '%" + $("#patent_Title").val() + "%' "; WasThereAPrevDefine = true; CountSqlWheres++; } if ($("#patent_Abstract").val().length > 0) { patentsql += (WasThereAPrevDefine ? "AND" : "") + " abstract LIKE '%" + $("#patent_Abstract").val() + "%' "; WasThereAPrevDefine = true; CountSqlWheres++; } if ($("#patent_Classification").val().length > 0) { patentsql += (WasThereAPrevDefine ? "AND" : "") + " us_patent_classifications LIKE '%" + $("#patent_Classification").val() + "%' "; WasThereAPrevDefine = true; CountSqlWheres++; } /* if ($("#patent_Claims").val().length > 0) { patentsql += (WasThereAPrevDefine ? "AND" : "") + " Detailed_Technology_Description LIKE '%" + $("#Detailed_Technology_Description").val() + "%' "; WasThereAPrevDefine = true; CountSqlWheres++; }*/ if ($("#patent_City").val().length > 0) { patentsql += (WasThereAPrevDefine ? "AND" : "") + " city LIKE '%" + $("#patent_City").val() + "%' "; WasThereAPrevDefine = true; CountSqlWheres++; } if ($("#patent_Number").val().length > 0) { patentsql += (WasThereAPrevDefine ? "AND" : "") + " archpatent_id LIKE '%" + $("#patent_Number").val() + "%' "; WasThereAPrevDefine = true; CountSqlWheres++; } if ($("#patent_fillingdate_min").val().length > 0) { patentsql += (WasThereAPrevDefine ? "AND" : "") + " filing_date > " + $("#patent_fillingdate_min").val() + " "; WasThereAPrevDefine = true; CountSqlWheres++; } if ($("#patent_fillingdate_max").val().length > 0) { patentsql += (WasThereAPrevDefine ? "AND" : "") + " filing_date < " + $("#patent_fillingdate_max").val() + " "; WasThereAPrevDefine = true; CountSqlWheres++; } if ($("#patent_issuedate_min").val().length > 0) { patentsql += (WasThereAPrevDefine ? "AND" : "") + " publication_date > " + $("#patent_issuedate_min").val() + " "; WasThereAPrevDefine = true; CountSqlWheres++; } if ($("#patent_issuedate_max").val().length > 0) { patentsql += (WasThereAPrevDefine ? "AND" : "") + " publication_date < " + $("#patent_issuedate_max").val() + " "; WasThereAPrevDefine = true; CountSqlWheres++; } var doit = false; if (CountSqlWheres == 0) { patentsql = "1=1"; } else { doit = true; } patentquery.where = patentsql; if (doit) { patentqueryTask.execute(patentquery, showpatentsResults); } else { if (confirm("This query will return a massive amount of data that may cause your browser (especially Internet Explorer) to temporary be unresponsive. ")) { patentqueryTask.execute(patentquery, showpatentsResults); } } } /* "Company_Name", "Street_Address", "City_1", "Zip_1", "NumEmps", "AlabamaBased", "Marketing_Text", "ObjectID" ]; */ function showpatentsResults(results) { var tempResults; var resultItems = []; var resultCount = results.features.length; console.log(resultCount); ObjectsToPlaceOnMap = []; // reset array log_search("Technology", patentsql, resultCount); //global.js for (var i = 0; i < resultCount; i++) { var fa = results.features[i].attributes; var featureGeo = results.features[i].geometry; //console.log(results.features[i]); // console.log(fa); $('.count_results').html(resultCount + ' result' + (resultCount == 1 ? "" : "s")); PatentResultCountForPointsOnMap = resultCount; //console.log(featureGeo); var pictureMarkerSymbol = new PictureMarkerSymbol('/images/icons/patent.png', 20, 20); var graphic = results.features[i]; graphic.setSymbol(pictureMarkerSymbol); //if (!isNaN(featureGeo['x']) && !isNaN(featureGeo['y'])) { // map.graphics.add(graphic); //console.log(i + " || " + fa['ObjectID']); //map.graphics.add(graphic); tempResults += "]+(>|$)/g, "") + "\" type='checkbox' name='patent' value='" + fa["archpatent_id"] + "' />" + "" + fa["archpatent_id"] + "" + "" + fa["invention_title"].replace(/<\/?[^>]+(>|$)/g, "") + "" + "" + fa["main_us_classification"] + "" + "" + fa["publication_date"] + "" + ""; ObjectsToPlaceOnMap.push(fa["archpatent_id"]); //} else { // end if x and y are numbers // console.log('no'); // } // console.log('%c ADD POINT TO MAP %c ' + fa['ObjectID'] + ' ~ ' + fa['Company_Name'] + ' ', 'background-color: #3366FF; color: #fff;', ''); } // end for each result in list of results // console.log('Stuff'); if (resultCount == 0) { tempResults += "no results found"; $('.count_results').html("no results found. try another saerch"); } /* $("#search-results").show(); $("#ajax_content_site_search_results").html(tempResults); process_table('#site-search-result'); update_search_tabsize(true); console.log(resultCount); map.addLayer(query2Task); $('.loader').hide(); sitesql = ''; process_table('#site-search-result');*/ $("#search-results").show(); $("#ajax_content_patent_search_results").html(tempResults); process_table('#patent-search-result'); update_search_tabsize(true); console.log(resultCount); //map.addLayer(patentqueryTask); $('.loader').hide(); patentsql = ''; process_table('#patent-search-result'); console.log(ObjectsToPlaceOnMap); execute_patentPoints(); } // show_results patentS // to get the points on the map: var PatentPointqueryTask = new QueryTask("http://ec2-54-163-148-251.compute-1.amazonaws.com:6080/arcgis/rest/services/Patents/MapServer/0"); var patentpointsql = ""; var PatentPointquery = new Query(); PatentPointquery.returnGeometry = true; PatentPointquery.outFields = ["*"]; PatentPointquery.orderByFields = ["ObjectID"]; PatentPointquery.outSpatialReference = { wkid: 4326 }; //Fifth Wheel Slide Rail function execute_patentPoints() { //patentpointsql = "archpatent_id = " + ObjectsToPlaceOnMap.join(" OR archpatent_id = "); //patentpointsql = "archpatent_id = 5728893"; //patentpointsql = "1=1"; //console.log("ObjectsToPlaceOnMap", ObjectsToPlaceOnMap); //console.log("archpatent_id = " + ObjectsToPlaceOnMap.join(" OR archpatent_id = ")); console.log(PatentResultCountForPointsOnMap); if (PatentResultCountForPointsOnMap > 1000) { patentpointsql = "1=1"; } else { patentpointsql = "archpatent_id = " + ObjectsToPlaceOnMap.join(" OR archpatent_id = "); } console.log(patentpointsql); PatentPointquery.where = patentpointsql; PatentPointqueryTask.execute(PatentPointquery, showpatentsPoints); } function showpatentsPoints(results) { var tempResults; var resultItems = []; var resultCount = results.features.length; for (var i = 0; i < resultCount; i++) { var fa = results.features[i].attributes; var featureGeo = results.features[i].geometry; //console.log(fa); var pictureMarkerSymbol = new PictureMarkerSymbol('/images/icons/patent.png', 20, 20); var graphic = results.features[i]; graphic.setSymbol(pictureMarkerSymbol); //$('.count_results').html(resultCount + ' result' + (resultCount == 1 ? "" : "s")); if (!isNaN(featureGeo['x']) && !isNaN(featureGeo['y'])) { map.graphics.add(graphic); } } map.addLayer(PatentPointqueryTask); } /* msa layers * var MsaLayersql = " 1=1 "; var MsaLayerqueryTask = new QueryTask("http://ec2-54-163-148-251.compute-1.amazonaws.com:6080/arcgis/rest/services/BackgroundService/MapServer/22"); var MsaLayerquery = new Query(); MsaLayerquery.returnGeometry = true; MsaLayerquery.outFields = ["*"]; MsaLayerquery.outSpatialReference = { wkid: 4326 }; on(dom.byId("MsaLayer_search_btn"), "click", execute_MsaLayer); function execute_MsaLayer() { MsaLayerquery.where = MsaLayersql; MsaLayerqueryTask.execute(MsaLayerquery, showMsaLayersResults); } function showMsaLayersResults(results) { var resultItems = []; var resultCount = results.features.length; var fa = results.features[0].attributes; var featureGeo = results.features[0].geometry console.log(results.features[0]); console.log(fa); console.log(resultCount); //var pictureMarkerSymbol = new PictureMarkerSymbol('/images/icons/building.png', 20, 20); var graphic = results.features[0]; //graphic.setSymbol(pictureMarkerSymbol); //graphic.setRenderer(); /* var symbol = new SimpleFillSymbol( SimpleFillSymbol.STYLE_SOLID, new SimpleLineSymbol( SimpleLineSymbol.STYLE_SOLID, new Color([255, 255, 255, 1]), 1 ), new Color([125, 125, 125, 1]) ); graphic.setSymbol(new SimpleRenderer(symbol)); map.graphics.add(results.features[0]);* var polygon = new Polygon(results.features[0].geometry); map.addLayer(polygon); map.graphics.add(polygon); map.addLayer(MsaLayerqueryTask); } // show_results /******************************************************************************* QUERY FOR MsaLayers ******************************** console.log('MsaLayer'); var MsaLayersql = " "; var MsaLayerqueryTask = new QueryTask("http://ec2-54-163-148-251.compute-1.amazonaws.com:6080/arcgis/rest/services/BackgroundService/MapServer/22"); var MsaLayerquery = new Query(); MsaLayerquery.returnGeometry = true; MsaLayerquery.outFields = [ "*" ]; MsaLayerquery.orderByFields = ["NAME"]; MsaLayerquery.outSpatialReference = { wkid: 4326 }; on(dom.byId("MsaLayer_search_btn"), "click", execute_MsaLayer, "df"); // need this btn function execute_MsaLayer(incoming_data) { console.log("Sfgsfg" + incoming_data) console.log(incoming_data); MsaLayersql = "OBJECTID=1" console.log(MsaLayersql); MsaLayerquery.where = MsaLayersql; MsaLayerqueryTask.execute(MsaLayerquery, showMsaLayersResults); } function showMsaLayersResults(results) { var tempResults; var resultItems = []; var resultCount = results.features.length; console.log(results.features[0]); var fa = results.features[0].attributes; var featureGeo = results.features[0].geometry; console.log(fa); map.graphics.add(results.features[0]); console.log(resultCount); map.addLayer(MsaLayerqueryTask); } // show_results // end MSA LAYER */ $('#SearchViaAddressBtn').click(function () { locate_via_address(); }); locator = new Locator("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer"); function locate_via_address() { console.log('locate_via_address()'); if ($('input[name="search_via_address"]').val().length > 0) { var address = $('input[name="search_via_address"]').val(); address = { SingleLine: address }; console.log(address); var options = { address: address, outFields: ["*"] }; console.log(options); locator.addressToLocations(options); } else { alert("address required"); } } locator.on("address-to-locations-complete", function (evt) { map.graphics.clear(); arrayUtils.forEach(evt.addresses, function (geocodeResult, index) { //create a random color for the text and marker symbol var r = Math.floor(Math.random() * 250); var g = Math.floor(Math.random() * 100); var b = Math.floor(Math.random() * 100); var symbol = new SimpleMarkerSymbol( SimpleMarkerSymbol.STYLE_CIRCLE, 20, new SimpleLineSymbol( SimpleLineSymbol.STYLE_SOLID, new Color([r, g, b, 0.5]), 10 ), new Color([r, g, b, 0.9])); var pointMeters = webMercatorUtils.geographicToWebMercator(geocodeResult.location); var locationGraphic = new Graphic(pointMeters, symbol); //add the location graphic and text with the address to the map map.graphics.add(locationGraphic); map.graphics.add(new Graphic(pointMeters)); }); showResults_AddressSearch(evt.addresses); }); map.on("extent-change", updateExtent); function updateExtent() { console.log("Current Extent JSON:" + JSON.stringify(map.extent.toJson())); console.log("Current Zoom level:" + map.getLevel()); } function showResults_AddressSearch(results) { //var rdiv = dom.byId("resultsdiv"); //rdiv.innerHTML = "

Results : " + results.length + "



"; console.log(results.length); var content = []; arrayUtils.forEach(results, function (result, index) { var x = result.location.x.toFixed(5); var y = result.location.y.toFixed(5); content.push("
"); content.push("" + (index + 1) + ". " + result.address + ""); content.push("Score: " + result.score); content.push("
"); content.push("Latitude/Longitude: " + y); content.push(", "); content.push("" + x); content.push(" "); content.push("
"); //} }); //rdiv.innerHTML += content.join(""); console.log(content); $("#SearchAddressResults").html("results:" + content.join('')); $("#SearchAddressResults").show(); }/*-county select tool-*/ //var CountySelect_queryTask = new QueryTask("http://ec2-54-163-148-251.compute-1.amazonaws.com:6080/arcgis/rest/services/BackgroundService/MapServer/23"); var CountySelect_queryTask = new QueryTask("http://ec2-54-163-148-251.compute-1.amazonaws.com:6080/arcgis/rest/services/BackgroundService2/MapServer/32"); var CountySelect_query = new Query(); CountySelect_query.returnGeometry = true; CountySelect_query.outFields = ["*"]; CountySelect_query.orderByFields = ["NAME"]; CountySelect_query.outSpatialReference = map.spatialReference; map.on("click", function (e) { if (DoCountySelectTool) { CountySelect_executeQueryTask(e,null); } }); $('.county_select').change(function () { if (DoCountySelectTool) { } else { if ($(this).val() != null) { console.log("county_select change. this value = ", $(this).val()); CountySelect_executeQueryTask(null, $(this).val()); map.graphics.clear(); } else { } } }); function CountySelect_executeQueryTask(evt, section) { if (section != null) { CountySelect_query.outSpatialReference = map.spatialReference; console.log('querytask based on selectbox', section); //CountySelect_query.where = "CNTY_FIPS='" + section.replace('xo_', '') + "'"; CountySelect_query.where = "CNTY_FIPS='" + section.join("' OR CNTY_FIPS='") + "'"; console.log("query where", CountySelect_query.where); CountySelect_query.geometry = null; } else { console.log('querytask based on mapclick', evt); CountySelect_query.geometry = evt.mapPoint; CountySelect_query.where = null; } CountySelect_queryTask.execute(CountySelect_query, CountySelect_showResults); } function CountySelect_showResults(featureSet) { console.log("featureSet", featureSet); var CountySelect_symbol = new SimpleFillSymbol( SimpleFillSymbol.STYLE_SOLID, new SimpleLineSymbol( SimpleLineSymbol.STYLE_SOLID, new Color([255, 255, 255, 1]), 2 ), new Color([125, 125, 125, .5]) ); dojo.forEach(featureSet.features, function (feature) { var graphic = feature; graphic.setSymbol(CountySelect_symbol); console.log("feature", feature); console.log("NAME",feature.attributes.NAME); console.log("CNTY_FIPS",feature.attributes.CNTY_FIPS); console.info($(".county_select option:contains('" + feature.attributes.NAME + "')")); //$(".county_select option:contains('" + feature.attributes.NAME + "')").attr('selected', 'selected'); $(".county_select option:contains('" + feature.attributes.NAME + "')").prop('selected', true); $('.county_select').multiselect("refresh"); map.graphics.add(graphic); }); console.log('done countyselect'); } window.addToMap = function addPointToMap(lon, lat, prop_id_for_debug) { if (typeof prop_id_for_debug === 'undefined') { prop_id_for_debug = 'undefined'; } if (lon && lat) { console.log('add to map ' + prop_id_for_debug + ' - ' + lon + ',' + lat); map.graphics.add( new esri.Graphic( new esri.geometry.Point(lon, lat), new esri.symbol.SimpleMarkerSymbol().setSize(10).setColor(new dojo.Color([255, 0, 0, 1])) ) ) } else { console.log('*******bad data: ' + prop_id_for_debug + ' - ' + lon + ',' + lat + ' ********'); } } window.clearMapGraphics = function clearMapGraphics() { console.log('clear map graphics'); map.graphics.clear(); Buildinggeometry = ""; console.log(Buildinggeometry); query.geometry = null; } setTimeout(function () { // window.addToMap(0, 0) }, 2500); var USGSMapService = new ArcGISDynamicMapServiceLayer("http://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer", { "opacity": 1.0, "imageParameters": imageParameters, "id": "usgsmap" }); //BackgroundService2 range(0, 32, 1).forEach(function (entry) { var opacity = 1; if(entry==29) { opacity = 0.6; } // cities if(entry==31) { opacity = 0.5; } // metros if(entry==32) { opacity = 0.5; } // counties layers[entry] = new FeatureLayer(NewLayersUrl + entry, {"opacity": opacity, mode: FeatureLayer.MODE_SNAPSHOT, // was LayerUrl outFields: ["*"], "loadError" : function() { console.error('**load error ' + NewLayersUrl + entry); }}); if(entry=='22') { // commerical airport var symbol = new PictureMarkerSymbol({ "url":"/images/icons/airport.png", "height":20, "width":20 }); var renderer = new esri.renderer.SimpleRenderer(symbol); layers[entry].setRenderer(renderer); } if(entry=='23') { // international airport var symbol = new PictureMarkerSymbol({ "url":"/images/icons/international-airport.png", "height":20, "width":20 }); var renderer = new esri.renderer.SimpleRenderer(symbol); layers[entry].setRenderer(renderer); } if(entry=='19') { // four year college var symbol = new PictureMarkerSymbol({ "url":"/images/icons/four-year-college.png", "height":20, "width":20 }); var renderer = new esri.renderer.SimpleRenderer(symbol); layers[entry].setRenderer(renderer); } if(entry=='20') { // two year college var symbol = new PictureMarkerSymbol({ "url":"/images/icons/two-year-college.png", "height":20, "width":20 }); var renderer = new esri.renderer.SimpleRenderer(symbol); layers[entry].setRenderer(renderer); } if(entry=='27') { // railroad var symbol = new SimpleLineSymbol( SimpleLineSymbol.STYLE_SOLID, new Color([76, 20, 95, 1]), 4 ); var renderer = new esri.renderer.SimpleRenderer(symbol); layers[entry].setRenderer(renderer); } }); // NEW DATA range(0, 23, 1).forEach(function (entry) { var opacity = 1; if(entry=="8"||entry=="9") { opacity = .5; } layersNew[entry] = new FeatureLayer(LayerUrlNew + entry, {"opacity": opacity, mode: FeatureLayer.MODE_SNAPSHOT, outFields: ["*"], "loadError" : function() { console.log('load error ' + LayerUrlNew + entry); }}); if(entry=='5') { // port of mobile var symbol = new PictureMarkerSymbol({ "url":"/images/icons/port.png", "height":20, "width":20 }); var renderer = new esri.renderer.SimpleRenderer(symbol); layersNew[entry].setRenderer(renderer); } if(entry=='2') { // Intermodal var symbol = new PictureMarkerSymbol({ "url":"/images/icons/intermodal.png", "height":20, "width":20 }); var renderer = new esri.renderer.SimpleRenderer(symbol); layersNew[entry].setRenderer(renderer); } if(entry=='1') { // hospital var symbol = new PictureMarkerSymbol({ "url":"/images/icons/hospital.png", "height":10, "width":10 }); var renderer = new esri.renderer.SimpleRenderer(symbol); layersNew[entry].setRenderer(renderer); } if(entry=='7') { // aidt var symbol = new PictureMarkerSymbol({ "url":"/images/icons/aidt.png?v1.2", "height":20, "width":50 }); var renderer = new esri.renderer.SimpleRenderer(symbol); layersNew[entry].setRenderer(renderer); } }); // Background 2 range(19, 20, 1).forEach(function (entry) { var opacity = 1; layers2[entry] = new FeatureLayer(LayerUrl2 + entry, {"opacity": opacity, mode: FeatureLayer.MODE_SNAPSHOT, outFields: ["*"], "loadError" : function() { console.log('load error ' + LayerUrlNew + entry); }}); }); // Background 3 range(0, 6, 1).forEach(function (entry) { var opacity = 1; if(entry==5 || entry==6) { opacity = 0.6; } // nmtc layers3[entry] = new FeatureLayer(LayerUrl3 + entry, {"opacity": opacity, mode: FeatureLayer.MODE_SNAPSHOT, outFields: ["*"], "loadError" : function() { console.log('load error ' + LayerUrlNew + entry); }}); if(entry=='0') { // attractions var symbol = new PictureMarkerSymbol({ "url":"/images/icons/attractions.png", "height":15, "width":15 }); var renderer = new esri.renderer.SimpleRenderer(symbol); layers3[entry].setRenderer(renderer); } if(entry=='1') { // golf var symbol = new PictureMarkerSymbol({ "url":"/images/icons/golf.png", "height":15, "width":15 }); var renderer = new esri.renderer.SimpleRenderer(symbol); layers3[entry].setRenderer(renderer); } if(entry=='2') { // research parks var symbol = new PictureMarkerSymbol({ "url":"/images/icons/research_parks.png", "height":15, "width":15 }); var renderer = new esri.renderer.SimpleRenderer(symbol); layers3[entry].setRenderer(renderer); } }); map.on("zoom-end", function () { if(!HasUserChangedTheDefaultMapView) { if(map.getZoom()>10) { console.log('perform basemap change'); if(map.getBasemap()=="national-geographic") { map.setBasemap('osm'); } } else { console.log('perform basemap change'); if(map.getBasemap()=="osm") { map.setBasemap('national-geographic'); } } } }); map.on("update-start", function () { /* if(!DidUserChangeMapView) { console.log('DidUserChangeMapView? == NO'); console.log('map.getZoom = ' + map.getZoom()); console.log('map.getBasemap = ' + map.getBasemap()); /* if(map.getBasemap()=="national-geographic") { if(map.getZoom()>10) { console.log('perform basemap change'); map.setBasemap('osm'); } } else if (map.getBasemap()=="osm") { if(map.getZoom()<11) { console.log('perform basemap change'); map.setBasemap('national-geographic'); } } } */ $('#MapLoader').show(); log_msg('map update start'); //map.disablePan(); //map.disableScrollWheelZoom(); }); map.on("update-end", function () { $('#MapLoader').hide(); log_msg('map update end'); //map.enablePan(); //map.enableScrollWheelZoom(); }); //map.on("click", myClickHandler); map.on('click', function(e) { myClickHandler(e) } ); $(document).on('click', '#OEM_HACKED', function (e) { if($(this).is(':checked')) { $('#OEM_HACKED').parent().find('input').each(function () { $(this).prop('checked', true) }); } else { $('#OEM_HACKED').parent().find('input').each(function () { $(this).prop('checked', false) }); } }); /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////oem hack $(document).on('click', '#layers ul a', function (e) { e.preventDefault(); $(this).parent().find('ul').toggle(); }); var OemLayer = new FeatureLayer("http://ec2-54-163-148-251.compute-1.amazonaws.com:6080/arcgis/rest/services/EDPANewData/MapServer/0",{mode: FeatureLayer.MODE_SNAPSHOT, outFields: ["*"]}); var MsaLayer = new FeatureLayer("http://ec2-54-163-148-251.compute-1.amazonaws.com:6080/arcgis/rest/services/BackgroundService2/MapServer/31", {"opacity": 1.00}); var Attractions = new FeatureLayer("http://ec2-54-163-148-251.compute-1.amazonaws.com:6080/arcgis/rest/services/FinalAdditions/MapServer/0",{mode: FeatureLayer.MODE_SNAPSHOT, outFields: ["*"]}); var GolfLayer = new FeatureLayer("http://ec2-54-163-148-251.compute-1.amazonaws.com:6080/arcgis/rest/services/FinalAdditions/MapServer/1",{mode: FeatureLayer.MODE_SNAPSHOT, outFields: ["*"]}); var ResearchParkLayer = new FeatureLayer("http://ec2-54-163-148-251.compute-1.amazonaws.com:6080/arcgis/rest/services/FinalAdditions/MapServer/2",{mode: FeatureLayer.MODE_SNAPSHOT, outFields: ["*"]}); //var MsaLayerEsri = new esri.layers.GraphicsLayer(); //map.addLayer(MsaLayerEsri); function msa_layer_stuff(layer_id) { // do query task to place msa on map. } $('#layers ul input').click( function () { if(typeof $(this).data('msa') !== 'undefined') { //console.log(MsaLayer); //console.log(MsaLayer.graphics[1]); if ($(this).is(":checked")) { console.log($(this).data('msa')); var this_item = $(this).data('msa'); MsaLayer.setDefinitionExpression("OBJECTID = " + $(this).data('msa')); //MsaLayerEsri.add(MsaLayer.graphics[1]); map.addLayer(MsaLayer); //MsaLayer.graphics.addToMap(1); $(this).parent().parent().find('input').each(function() { console.log($(this)); if(this_item==$(this).data('msa')) { } else { $(this).attr('checked',false); } }); } else { map.removeLayer(MsaLayer); } console.log('stuff'); } if(typeof $(this).data('attractions') !== 'undefined') { var defaultSymbol = new SimpleFillSymbol().setStyle(SimpleFillSymbol.STYLE_NULL); defaultSymbol.outline.setStyle(SimpleLineSymbol.STYLE_NULL); var renderer = new UniqueValueRenderer(defaultSymbol, "FID"); //console.log(MsaLayer); //console.log(MsaLayer.graphics[1]); console.log('attractions'); if ($(this).is(":checked")) { console.log($(this).data('attractions')); var this_item = $(this).data('attractions'); Attractions.setDefinitionExpression("FID = " + $(this).data('attractions')); range(0, 10, 1).forEach(function (entry) { renderer.addValue(entry, new PictureMarkerSymbol({ "url":"/images/icons/attractions.png", "height":15, "width":15 })); }); Attractions.setRenderer(renderer); //MsaLayerEsri.add(MsaLayer.graphics[1]); map.addLayer(Attractions); //MsaLayer.graphics.addToMap(1); $(this).parent().parent().find('input').each(function() { console.log($(this)); if(this_item==$(this).data('attractions')) { } else { $(this).attr('checked',false); } }); } else { map.removeLayer(Attractions); } console.log('stuff attractions'); } if(typeof $(this).data('golf') !== 'undefined') { var defaultSymbol = new SimpleFillSymbol().setStyle(SimpleFillSymbol.STYLE_NULL); defaultSymbol.outline.setStyle(SimpleLineSymbol.STYLE_NULL); var renderer = new UniqueValueRenderer(defaultSymbol, "FID"); //console.log(MsaLayer); //console.log(MsaLayer.graphics[1]); console.log('golf'); if ($(this).is(":checked")) { console.log($(this).data('golf')); var this_item = $(this).data('golf'); GolfLayer.setDefinitionExpression("FID = " + $(this).data('golf')); range(0, 10, 1).forEach(function (entry) { renderer.addValue(entry, new PictureMarkerSymbol({ "url":"/images/icons/golf.png", "height":15, "width":15 })); }); GolfLayer.setRenderer(renderer); //MsaLayerEsri.add(MsaLayer.graphics[1]); map.addLayer(GolfLayer); //MsaLayer.graphics.addToMap(1); $(this).parent().parent().find('input').each(function() { console.log($(this)); if(this_item==$(this).data('golf')) { } else { $(this).attr('checked',false); } }); } else { map.removeLayer(GolfLayer); } console.log('stuff golf'); } if(typeof $(this).data('researchpark') !== 'undefined') { var defaultSymbol = new SimpleFillSymbol().setStyle(SimpleFillSymbol.STYLE_NULL); defaultSymbol.outline.setStyle(SimpleLineSymbol.STYLE_NULL); var renderer = new UniqueValueRenderer(defaultSymbol, "FID"); //console.log(MsaLayer); //console.log(MsaLayer.graphics[1]); console.log('researchpark'); if ($(this).is(":checked")) { console.log($(this).data('researchpark')); var this_item = $(this).data('researchpark'); ResearchParkLayer.setDefinitionExpression("FID = " + $(this).data('researchpark')); range(0, 4, 1).forEach(function (entry) { renderer.addValue(entry, new PictureMarkerSymbol({ "url":"/images/icons/research_parks.png", "height":15, "width":15 })); }); ResearchParkLayer.setRenderer(renderer); //MsaLayerEsri.add(MsaLayer.graphics[1]); map.addLayer(ResearchParkLayer); //MsaLayer.graphics.addToMap(1); $(this).parent().parent().find('input').each(function() { console.log($(this)); if(this_item==$(this).data('researchpark')) { } else { $(this).attr('checked',false); } }); } else { map.removeLayer(ResearchParkLayer); } console.log('stuff researchpark'); } else if(typeof $(this).data('auto') !== 'undefined') { var defaultSymbol = new SimpleFillSymbol().setStyle(SimpleFillSymbol.STYLE_NULL); defaultSymbol.outline.setStyle(SimpleLineSymbol.STYLE_NULL); var renderer = new UniqueValueRenderer(defaultSymbol, "FID"); if(typeof $(this).data('parent') !== 'undefined') { map.removeLayer(OemLayer); if ($(this).is(":checked")) { range(0, 14, 1).forEach(function (entry) { renderer.addValue(entry, new PictureMarkerSymbol({ "url":"/images/icons/oem_" + entry + ".png", "height":20, "width":20 })); }); OemLayer.setRenderer(renderer); console.log(OemLayer); map.addLayer(OemLayer); } } else { console.log('oem'); map.removeLayer(OemLayer); //if ($(this).is(":checked")) { $(this).parent().parent().find('input:checked').each(function() { console.log($(this).data('auto')); renderer.addValue($(this).data('auto'), new PictureMarkerSymbol({ "url":"/images/icons/oem_" + $(this).data('auto') + ".png", "height":20, "width":20 })); }); /* renderer.addValue("0", new PictureMarkerSymbol({ "url":"/images/icons/oem_0.png", "height":20, "width":20 })); renderer.addValue("1", new PictureMarkerSymbol({ "url":"/images/icons/oem_1.png", "height":20, "width":20 })); renderer.addValue("2", new PictureMarkerSymbol({ "url":"/images/icons/oem_2.png", "height":20, "width":20 })); renderer.addValue("3", new PictureMarkerSymbol({ "url":"/images/icons/oem_3.png", "height":20, "width":20 })); renderer.addValue("4", new PictureMarkerSymbol({ "url":"/images/icons/oem_4.png", "height":20, "width":20 })); renderer.addValue("5", new PictureMarkerSymbol({ "url":"/images/icons/oem_5.png", "height":20, "width":20 })); renderer.addValue("6", new PictureMarkerSymbol({ "url":"/images/icons/oem_6.png", "height":20, "width":20 })); renderer.addValue("7", new PictureMarkerSymbol({ "url":"/images/icons/oem_7.png", "height":20, "width":20 })); renderer.addValue("8", new PictureMarkerSymbol({ "url":"/images/icons/oem_8.png", "height":20, "width":20 })); renderer.addValue("9", new PictureMarkerSymbol({ "url":"/images/icons/oem_9.png", "height":20, "width":20 })); renderer.addValue("10", new PictureMarkerSymbol({ "url":"/images/icons/oem_10.png", "height":20, "width":20 })); renderer.addValue("11", new PictureMarkerSymbol({ "url":"/images/icons/oem_11.png", "height":20, "width":20 })); renderer.addValue("12", new PictureMarkerSymbol({ "url":"/images/icons/oem_12.png", "height":20, "width":20 })); renderer.addValue("13", new PictureMarkerSymbol({ "url":"/images/icons/oem_13.png", "height":20, "width":20 })); renderer.addValue("14", new PictureMarkerSymbol({ "url":"/images/icons/oem_14.png", "height":20, "width":20 })); */ //renderer.addValue($(this).data('auto'), new PictureMarkerSymbol({ "url":"/images/icons/oem_" + $(this).data('auto') + ".png", "height":20, "width":20 })); OemLayer.setRenderer(renderer); console.log(OemLayer); map.addLayer(OemLayer); //enable oem layer for all and check all sub /*} else { map.removeLayer(OemLayer); }*/ } } else { if (typeof $(this).data('layer') !== 'undefined') { var layer_key = $(this).data('layer'); } else if (typeof $(this).data('layernew') !== 'undefined') { var layer_key = $(this).data('layernew'); } else if (typeof $(this).data('layertwo') !== 'undefined') { var layer_key = $(this).data('layertwo'); } else if (typeof $(this).data('layerthree') !== 'undefined') { var layer_key = $(this).data('layerthree'); } if(layer_key=="overlay") { if ($(this).is(":checked")) { map.addLayer(dynamicMapServiceLayer); $(this).prop('checked', true); } else { map.removeLayer(dynamicMapServiceLayer); $(this).prop('checked', false); } } else { console.log('535 layer click'); console.log('536', $(this)); console.log("537 layer_key = " + layer_key); if ($(this).is(":checked")) { console.log('539 show ' + $(this).data('id')); if (typeof $(this).data('layer') !== 'undefined') { console.log('This should fing be: layer_key ' + layer_key + 'of', layers); console.log('541'); map.addLayer(layers[layer_key]); } else if (typeof $(this).data('layertwo') !== 'undefined') { console.log('544'); map.addLayer(layers2[layer_key]); } else if (typeof $(this).data('layernew') !== 'undefined') { console.log('547'); var layer_key2 = $(this).data('layernew'); var layer_search = $(this).data('id'); map.addLayer(layersNew[layer_key2]); } else if (typeof $(this).data('layerthree') !== 'undefined') { console.log('552'); map.addLayer(layers3[layer_key]); } $(this).siblings('ul').show(); $(this).siblings('ul').find('input').each(function() { console.log($(this)); console.log('561'); $(this).prop('checked', true); if (typeof $(this).data('layer') !== 'undefined') { console.log('564'); console.log('add layer'); var layer_key2 = $(this).data('layer'); map.addLayer(layers[layer_key2]); } else if (typeof $(this).data('layertwo') !== 'undefined') { console.log('569'); console.log('add layer'); var layer_key2 = $(this).data('layertwo'); map.addLayer(layers2[layer_key2]); } else if (typeof $(this).data('layernew') !== 'undefined') { console.log('574'); var layer_key2 = $(this).data('layernew'); map.addLayer(layersNew[layer_key2]); } else if (typeof $(this).data('layerthree') !== 'undefined') { console.log('578'); var layer_key2 = $(this).data('layerthree'); map.addLayer(layers3[layer_key2]); } }); } else { //if 22 console.log('hide ' + $(this).data('id')); if (typeof $(this).data('layer') !== 'undefined') { console.log('595'); if ($(this).data('layer')=="22") { console.log('598'); map.removeLayer(MsaLayer); } map.removeLayer(layers[layer_key]); } else if (typeof $(this).data('layertwo') !== 'undefined') { console.log('604'); map.removeLayer(layers2[layer_key]); } else if (typeof $(this).data('layernew') !== 'undefined') { console.log('607'); map.removeLayer(layersNew[layer_key]); } else if (typeof $(this).data('layerthree') !== 'undefined') { console.log('610'); map.removeLayer(layers3[layer_key]); } //$(this).siblings('ul').hide(); $(this).siblings('ul').find('input').each(function() { console.log($(this)); $(this).prop('checked', false); if (typeof $(this).data('layer') !== 'undefined') { console.log('add layer'); var layer_key2 = $(this).data('layer'); map.removeLayer(layers[layer_key2]); } else if (typeof $(this).data('layertwo') !== 'undefined') { console.log('add layer'); var layer_key2 = $(this).data('layertwo'); map.removeLayer(layers2[layer_key2]); } else if (typeof $(this).data('layernew') !== 'undefined') { var layer_key2 = $(this).data('layernew'); map.removeLayer(layersNew[layer_key2]); } else if (typeof $(this).data('layerthree') !== 'undefined') { var layer_key2 = $(this).data('layerthree'); map.removeLayer(layers3[layer_key2]); } }); } } } } ); $('#image-options button').click( function () { //DidUserChangeMapView = true; HasUserChangedTheDefaultMapView = true; console.log('update map option ' + $(this).data('map')); if ($(this).data('map') == 'usgs') { map.addLayer(USGSMapService); map.reorderLayer("usgsmap",1); } else { map.removeLayer(USGSMapService); map.setBasemap($(this).data('map')); } } ); var kkeys = [], konami = "38,38,40,40,37,39,37,39,66,65"; $(document).keydown(function (e) { kkeys.push(e.keyCode); if (kkeys.toString().indexOf(konami) >= 0) { $(document).unbind('keydown', arguments.callee); map.removeLayer(USGSMapService); map.setBasemap('gray'); } }); function myClickHandler(evt) { console.info('mouse click'); console.info(evt); /* Object {bldg_prop_name: "Springs 278", bldg_county_name: "Calhoun", bldg_city_name: "Piedmont", bldg_tot_sq_ft_num: 506580, bldg_eave_hght_ft_num: 20…}bldg_city_name: "Piedmont"bldg_cm_cnt_num: nullbldg_county_code: "015"bldg_county_name: "Calhoun"bldg_dock_status: "A"bldg_eave_hght_ft_num: 20bldg_exp_bldg_ind: "No"bldg_max_ceil_hght_ft_num: 31bldg_mi_cmcl_air_num: 60bldg_prop_id: 5533bldg_prop_name: "Springs 278"bldg_prop_type: "Industrial"bldg_rail_track_status: "A"bldg_spec_ind: nullbldg_tot_sq_ft_num: 506580bldg_tot_trk_dock_num: 41bldg_total_acre_num: 40__proto__: Object*/ if(evt.graphic) { if(evt.graphic.attributes) { console.log(evt.graphic); console.log(evt.graphic.attributes); /* if(evt.graphic.attributes.Licensed_B=="332") { // hosptial with graphic console.log('Hosp graphic'); $('#YoutubePlayerIframeHolder').html(''); $('#overlay').show(); $('#youtube_player_frame').show(); }*/ // college // hospital // college - 4 year & 2 year if(evt.graphic.attributes.Licensed_B) { // int airport console.log(evt.graphic.attributes.Name); console.log(evt.graphic.attributes.Licensed_B); $("#popupMessage").css({ top: evt.pageY + 5, left: evt.pageX + 5 }).show(); $("#popupMessage").html(''+evt.graphic.attributes.Name+'' +(evt.graphic.attributes.FID=="11" ? ' ' : '') +(evt.graphic.attributes.City_1 ? '
' + evt.graphic.attributes.City_1 : '') +(evt.graphic.attributes.Type ? '
' + evt.graphic.attributes.Type : '') +(evt.graphic.attributes.Licensed_B ? '
Bed Count: ' + evt.graphic.attributes.Licensed_B : '') ); } // college - 4 year & 2 year if(evt.graphic.attributes.MainCampus) { // int airport console.log(evt.graphic.attributes.FULLNAME); console.log(evt.graphic.attributes.MainCampus); $("#popupMessage").css({ top: evt.pageY + 5, left: evt.pageX + 5 }).show(); $("#popupMessage").html(''+evt.graphic.attributes.FULLNAME+''+(evt.graphic.attributes.CITY ? '
' + evt.graphic.attributes.CITY : '')); } // city & msa if(evt.graphic.attributes.Shape_Length) { $("#popupMessage").css({ top: evt.pageY + 5, left: evt.pageX + 5 }).show(); if(evt.graphic.attributes.NAME10) { console.log(evt.graphic.attributes.NAME10); $("#popupMessage").html(''+evt.graphic.attributes.NAME10+''); } else { $("#popupMessage").html(''+evt.graphic.attributes.NAME+''); } } //Research_P if(evt.graphic.attributes.Research_P) { console.log(evt.graphic.attributes.Research_P); var video = null; if(evt.graphic.attributes.FID=='0') { video = 'nII7fUOf20Q'; } if(evt.graphic.attributes.FID=='1') { video = 'xk-tGNjvuAI'; } if(evt.graphic.attributes.FID=='2') { video = 'eUPbvUuWwMo'; } if(evt.graphic.attributes.FID=='3') { video = '4lXGxFOkaKQ'; } $("#popupMessage").css({ top: evt.pageY + 5, left: evt.pageX + 5 }).show(); console.log('video',video); $("#popupMessage").html(''+evt.graphic.attributes.Research_P+'' +(video ? ' ' : '') ); } //Attraction if(evt.graphic.attributes.Attraction) { console.log(evt.graphic.attributes.Attraction); var video = null; if(evt.graphic.attributes.FID=='0') { video = 'APFKwrgZnqE'; } if(evt.graphic.attributes.FID=='1') { video = '8fb6-b6BFsg'; } if(evt.graphic.attributes.FID=='2') { video = 'DbWNrnA-ITU'; } if(evt.graphic.attributes.FID=='3') { video = 'NLxG2Gi9bwk'; } if(evt.graphic.attributes.FID=='4') { video = '8e7Qua_VslU'; } if(evt.graphic.attributes.FID=='5') { video = 'jNON59saulw'; } $("#popupMessage").css({ top: evt.pageY + 5, left: evt.pageX + 5 }).show(); console.log('video',video); $("#popupMessage").html(''+evt.graphic.attributes.Attraction+'' +(video ? ' ' : '') ); } //Golf_trail if(evt.graphic.attributes.Golf_trail) { console.log(evt.graphic.attributes.Golf_trail); var video = null; if(evt.graphic.attributes.FID=='0') { video = 'tBGSaB244hU'; } if(evt.graphic.attributes.FID=='1') { video = '-Sss37Pfz5M'; } if(evt.graphic.attributes.FID=='2') { video = 'lRnIakS17OY'; } if(evt.graphic.attributes.FID=='3') { video = 'WcxM52cueTI'; } if(evt.graphic.attributes.FID=='4') { video = 'GjP47bO66WQ'; } if(evt.graphic.attributes.FID=='5') { video = 'p2o_zPFd1Uo'; } if(evt.graphic.attributes.FID=='6') { video = '998mZdywyC4'; } if(evt.graphic.attributes.FID=='7') { video = 'U84eg-JXWiU'; } if(evt.graphic.attributes.FID=='8') { video = 'cQTCEAqY4Qw'; } if(evt.graphic.attributes.FID=='9') { video = 'P8jmK0R51Z0'; } if(evt.graphic.attributes.FID=='10') { video = 'm-6hOHT6v4Q'; } $("#popupMessage").css({ top: evt.pageY + 5, left: evt.pageX + 5 }).show(); console.log('video',video); $("#popupMessage").html(''+evt.graphic.attributes.Golf_trail+'' +(video ? ' ' : '') ); } if(evt.graphic.attributes.TOT_ENP) { // int airport console.log(evt.graphic.attributes.NAME); console.log(evt.graphic.attributes.TOT_ENP); $("#popupMessage").css({ top: evt.pageY + 5, left: evt.pageX + 5 }).show(); var video = null; if(evt.graphic.attributes.ObjectID=='15') { video = '1C3eGAYZ0iU'; // hsv } if(evt.graphic.attributes.ObjectID=='194') { video = 'wKivtCK5IWg'; // bham } $("#popupMessage").html(''+evt.graphic.attributes.NAME+'' +(video ? ' ' : '') +''+(evt.graphic.attributes.FIELD ? '
' + evt.graphic.attributes.FIELD : '')+''); } if(evt.graphic.attributes.Runway_Length == null) { if(evt.graphic.attributes.FULLNAME) { // comm airport console.log(evt.graphic.attributes.FULLNAME); console.log(evt.graphic.attributes.Runway_Length); var video = null; if(evt.graphic.attributes.OBJECTID=='12') { video = '3wewgzxlfCI'; // nw alabama } if(evt.graphic.attributes.OBJECTID=='11') { video = '4esHFnc9yfE'; // Montgomery Regional Airport Simulation Video } if(evt.graphic.attributes.OBJECTID=='10') { video = 'YfNuDaUHqYo'; // mobile } if(evt.graphic.attributes.OBJECTID=='9') { video = '1C3eGAYZ0iU'; // hsv } if(evt.graphic.attributes.OBJECTID=='8') { video = 'FV2rocJUunM'; // dothan } if(evt.graphic.attributes.OBJECTID=='7') { video = 'wKivtCK5IWg'; // bham } $("#popupMessage").css({ top: evt.pageY + 5, left: evt.pageX + 5 }).show(); $("#popupMessage").html(''+evt.graphic.attributes.FULLNAME+'' +(video ? ' ' : '') +'
' ); } } if(evt.graphic.attributes.bldg_prop_name) { //building var TAttr = evt.graphic.attributes; console.log(evt.graphic.attributes.bldg_prop_name); $("#popupMessage").css({ top: evt.pageY + 5, left: evt.pageX + 5 }).show(); $("#popupMessage").html('' + TAttr.bldg_prop_name + '

' + TAttr.bldg_address_1 + '
' + TAttr.bldg_city_name + ', ' + TAttr.bldg_county_name + ' county

' + TAttr.bldg_tot_sq_ft_num + ' sq ft'); $.ajax({ url: "/image-viewer/building/" + TAttr.bldg_prop_id + "/1", success: function (response) { $('#popupMsgImg').html('' + response + ''); } }); } if(evt.graphic.attributes.site_prop_name) { //site var TAttr = evt.graphic.attributes; console.log(evt.graphic.attributes.site_prop_name); $("#popupMessage").css({ top: evt.pageY + 5, left: evt.pageX + 5 }).show(); $("#popupMessage").html('' + TAttr.site_prop_name + '
' + TAttr.site_city_name + ', ' + TAttr.site_county_name + ' county'); $.ajax({ url: "/image-viewer/site/" + TAttr.site_prop_id + "/1", success: function (response) { $('#popupMsgImg').html(''+response+""); } }); } //site bounds if(evt.graphic.geometry.type=='polygon') { console.log('site bound detected ... do ajax cmd to get info for site ' + evt.graphic.attributes.id); $("#popupMessage").css({ top: evt.pageY + 5, left: evt.pageX + 5 }).show(); $("#popupMessage").html('
loading data...
'); $.ajax({ url: "/db-processor/ajax-popup.aspx?prop_type=site&prop_key=" + evt.graphic.attributes.id, success: function (response) { $('#popupAjaxReturn').html(response); } }); $.ajax({ url: "/image-viewer/site/" + evt.graphic.attributes.id + "/1", success: function (response) { $('#popupMsgImg').html(''+response+""); } }); } // should be OEM if(evt.graphic.attributes.Company) { console.log(evt.graphic.attributes.Company); console.log(evt.graphic.attributes.Video); $("#popupMessage").css({ top: evt.pageY + 5, left: evt.pageX + 5 }).show(); var video = (evt.graphic.attributes.Video ? evt.graphic.attributes.Video.split("/") : [null,null,null,null]); console.log(video[3]); $("#popupMessage").html(''+evt.graphic.attributes.Company+'' +(evt.graphic.attributes.Video ? ' ' : '') +(evt.graphic.attributes.Name ? '
'+evt.graphic.attributes.Name : '') +'
'+evt.graphic.attributes.City+'' +(evt.graphic.attributes.Sector ? '
' + evt.graphic.attributes.Sector : '') ); } if(evt.graphic.attributes.Name=="Port of Mobile Intermodal") { $("#popupMessage").css({ top: evt.pageY + 5, left: evt.pageX + 5 }).show(); $("#popupMessage").html('Port of Mobile Intermodal' +'' ); } // if(evt.graphic.attributes.AIDT_Locat) { $("#popupMessage").css({ top: evt.pageY + 5, left: evt.pageX + 5 }).show(); /// var video = null; if(evt.graphic.attributes.FID=='3') { video='GsYtl6Dg6wo'; // aidt maritime mobile } if(evt.graphic.attributes.FID=='2') { video='IVl8KDspvDE'; // tanner } $("#popupMessage").html(''+evt.graphic.attributes.AIDT_Locat+'' +(video ? ' ' : '') +'
' + evt.graphic.attributes.City + '' ); } if(evt.graphic.attributes.Name && evt.graphic.attributes.Notes) { $("#popupMessage").css({ top: evt.pageY + 5, left: evt.pageX + 5 }).show(); /// var video = null; if(evt.graphic.attributes.FID=='6') { video = 'GNVPXKqnNN8'; // hsv } if(evt.graphic.attributes.FID=='2') { video = '7UlbAZqPShY'; // bham } $("#popupMessage").html(''+evt.graphic.attributes.Name+'' +(video ? ' ' : '') ); } if(evt.graphic.attributes.Company_Name) { //partner OR incubator var TAttr = evt.graphic.attributes; console.log(evt.graphic.attributes.Company_Name); $("#popupMessage").css({ top: evt.pageY + 5, left: evt.pageX + 5 }).show(); if (typeof TAttr.NumEmps != "undefined") { console.log(TAttr.NumEmps); //partner $("#popupMessage").html('' + TAttr.Company_Name + '
' + TAttr.Street_Address+', ' + TAttr.City_1 + '
Staff: ' + TAttr.NumEmps); $.ajax({ url: "/image-viewer/partners/" + TAttr.ObjectID + "/1", success: function (response) { $('#popupMsgImg').html(''+response+""); } }); } else { //incubator $("#popupMessage").html('' + TAttr.Company_Name + '
'+TAttr.Street_Address+', ' + TAttr.Nearest_Incorporated_City + '
'+ (TAttr.Number_of_Staff != null ? 'Staff: ' + TAttr.Number_of_Staff : '')); $.ajax({ url: "/image-viewer/incubators/" + TAttr.ObjectID + "/1", success: function (response) { $('#popupMsgImg').html(''+response+""); } }); } } } } else { $("#popupMessage").hide(); } } $("input[type='text'], input[type='password']").focus(function(){ console.log('focusin', $(this)); map.disableKeyboardNavigation(); }); $("input[type='text'], input[type='password']").blur(function(){ console.log('focusout', $(this)); map.enableKeyboardNavigation(); }); //d }); // dont worry about that error function zoomToDefault() { require([ "esri/geometry/Point", "esri/geometry/webMercatorUtils" ], function (Point, webMercatorUtils) { var point = new Point(-86.694, 33.06, { wkid: "32616" }); var wmpoint = webMercatorUtils.geographicToWebMercator(point); setTimeout(function() { map.centerAndZoom(wmpoint, 7); }, 1000); }); } function zoomTo(lat, lon) { require([ "esri/geometry/Point", "esri/geometry/webMercatorUtils" ], function (Point, webMercatorUtils) { var point = new Point(lon, lat, { wkid: "32616" }); $("#popupMessage").hide(); map.setZoom(11); var wmpoint = webMercatorUtils.geographicToWebMercator(point); setTimeout(function() { //map.setZoom(15); map.centerAt(wmpoint); map.centerAndZoom(wmpoint, 16); }, 1000); }); } function SimplezoomTo(lat, lon) { require([ "esri/geometry/Point", "esri/geometry/webMercatorUtils" ], function (Point, webMercatorUtils) { var point = new Point(lon, lat, { wkid: "32616" }); $("#popupMessage").hide(); //map.setZoom(6); var wmpoint = webMercatorUtils.geographicToWebMercator(point); //setTimeout(function() { //map.setZoom(15); map.centerAt(wmpoint); map.centerAndZoom(wmpoint, 10); //}, 1000); }); }