Hi,
I am trying to query the block service https://tigerweb.geo.census.gov/arcgis/rest/services/TIGERweb/Tracts_Blocks/MapServer/2 to get block information based on the input criteria - latitude and longitude. I am getting below error
"Unable to load proxy.ashx?https://tigerweb.geo.census.gov/arcgis/rest/services/TIGERweb/Tracts_Blocks/MapServer/2?f=json status: 500"
if anybody has resolved this issue, please let me know.
Thanks
Chitra
Solved! Go to Solution.
It works!!!!! that is cool!!!! Thank you very much Robert.
I will try to figure out the color intensity part. If not, will come back for ideas.
Thank you
Chitra
Hi Robert,
The outline color is not setting to black in below code. We are using js.arcgis.com/3.14. Do I have to do anything different for this version?
gra.setSymbol(
new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,
new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([0, 0, 0]), 2),
color
)
);
Thanks
Chitra
Thanks
Chitra
@ChitraKrishnan 3.14 does not have the clone method on the Graphic class so you have to make some code changes:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
<title>Census Blocks</title>
<link rel="stylesheet" href="https://js.arcgis.com/3.14/dijit/themes/tundra/tundra.css">
<link rel="stylesheet" href="https://js.arcgis.com/3.14/esri/css/esri.css">
<style>
html,
body,
#mapDiv {
padding: 0;
margin: 0;
height: 100%;
}
</style>
<script src="https://js.arcgis.com/3.14/"></script>
<script>
var map, GL, pntsArr;
require([
"esri/map", "esri/tasks/QueryTask", "esri/SpatialReference",
"esri/tasks/query", "esri/geometry/Point", "esri/dijit/PopupTemplate",
"esri/layers/GraphicsLayer", "esri/graphic",
"esri/symbols/SimpleLineSymbol", "esri/symbols/SimpleFillSymbol", "esri/renderers/SimpleRenderer",
"esri/Color", "dojo/domReady!"
], function (
Map, QueryTask, SpatialReference,
Query, Point, PopupTemplate,
GraphicsLayer, Graphic,
SimpleLineSymbol, SimpleFillSymbol, SimpleRenderer,
Color
) {
map = new Map("mapDiv", {
basemap: "streets",
center: [-83.0014423, 39.9593239],
zoom: 14,
slider: false
});
var popupTemplate = new PopupTemplate({
title: "{NAME}",
fieldInfos: [{
fieldName: "BLOCK",
visible: true,
label: "Block: "
},
{
fieldName: "CENTLAT",
visible: true,
label: "Latitude: "
},
{
fieldName: "CENTLON",
visible: true,
label: "Longitude: "
}
]
});
GL = new GraphicsLayer({id: 'mygl', infoTemplate: popupTemplate});
map.addLayer(GL);
var arrayFromDatabase = [[-83.0014423,39.9593239],[-83.0006330,39.9597960],[-83.0019028,39.9617077]];
queryBlocks(arrayFromDatabase);
function queryBlocks(dbArr) {
var q = new Query();
q.outSpatialReference = new SpatialReference(102100);
q.returnGeometry = true;
q.outFields = ["*"];
var qt = new QueryTask("https://tigerweb.geo.census.gov/arcgis/rest/services/TIGERweb/Tracts_Blocks/MapServer/2");
dbArr.map(function (pntData){
var pnt = new Point(pntData);
q.geometry = pnt;
qt.execute(q, function (result) {
result.features.map(function (f) {
var randomColor = '#' + Math.floor(Math.random() * 16777215).toString(16);
var color = new Color(randomColor);
color.a = 0.5;
var gra = new Graphic(f.toJson());
// console.info(gra.attributes);
gra.setSymbol(
new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,
new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([0,0,0]), 2),
color
)
);
GL.add(gra);
});
});
});
}
});
</script>
</head>
<body>
<div id="mapDiv"></div>
</body>
</html>