POST
|
I have some client side graphics and each graphic has different kinds of fields (attributes). Is there a way to create a heat map based on these graphics? I know I can probably use feature collection object and create a feature layer based on the feature collection, but what if in my graphics, they have different fields (attributes)? Is it still possible to create a feature collection for these graphics? Is there any examples? Thanks!
... View more
02-07-2017
08:42 PM
|
0
|
1
|
1293
|
POST
|
I fixed it by cloning the original graphics. Here is my code: view.on("click", function(e){
// console.log(graphicCollection);
view.hitTest(e.screenPoint).then(function(response){
response.results.forEach(function(g){
var graphic = g.graphic;
// console.log(graphic);
if (graphic) {
var newGraphics = view.graphics.clone();
view.graphics.removeAll();
newGraphics.forEach(function(g){
g.symbol.symbolLayers.items[0].material.color.a = 0.3;
});
var gpcIndex = newGraphics.findIndex(function(item){
return item.id === graphic.id;
});
newGraphics.getItemAt(gpcIndex).symbol.symbolLayers.items[0].material.color.a = 1;
view.graphics = newGraphics;
};
});
});
});
Here I'm changing the opacity of the graphics, I fade all the unselected graphics. The "zoom to" function of the popup works fine with the above code.
... View more
07-06-2016
06:30 PM
|
1
|
0
|
2016
|
POST
|
I tried using view.graphics.add(graphic) to add the graphics onto the view directly instead of adding the graphic onto a GraphicsLayer and then adding the layer onto the map. It still gives me the above error.
... View more
07-06-2016
05:44 PM
|
0
|
0
|
2016
|
POST
|
thanks for the reply. This works pretty well. However, this raises another problem. after adding the new graphic on the layer, when I click on the "zoom to" on the popup of the graphic, there is an error 'Object {name: "internal:graphic-not-part-of-view", message: "Graphic is not part of this view", details: undefined}' do you have any idea?
... View more
07-06-2016
05:40 PM
|
0
|
0
|
2016
|
POST
|
I'm using SceneView btw. But I tried with the sample code here: ArcGIS API for JavaScript Sandbox I used this sample code to do the query, it gave me the same error "name: "QueryEngine", message: "Unsupported query", details: undefined" and after this error, there was another error "bundle.js:2559 Uncaught TypeError: Cannot read property 'domain' of undefined", I'm not sure if this is relavant.
... View more
07-05-2016
10:26 AM
|
0
|
1
|
3710
|
POST
|
Robert, I saw that and tried it, but it still gave me the error "Object {name: "QueryEngine", message: "Unsupported query", details: undefined}". I'm not sure where I did wrong. Here's part I used to do the query: view.then(function(){ console.log(lyr); view.on("click", function(e){ console.log(e.mapPoint); var queryParams = lyr.createQueryParameters(); queryParams.geometry = e.mapPoint; queryParams.spatialRelationship = "intersects"; lyr.queryFeatures(queryParams).then(function(results){ console.log(results.features); }); }); });
... View more
07-05-2016
09:58 AM
|
0
|
0
|
3710
|
POST
|
The sample code here: Create a FeatureLayer with client side graphics | ArcGIS API for JavaScript 4.0 shows how to create a featurelayer with client side geojson data. It works fine if I click somewhere on the map that does not have any feature. It will not do anything, which is reasonable. However, if I change MapView into SceneView in this sample (sample code attached, you can copy and paste into the sandbox), when I click somewhere on the globe that does not have any feature, the console will show me an error, and it has an message "Unsupported query" (see image below) I'm wondering how to fix it. Also, if you look closely on the SceneView globe, you will notice that each feature (point circle) has a white dot in the center (see image below) I fixed this by adding "elevationInfo: { mode: "on-the-ground"}" in the FeatureLayer. This code can be found in the attachment "sampleCodeWelevationinfo.txt". But the problem is, after adding it, the popup does not work any more and wherever you click on the globe, it will show the same error as in the first image. Do you know how to fix these problems? thanks! btw, in this sample code: ArcGIS API for JavaScript Sandbox , change "onTheGround" to "on-the-ground", it has no problem for the popup and if you click somewhere on the globe that does not have any feature, it will tell you no feature is found. The only different between this one and the problem one is that in this one the FeatureLayer reference a service URL while the problem one uses an array of client-side graphics. I would like to use my own data, how to fix it?
... View more
06-22-2016
03:00 PM
|
0
|
1
|
3468
|
Title | Kudos | Posted |
---|---|---|
1 | 07-06-2016 06:30 PM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|