|
POST
|
You could use a PictureMarkerSymbol and pass the path to your image as the URL for the symbol, for example: var pictureMarkerSymbol = new PictureMarkerSymbol('/images/my-image.jpg', 25,25); (The last two parameters are width and height in pixels, don't pass in anything to use the default pixels of the image). You'd then decide where you want to place the symbol, probably you'd make a point geometry at that location, and then create a new graphic with the symbol and geometry and add it to your map or a layer on your map. This method requires you to host the image if you want other people to be able to view your app. Alternatively, you could upload the image to some hosting site and pass the URL to the image instead of the path to the file. This will be a "dumb" image. If you want to do something special with the image, you could try to play around with using an image service to host the image. I'm not knowledgeable about how this stuff works, but the 3.XX API has a widget to help with oblique image viewing: ObliqueViewer | API Reference | ArcGIS API for JavaScript 3.20. The key there is that the image must be published as a mosiac dataset and presumably there has to be some frame of reference for translating between image coordinates and map coordinates. This would all require software other than the JS API to set up.
... View more
05-23-2017
08:08 AM
|
1
|
4
|
3979
|
|
POST
|
Setting the 'visible' property on a graphic works in 3D, so my feeling is that it should work in 2D also, but it doesn't right now. example: JS Bin - Collaborative JavaScript Debugging edit: I can confirm that this is a known issue. It doesn't look like it will be fixed by 4.4 though.
... View more
05-19-2017
11:52 AM
|
0
|
1
|
3383
|
|
POST
|
Siren's song? No my friend, this is no siren's song. Behold the future of GIS: JS Bin - Collaborative JavaScript Debugging
... View more
05-19-2017
10:22 AM
|
0
|
2
|
3060
|
|
POST
|
I think technically it's possible. I've seen some references to people doing this here and there, but I don't imagine it's "supported" and I would guess you'd have to have a fairly deep understanding of the dojo loader/various things peripheral to the API in order to get it working. I'm unsure if people doing this are loading each version separately and keeping them isolated from each other, or if there's a way to use one dojo loader to load modules from both APIs.
... View more
05-19-2017
06:09 AM
|
0
|
0
|
693
|
|
POST
|
Brief background: a feature service/feature server can have an arbitrary number of layers or tables. Each layer/table has an index. You could query a layer/table on a feature service with a URL like this: https://<domain>.esri.com/arcgis/rest/services/<feature service name>/FeatureServer/<layer/table idx>/query REST API ref: ArcGIS REST API Here's an example of how to do this via esriRequest: esriRequest('<feature layer/table url>/query',{
query: {
where:"1=1", // sql clause, 1=1 means every feature
outFields:'*', // attribute fields to return
token: <user token>, // token
f:"json" // format
},
}).then(function(r){
if (r.features){
console.log(r.features);
} else {
console.log('No Features Returned.');
}
}); Here's an example of how you might use applyEdits: https://<domain>.esri.com/arcgis/rest/services/<feature service name>/FeatureServer/<layer/table idx>/applyEdits REST API ref: ArcGIS REST API esriRequest('<feature layer/table url>/applyEdits',{
query: {
method: 'post', // POST request
adds: [ // this is an array of JSON from a graphic:
// you can get it using graphic.toJSON()
// or construct the JSON manually
// if the 'layer' is a table, do not specify
// a geometry
{
geometry: {"x" : -118.15, "y" : 33.80},
attributes: {
OWNER: "Joe Smith",
VALUE: 94820.37,
APPROVED: true,
LASTUPDATE: 1227663551096
}
},
{
... // feature to add #2
}
],
updates: [
{
... // same as adds, except you must include an
// object id, which is the unique id for this feature
// the object id field can be anything, but it's usually
// objectId or OBJECTID, you can check on the layer
}
],
deletes: <object1, objectid2, ...>, // deletes just needs a comma-delimited
// list of object ids
token: <user token>, // token
f:"json" // format
},
}).then(function(r){
console.log(r);
}); Technically you should also be able to fetch all layers/table on a feature server using /query on the root feature server URL (see: ArcGIS REST API ). But I've never been able to get that to work.
... View more
05-18-2017
08:23 AM
|
0
|
0
|
1061
|
|
POST
|
Like Robert posted, it really depends on the specifics of what you want to do. Do you want to add a point to an existing map and persist that point? You need to have backend infrastructure set up to do this. Do you want to visually add a point to a map in the client? You can do this without making a request, but it won't be persisted anywhere. Do you want to highlight a point that already exists? You can visually highlight a point in the client, or you could edit the point on the backend to represent it being highlighted, so anyone who pulls in that map can see what is highlighted. Since you're new to the API, I'd take a look at esri/Graphic. Things that are added to the map in the JS API are called graphics. Graphics consist of attributes (key-value pairs, must be strings/numbers), geometries (the shape of the graphic: polygon, line, point, multipoint, extent (bounding box), or circle), and a symbol (how the geometry is symbolized on the map, the color, fill, etc). Graphics can be added to a map in the client, without communicating to any service, but often they are added to a map in response to data that is from some other service, whether an Esri service or a list of lng/lats from any server. Here's a simple example from the 4.XX SDK that adds three graphics with different types of geometry to a 2D map: ArcGIS API for JavaScript Sandbox
... View more
05-18-2017
06:54 AM
|
0
|
0
|
728
|
|
POST
|
Are you using featureLayer.applyEdits from the JavaScript API? You should be able to use the REST API to do anything that you've done before, you may just have to manually make the requests, ie use esri/Request to make an applyEdits request directly to ArcGIS REST API. The underlying REST API hasn't changed, just the JavaScript interface. I'm not totally clear on the distinction between feature classes and tables in the DB, but as long as a table is part of a feature service, you should be able to edit it using the REST API.
... View more
05-18-2017
06:31 AM
|
0
|
0
|
1061
|
|
POST
|
arrayUtils is a dojo utility that contains some array methods. The standard library in all browsers has most (all?) of these functions at this point, so could change arrayUtils.forEach(featureCollection.layers, function (layer) { ... })
to
featureCollection.layers.forEach(function(layer){...})
... View more
05-18-2017
05:56 AM
|
0
|
1
|
1103
|
|
POST
|
Try Collection.flatten: Collection | API Reference | ArcGIS API for JavaScript 4.3 There's a sample there that looks like it may be just what you're looking for.
... View more
05-16-2017
12:05 PM
|
3
|
0
|
5179
|
|
POST
|
It seems to me that importScripts is the right way to handle this. JavaScript doesn't allow you to share between threads currently. I would imagine that there are limitations to what can be imported, and it may be difficult to import the entire JS API for various reasons. For instance the worker's global scope is different from the normal JavaScript global scope, and the JS API probably relies on the normal global scope in some places. It may be possible to build the modules you need into a single file (Extent, Polygon, and all dependencies) and pull this in via importScripts, assuming there's no issues with those modules running in the worker's scope. I don't know much about the details here though.
... View more
05-16-2017
06:11 AM
|
0
|
0
|
2784
|
|
POST
|
Here's a jsbin showing how to tap into the event: JS Bin - Collaborative JavaScript Debugging
... View more
05-16-2017
05:48 AM
|
0
|
1
|
1270
|
|
POST
|
Just curious, but what response do requests get right now when they don't get past the proxy? It seems to me that if the proxy is not passing through some requests to ArcGIS server, then the proxy is also responsible for responding with the appropriate code. Or maybe I'm misunderstanding how this is set up. I don't know anything about resource-proxy, but you could make an issue on github asking this question. The repo looks reasonably active so I'd imagine someone there can help you out.
... View more
05-15-2017
12:24 PM
|
0
|
1
|
1992
|
|
POST
|
The issue is that all the requests (inside the while loop) are fired off simultaneously (or within a few milliseconds of each other). So every request is sent before a single response is received. Ken's solution is correct in my opinion. It's generally preferable to send all the requests you need and in the callback function look for a certain condition to be met. This will result in a better user experience (faster) and will waste less time. If you don't want to do things this way (although I think it's the right choice), you have two main alternatives. One option is to execute the requests one at a time, end to end. So you'll send a query for the first feature in the array, then wait for the result, check the result, if you haven't found what you're looking for then you can send the query for the next item. Here's an example of how you might do this: var TheAdr; // string
var features = [...] // array of features
doQueryRecursive(features, 0, TheAdr);
// takes the list of features, the index, and the address
function doQueryRecursive(features, idx, TheAdr){
var feature = features[idx]; // set the feature
idTroncon=feature.attributes[FLayer2.objectIdField];
alert("idTroncon "+idTroncon);
// construct the query
var queryAdr = new Query();
queryAdr.where = "Text_ = '"+TheAdr+"' AND ID_TRONCON ="+idTroncon;
queryAdr.outSpatialReference = {wkid:102100};
queryAdr.returnGeometry = true;
queryAdr.outFields = ["objectid"];
// submit query
queryTaskAdr.execute(queryAdr, function(fset) {
alert(' EXECUTING'); // you labeled this executing, but this function
// is actually called when the query is finished.
if (fset.features.length === 1) { // check for point, if point is found
// do what needs to be done
var objectidOfAdr=fset.features[0].attributes['objectid'];
var geoAdr=fset.features[0].geometry;
var FLayer1 = map.getLayer("adresse");
FLayer1.setSelectionSymbol(marker);
var selectionQuery1 = new Query();
selectionQuery1.where = "objectid ="+objectidOfAdr;
FLayer1.selectFeatures(selectionQuery1,esri.layers.FeatureLayer.SELECTION_NEW);
ExtentAdr=new Extent(geoAdr.x, geoAdr.y, (geoAdr.x)+50, (geoAdr.y)+50, geoAdr.spatialReference);
FLayer1.on("selection-complete", zoomToAdr);
} else { // if point is not found...
if (features[idx + 1]){ // check if there is another feature
doQueryRecursive(features, idx + 1, TheAdr); // if there is another feature
// submit a query for the next feature
} else {
// if there is no other feature, then give feedback
alert("No matches found");
}
}
}.bind(this));
} Another approach would be to send all requests at the same time (like you're doing now) and then take a look at all the responses once every requests has returned. You can do this with Promise.all: var TheAdr; // string
var features = [...] // array of features
var promises = mapToPromises(features, TheAdr);
// wait for all requests to be fulfilled, then check the responses
Promise.all(promises).then(function(results){
var foundResult = false;
for (var i=0; i<results.length; i++){
if (results[i].features.length === 1) {
var objectidOfAdr=fset.features[0].attributes['objectid'];
var geoAdr=fset.features[0].geometry;
var FLayer1 = map.getLayer("adresse");
FLayer1.setSelectionSymbol(marker);
var selectionQuery1 = new Query();
selectionQuery1.where = "objectid ="+objectidOfAdr;
FLayer1.selectFeatures(selectionQuery1,esri.layers.FeatureLayer.SELECTION_NEW);
ExtentAdr=new Extent(geoAdr.x, geoAdr.y, (geoAdr.x)+50, (geoAdr.y)+50, geoAdr.spatialReference);
FLayer1.on("selection-complete", zoomToAdr);
foundResult = true;
break;
}
}
if (!foundResult){
alert("Didn't find any results");
}
});
// takes the list of features and the address, returns an
// array of promises
function mapToPromises(features, TheAdr){
return features.map(feature, function(){
// construct the query
var queryAdr = new Query();
queryAdr.where = "Text_ = '"+TheAdr+"' AND ID_TRONCON ="+idTroncon;
queryAdr.outSpatialReference = {wkid:102100};
queryAdr.returnGeometry = true;
queryAdr.outFields = ["objectid"];
// submit the query, retuen the promise;
return queryTaskAdr.execute(queryAdr);
});
} My advice would be to use Ken's approach though.
... View more
05-15-2017
11:53 AM
|
2
|
1
|
2710
|
|
POST
|
When I print to the console in firefox I get something like this: I can then click on the Object link at the starting of the line to open the panel on the right that lists all the properties on that object. Does this not work for you? Also, consider trying console.dir(featureLayer).
... View more
05-15-2017
06:22 AM
|
1
|
0
|
2165
|
|
POST
|
Based on your code you've created a new polyline geometry, but you aren't doing the necessary things to add it to the map. You need to create a Graphic (esri/Graphic), which requires a geometry (which you have), and a symbol (probably a esri/symbols/SimpleLineSymbol). Once you've created the graphic, you can add it with this.mapView.graphics.add(graphic);
... View more
05-15-2017
05:47 AM
|
2
|
0
|
889
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 05-03-2017 08:23 AM | |
| 1 | 11-02-2017 08:36 AM | |
| 1 | 11-02-2017 09:23 AM | |
| 1 | 09-20-2017 02:07 PM | |
| 1 | 10-06-2017 05:54 AM |
| Online Status |
Offline
|
| Date Last Visited |
11-11-2020
02:24 AM
|