Both FC are Web Mercator Aux Sphere
The Map is defined as follows ---- I think this defaults to Web Mercator Web Aux?
var mapright = new Map({
basemap: "dark-gray",
layers: [resultsLayer3, resultsLayer2, countyLayerWebMercator]
});
var viewright = new MapView({
container: "viewDivright",
map: mapright,
center: [-77.05, 37.53308],
zoom: 7
});
PART ONE query, get geometry create Graphic
function queryMultipartPolyongUniqueID3(feature) {
var str = feature;
var query = "";
query = MultiPartPolygonsLayer.createQuery();
query.where = "ADDRESSgeo = '" + str + "'";
return MultiPartPolygonsLayer.queryFeatures(query);
}
// DISPLAY RESULTS IN GRAPHICS LAYER
function displayResultsUniqueID(results) {
resultsLayer2.removeAll();
var features2 = results.features.map(function (graphic) {
graphic.symbol = {
type: "simple-fill",
style: "solid",
color: [240, 248, 255, 0.9],
size: "10px", // pixels
outline: {
// autocasts as new SimpleLineSymbol()
color: [240, 248, 255, 0.9],
width: 1 // points
}
};
return graphic;
});
var numCounties2 = features2.length;
resultsLayer2.addMany(features2);
// CALL THE SECOND FUNCTION
queryCountiesthatIntersect().then(displayResults2);
}
THEN Call the second function at the end ----
// CALL THE SECOND FUNCTION
queryCountiesthatIntersect().then(displayResults2);
1. If I comment out the call to this 2nd function that code runs without error.
2. If I run it with the call to the second function I get the below error.
ERROR
dojo.js:218 [esri.core.Accessor] Accessor#set Invalid property value, value needs to be one of 'esri.geometry.Extent', 'esri.geometry.Multipoint', 'esri.geometry.Point', 'esri.geometry.Polyline', 'esri.geometry.Polygon', or a plain object that can autocast (having .type = 'extent', 'multipoint', 'point', 'polyline', 'polygon')
QUESTIONS:
Am I getting this error because I am trying to use a Graphic Layer from the First Function Above?????
Can I use graphic Layer? If so do I need to define it differently?
Do I need to use a Feature Layer?
function queryCountiesthatIntersect() {
var query = countyLayerWebMercator.createQuery();
query.geometry = resultsLayer2;
query.spatialRelationship = "intersects";
return countyLayerWebMercator.queryFeatures(query);
}
function displayResults2(results) {
resultsLayer3.removeAll();
var features3 = results.features.map(function (graphic) {
graphic.symbol = {
type: "simple-fill",
style: "solid",
color: [240, 248, 255, 0.9],
size: "10px", // pixels
outline: {
// autocasts as new SimpleLineSymbol()
color: [191, 42, 18, 0.9],
width: 1 // points
}
};
return graphic;
});
var numCounties = features3.length;
resultsLayer3.addMany(features3);
}
Solved! Go to Solution.
I got it with this: i was missing the "items"
query.geometry = resultsLayer2.graphics.items[0].geometry;
NOT
query.geometry = resultsLayer2.graphics[0].geometry;
I had to walk the console.log of the Graphics layer a bit more
Funny thing is I get this error but the 2nd function still displays data but for some reason ALL of the County data....not the ones that are intersecting the Graphic Layer. So I am assuming I might have to define the Geometry of the Graphic Layer?
Jay,
The queries geometry property has to be a single geometry. You are currently attempting to pass a GraphicsLayer with possibly multiple graphics.
query.geometry = resultsLayer2.geometry[0]; ????
query.geometry = resultsLayer2.graphics[0].geometry;
Tried this and don't get to the second alert
function queryCountiesthatIntersect() {
alert("1");
var query = countyLayerWebMercator.createQuery();
query.geometry = resultsLayer2.graphics[0].geometry;
query.spatialRelationship = "intersects";
alert("2");
return countyLayerWebMercator.queryFeatures(query);
}
I changed the Graphic build to this as well
resultsLayer2.add(features2);
NOT
resultsLayer2.addMany(features2);
Jay,
addmany would look like this. it is expecting an array.
resultsLayer2.addMany([features2]);
This works fine and I get the 1st function to render the graphic layer properly
resultsLayer2.addMany(features2);
This does NOT work...the graphic layer in the first function does not draw.
resultsLayer2.addMany([features2]);
Still think there is an issue with this...when trying to use the geometry to find the counties that intersect the Graphic Layer
written like this I get nothing
query.geometry = resultsLayer2.graphics[0].geometry;
written like this I get all 133 counties
query.geometry = resultsLayer2;
I was using this ESRI Example: ArcGIS API for JavaScript Sandbox
towards the bottom
function displayResults(results) {
resultsLayer.removeAll();
var features = results.features.map(function(graphic) {
graphic.symbol = {
type: "simple-marker", // autocasts as new SimpleMarkerSymbol()
style: "diamond",
size: 6.5,
color: "darkorange"
};
return graphic;
});
var numQuakes = features.length;
document.getElementById("results").innerHTML =
numQuakes + " earthquakes found";
resultsLayer.addMany(features);
}