Hi Robert,
Thanks for the response.
It worked after I added a self-signed ssl to my local web server. I left the proxy.config file unchanged. I am not sure how it bypassed the proxy.ashx file.
I am trying to query https://tigerweb.geo.census.gov/arcgis/rest/services/TIGERweb/Tracts_Blocks/MapServer/2 using esri/request to get block info(and highlight that block with a color) whenever a particular latitude or longitude is passed as input. The return response looks very generic and does not include that particular block info. I tried below 2 sets of code.
Could you please let me know what is incorrect in below code and appreciate if you could guide me with a sample code on how to query the url and render with colors.
Set1
queryBlocks: function (e) {
var pad = this.extent.getWidth() / this.width * 3;
var queryGeom = new Extent(e.mapPoint.x - pad, e.mapPoint.y - pad, e.mapPoint.x + pad, e.mapPoint.y + pad, this.spatialReference);
var q = new query();
q.outSpatialReference = { "wkid": 102100 };
q.returnGeometry = true;
q.outFields = ["BLOCK", "CENTLAT", "CENTLON"];
q.geometry = queryGeom;
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: " }
]
});
var qt = new QueryTask("https://tigerweb.geo.census.gov/arcgis/rest/services/TIGERweb/Tracts_Blocks/MapServer/2");
var def = qt.execute(q);
def.addCallback(function (result) {
return dojo.map(result.features, function (f) {
f.setInfoTemplate(popupTemplate);
return f;
});
});
this.infoWindow.setFeatures([def]);
this.infoWindow.show(e.screenPoint, this.getInfoWindowAnchor(e.screenPoint));
// queryFeatureLayer
const layerUrl = "https://tigerweb.geo.census.gov/arcgis/rest/services/TIGERweb/Tracts_Blocks/MapServer/2";
var layersRequest = esriRequest({
url: layerUrl,
content: {
f: "json",
where: "CENTLAT = +39.9570572", // Set by select element
spatialRelationship: "intersects", // Relationship operation to apply
geometry: this.extent, // Restricted to visible extent of the map
outFields: ["*"], // Attributes to return
returnGeometry: false
},
handleAs: "json",
// callbackParamName: "callback"
});
layersRequest.then(
function (response) {
console.log("Success: ", response.layers);
}, function (error) {
console.log("Error: ", error.message);
});
}
Set 2:
queryBlocks: function (e) {
var pad = this.extent.getWidth() / this.width * 3;
var queryGeom = new Extent(e.mapPoint.x - pad, e.mapPoint.y - pad, e.mapPoint.x + pad, e.mapPoint.y + pad, this.spatialReference);
var q = new query();
q.outSpatialReference = { "wkid": 102100 };
q.returnGeometry = true;
q.outFields = ["BLOCK", "CENTLAT", "CENTLON"];
q.geometry = queryGeom;
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: " }
]
});
var qt = new QueryTask("https://tigerweb.geo.census.gov/arcgis/rest/services/TIGERweb/Tracts_Blocks/MapServer/2");
var def = qt.execute(q);
def.addCallback(function (result) {
return dojo.map(result.features, function (f) {
f.setInfoTemplate(popupTemplate);
return f;
});
});
this.infoWindow.setFeatures([def]);
this.infoWindow.show(e.screenPoint, this.getInfoWindowAnchor(e.screenPoint));
// queryFeatureLayer
const parcelLayer = new FeatureLayer("https://tigerweb.geo.census.gov/arcgis/rest/services/TIGERweb/Tracts_Blocks/MapServer/2");
const parcelQuery = {
where: "CENTLAT = +39.9570572", // Set by select element
outSpatialReference: { "wkid": 102100 },
spatialRelationship: "intersects", // Relationship operation to apply
geometry: this.extent, // Restricted to visible extent of the map
outFields: ["BLOCK"], // Attributes to return
returnGeometry: true
};
parcelLayer.queryFeatures(parcelQuery)
.then(function (results) {
console.log("Feature count: " + results.features.length)
})
.otherwise(function (error) {
console.log("Error: " + error.error);
});
},
Thanks
Chitra