|
POST
|
I have another project that has a series of queryTasks to populate datagrids that also needs to be changed. This example should work just fine for that as well. Thanks for your assistance.
... View more
10-03-2013
11:12 AM
|
0
|
0
|
1916
|
|
POST
|
That turned out to be operator error. I had changed around the location of one of my services yesterday to be in the subfolder where it belonged. Since the layer wasn't really valid, then onLayersAddResult never fired. I thought I'd changed all the places I used the layer, but I missed one. I'm developing my own mental list of Murphy's Laws. If you are 100% certain you've identified the line of code where your problem lies, there is a 100% certainty your problem lies elsewhere.
... View more
10-03-2013
11:09 AM
|
0
|
0
|
2392
|
|
POST
|
Because the output from all(IdentifyTaskList).then(showIdentifyResults) isn't the same as my deferredList was, I had to deal with the results slightly differently. This is the new showResults function:
function showIdentifyResults(idResults) {
generateInfoTemplate = new InfoTemplate();
generateInfoTemplate.setContent(generateWindowContent);
results = arrayUtils.map(idResults, function(r) {
var result = r[0];
var feature = result.feature;
var layerName = result.layerName;
generateInfoTemplate.setTitle("Layer Information");
feature.attributes.layerName = result.layerName;
feature.setInfoTemplate(generateInfoTemplate);
return feature;
});
if(results.length === 0) {
app.map.infoWindow.clearFeatures();
} else {
app.map.infoWindow.setFeatures(results);
}
app.map.infoWindow.show(idPoint);
// return results;
}
... View more
10-03-2013
09:16 AM
|
0
|
0
|
1916
|
|
POST
|
I'm having an issue today with something similar, but my code is slightly older, 3.4. I have made no changes at all to this code for over a week and it was working as of yesterday. I have a dojo.connect on the map for onLayersAddResult, which is used to create the toc.
map.addLayers([eezLayer, eezFeatureLayer]);
dojo.connect(map, 'onLayersAddResult', function(results) {
var toc = new agsjs.dijit.TOC({
map: map,
layerInfos: [{
layer: eezLayer,
title: "Enhanced Enterprise Zones",
slider:true
},{
layer: districtLayer,
title: "Legislative Districts"
}]
}, 'tocDiv');
toc.startup();
});
This never executes because it never detects the onLayersAddResult event has fired. I'm completely baffled. This code has been in test for a month and today it suddenly decided not to work?! The layers do get added, but I have no TOC because of this.
... View more
10-03-2013
08:15 AM
|
0
|
0
|
2392
|
|
POST
|
I felt like I had several lines too many in that function, but it was a posting from another thread and jsFiddle, not my own. Since it was functional, I just left it alone. (Until now when I needed it changed!) Since there's quite a bit that happens in my showResults function, I think I'll leave it separate for now. That function isn't quite right yet, but I do see I have results returned. I'm on much more comfortable ground there, so hopefully I'll get it all straightened out soon.
... View more
10-03-2013
06:01 AM
|
0
|
0
|
1916
|
|
POST
|
I found this site useful, maybe something in this list will help: http://www.sitepen.com/blog/2012/10/31/debugging-dojo-common-error-messages/
... View more
10-02-2013
01:37 PM
|
0
|
0
|
1008
|
|
POST
|
I have been using this function on a map click event to run multiple identify tasks using deferred and deferredList. I'm now hoping to get this rewritten to use dojo/promise/all. I'm getting lost on what should be changed in this code. Here is the original, and it works. function runIdentifies(evt) { idPoint = evt.mapPoint; var layers = dojo.map(map.layerIds, function(layerId) { return map.getLayer(layerId); }); //Create an array of all layers in the map layers = dojo.filter(layers, function(layer) { if (layer.visibleLayers[0] !== -1){ return layer.getImageUrl && layer.visible } }); //Only dynamic layers have the getImageUrl function. Filter so you only query visible dynamic layers var tasks = dojo.map(layers, function(layer) { return new esri.tasks.IdentifyTask(layer.url); }); //map each visible dynamic layer to a new identify task, using the layer url var defTasks = dojo.map(tasks, function (task) { return new dojo.Deferred(); }); //map each identify task to a new dojo.Deferred var params = createIdentifyParams(layers,evt); var dlTasks = new dojo.DeferredList(defTasks); //And use all of these Deferreds in a DeferredList dlTasks.then(showIdentifyResults); //chain showIdentifyResults onto your DeferredList for (i=0;i<tasks.length;i++) { //Use 'for' instead of 'for...in' so you can sync tasks with defTasks try { tasks.execute(params, defTasks.callback, defTasks.errback); //Execute each task } catch (e) { console.log("Error caught"); console.log(e); defTasks.errback(e); //If you get an error for any task, execute the errback } } } //needed to limit identify to only currently visible layers function createIdentifyParams(layers,evt){ identifyParamsList.length = 0; dojo.forEach(layers, function (layer) { var idParams = new esri.tasks.IdentifyParameters(); idParams.width = map.width; idParams.height = map.height; idParams.geometry = evt.mapPoint; idParams.mapExtent = map.extent; idParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_VISIBLE; var visLayers = layer.visibleLayers; if (visLayers !== -1) { idParams.layerIds = layer.visibleLayers; }else { idParams.layerIds = []; } idParams.tolerance = 3; idParams.returnGeometry = true; idParams.spatialReference = spatialReference; identifyParamsList.push(idParams); }); return identifyParamsList; } function showIdentifyResults(r) { var results = []; r = dojo.filter(r, function (result) { return r[0]; }); //filter out any failed tasks for (i=0;i<r.length;i++) { results = results.concat(r[1]); } results = dojo.map(results, function(result) { var feature = result.feature; var layerName = result.layerName; feature.attributes.layerName = result.layerName; feature.setInfoTemplate(generateInfoTemplate); var resultGeometry = feature.geometry; var resultType = resultGeometry.type; if (layerName == "House" || layerName == "Congressional" ) { feature.attributes.nameTitle = "Representative "; feature.setInfoTemplate(legisInfoTemplate); } if (layerName == "Senate") { feature.attributes.nameTitle = "Senator "; feature.setInfoTemplate(legisInfoTemplate); } return feature; }); if(results.length === 0) { map.infoWindow.clearFeatures(); } else { map.infoWindow.setFeatures(results); } map.infoWindow.show(idPoint); return results; } Here's what I have so far, trying to substitute with Deferred and all. Or should it be Promise and all? From my reading, all and deferredList are very similar, but not so for Deferred vs. Promise function createIdentifyParams(layers,evt){ identifyParamsList.length = 0; arrayUtils.forEach(layers, function (layer) { var idParams = new IdentifyParameters(); idParams.width = app.map.width; idParams.height = app.map.height; idParams.geometry = evt.mapPoint; idParams.mapExtent = app.map.extent; idParams.layerOption = IdentifyParameters.LAYER_OPTION_VISIBLE; var visLayers = layer.visibleLayers; if (visLayers !== -1) { idParams.layerIds = layer.visibleLayers; }else { idParams.layerIds = []; } idParams.tolerance = 3; idParams.returnGeometry = true; idParams.spatialReference = spatialReference; identifyParamsList.push(idParams); }); return identifyParamsList; } function runIdentifies(evt) { idPoint = evt.mapPoint; //Create an array of all layers in the map var layers = arrayUtils.map(app.map.layerIds, function(layerId) { return app.map.getLayer(layerId); }); //Only dynamic layers have the getImageUrl function. Filter so you only query visible dynamic layers layers = arrayUtils.filter(layers, function(layer) { if (layer.visibleLayers[0] !== -1){ return layer.getImageUrl && layer.visible } }); //map each visible dynamic layer to a new identify task, using the layer url var tasks = arrayUtils.map(layers, function(layer) { return new IdentifyTask(layer.url); }); var defTasks = arrayUtils.map(tasks, function (task) { // return new dojo.Deferred(); // original code return new Deferred(); }); //map each identify task to a new dojo.Deferred //function to create an array of parameters, limits identify to only visible layers var params = createIdentifyParams(layers,evt); var dlTasks = new all(defTasks); // var dlTasks = new dojo.DeferredList(defTasks); //And use all of these Deferreds in a DeferredList, original code dlTasks.then(showIdentifyResults); for (i=0;i<tasks.length;i++) { try { tasks.execute(params, defTasks.callback, defTasks.errback); } catch (e) { console.log("Error caught"); console.log(e); defTasks.errback(e); } } } function showIdentifyResults(r) { var results = []; r = dojo.filter(r, function (result) { return r[0]; }); //filter out any failed tasks for (i=0;i<r.length;i++) { results = results.concat(r[1]); } results = arrayUtils.map(results, function(result) { var feature = result.feature; var layerName = result.layerName; feature.attributes.layerName = result.layerName; feature.setInfoTemplate(generateInfoTemplate); var resultGeometry = feature.geometry; var resultType = resultGeometry.type; if (layerName == "House" || layerName == "Congressional" ) { feature.attributes.nameTitle = "Representative "; feature.setInfoTemplate(legisInfoTemplate); } if (layerName == "Senate") { feature.attributes.nameTitle = "Senator "; feature.setInfoTemplate(legisInfoTemplate); } return feature; }); if(results.length === 0) { map.infoWindow.clearFeatures(); } else { map.infoWindow.setFeatures(results); } map.infoWindow.show(idPoint); return results; }
... View more
10-02-2013
01:31 PM
|
0
|
7
|
2604
|
|
POST
|
Maybe. I've not used that before and have no account. It has data that I'm not ready to release to the public yet and it would be quite a bit of work to come up with substitute data sets. I've spent enough time on it today that it's broken more now that it was a few hours ago. That's what I get for trying to tidy up my code and bring it up to date. When it was sloppier, it worked better. Plus, I consider myself a GIS person, not a programmer, so I hate for people to look at my code!
... View more
10-01-2013
01:34 PM
|
0
|
0
|
2003
|
|
POST
|
That would be a good suggestion, if I didn't already have mulitple working examples stripped down that do that already. I just need to keep plugging away on this. I feel like I have to begin converting my code to AMD, but it's really been a hassle so far. I had a non-AMD version that works just fine.
... View more
10-01-2013
01:25 PM
|
0
|
0
|
2003
|
|
POST
|
I'd been using Firefox. I get this error in Chrome: dojo/parser parse() error SyntaxError {} [VM] init.js (597):34 Resource interpreted as Script but transferred with MIME type text/plain: "https://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer?f=json&callback=dojo.io.script.jsonp_dojoIoScript1._jsonpCallback". I have a proxy set up and this path is in it. The other thing I'm probably getting goofed up with is setting up the parser. I have a djConfig defined as parseOnLoad:false and then after requiring dojo/parser, I have a statement parser.parse. But something I read said I was supposed to have parserOnLoad set to true if I was going to define any of my widgets declaratively. I have several in this code. But when I take out parser.parse and switch parseOnLoad back to true, that didn't work either.
... View more
10-01-2013
12:44 PM
|
0
|
0
|
2003
|
|
POST
|
I have quite a bit of code I'm still trying to convert to AMD, but no errors on the map object. It's possible that something else that isn't right yet is having a cascading effect. It seems weird that something completely unrelated like an trying to fix my 'onClick' function on a button could keep a basemap from loading.
... View more
10-01-2013
12:22 PM
|
0
|
0
|
2003
|
|
POST
|
I have several projects that have the basemap defined as part of the map constructor. I have a project I'm reworking in the AMD style, so I'm going through, changing the code as best I can. Maybe I've hit a gotcha on this one that I'm not aware of. The definition for the map is highlightMarkerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 22, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([255,255,0]), 2), new Color([255,255,0,0.5])); var popup = new Popup({ markerSymbol: highlightMarkerSymbol, fillSymbol: new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([255,200,0]), 2), new Color([255,255,0,0.50])) }, dojo.create("div")); map = new Map("mapDiv", { infoWindow: popup, basemap: "topo", center: [-92.593, 38.5], zoom: 7 }); After this I load a few different layers. I'm also defining a basemapGallery to let the users change the background. All my layers load fine and I'm not getting any errors. When my page first loads, there is no basemap displayed, it's just blank. If I zoom in a couple of times, then it draws. If I use my tool to change the basemap, it also works fine. I tried a few different basemaps, not just topo, with the same results. Can anyone provide some insight as to why the basemap might not draw at first? I have this same syntax in other projects and it works just fine in them!
... View more
10-01-2013
09:16 AM
|
0
|
11
|
2988
|
|
POST
|
OK, I was thinking if I used Label for both those, then somehow I wasn't making use of the value anywhere at all. Now I just need to look at my prompt a little differently. I started out with a single option "Pick a district" and rely on the function to add all the names below it. When you click in the box as if to type to start a serach, it doesn't clear the prompt, you're just type the letter in front of the Pick a district, so you can something like DPick a district, which of course yields nothing. I need something to clear 'onClick' or something like that.
... View more
09-30-2013
12:07 PM
|
0
|
0
|
569
|
|
POST
|
After all this, I'm not getting the behavior I really need. I have district names for 'name' and for the values, I have a 6 digit numeric code, which is the common data element between my district polygons and school point layers. When trying to use the 'filtering' aspect of the dijit, it is expecting the code. My intent was for the user to end a "B" for example and skip to that section of the list. Nobody is going to know the internal code!
... View more
09-30-2013
11:34 AM
|
0
|
0
|
2240
|
|
POST
|
Not quite figured out after all. When I try to entering a letter to move to that place in the list (the only reason I switched to FilteringSelect in the first place), it tells me the value entered isn't valid. In the example, I saw the query filter set as
queryExpr:'*${0}*'
But when I looked at the variable, that was the property already, so I didn't explicitly set it again. It seems redundant to do so.
... View more
09-30-2013
11:18 AM
|
0
|
0
|
2240
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 06-02-2017 02:38 PM | |
| 2 | 03-18-2022 10:14 AM | |
| 2 | 02-18-2016 06:28 AM | |
| 1 | 03-18-2024 07:29 AM | |
| 4 | 08-02-2023 06:08 AM |
| Online Status |
Offline
|
| Date Last Visited |
02-25-2025
01:56 PM
|