|
POST
|
Maybe you're doing something special with your identify, but just because your identifyTask generates something that is typically called results doesn't mean you have to add that as a requirement. I use IdentifyTask all the time and I've never added it either as a requirement or an alias, just IdentifyTask and IdentifyParameters. Try taking that out and see if that helps. You shouldn't have to keep using dot notation if all is well in the top section.
... View more
11-05-2013
10:28 AM
|
0
|
0
|
2564
|
|
POST
|
The thing that caught my eye is you're still declaring your FindTask as using the old 'dot' style.
findTask = new esri.tasks.FindTask("http://eagle.camplan.uga.edu:6080/arcgis/rest/services/CampusMap/UGA_CampusMap_Base/MapServer");
One of the things you should do is change this to be simply:
findTask = new FindTask("http://eagle.camplan.uga.edu:6080/arcgis/rest/services/CampusMap/UGA_CampusMap_Base/MapServer");
That's part of the point of switching to AMD. I totally agree with Ken's comments on the order of the require and aliases too. One really basic thing I did was to add some more lines to both. My eye wasn't always tracking the order correctly if I had to keep scrolling over to the right to see whatever I'd tacked onto the far right side. Once I took the time to tidy that section up a bit, putting less on each line, it was a lot more obvious where I was getting off track. If you don't have this part right, you're going to see weird behavior. Ken's comment about putting all the non-aliases requires last is likely also part of your problem. Don't mix those up at the top while your trying to get the requires and aliases "paired up". Stick them at the end, right before dojo/domReady.
... View more
11-04-2013
11:02 AM
|
0
|
0
|
2564
|
|
POST
|
I figured it out after a little more reading. It's hard to do Internet searches on such generic terms (button, click, on ....) registry.byId('btnWICoffSat').on('click', function (){ toggleLayer('offSatLayer')});
... View more
10-31-2013
11:02 AM
|
0
|
0
|
1014
|
|
POST
|
I have a button that used to work fine in my non-AMD syntax. I have just two layers that I'd like to let the user turn on and off. I had a small function that would check the current visibility and toggle it on/off depending on its current state. //functions for turning layer on/off function toggleLayer(layerId) { var layer = app.map.getLayer(layerId); if (layer.visible) { layer.hide(); } else { layer.show(); } } I had the button defined as <button id="btnWICvendor" dojotype="dijit.form.Button" onClick="toggleLayer('venLayer')"> Click to Hide Sites</button> From my reading, it sounded like I should be adding the click listener to the button using dojo/on. Besides updating the button definition, I removed onClick and added this line into my code. But it doesn't look like I pass any argument with this method. registry.byId('btnWICvendor').on('click', toggleLayer); I thought this would be simple, but apparently not! What am I missing? I know I could use TOC, but that seems like overkill for this particular map.
... View more
10-31-2013
10:35 AM
|
0
|
2
|
1291
|
|
POST
|
I hate to mark any particular reply as the answer to my posting, but I'm always looking for the green 'A' to know the posting did had a resolution. I'll continue to pursue my formatting a zoom button question, but mark this answered since my grid now has data in it.
... View more
10-29-2013
12:58 PM
|
0
|
0
|
1709
|
|
POST
|
Nearly all my services have multiple layers within them. You aren't referring to group layers are you? It gets hard to have a discussion when we're using such generic terms as layer. It doesn't matter what the layers are called within the service, or if you have the same layer name in two different services. You aren't using these names when you set up your identify. What you are using in Identify is the unique ID you should be assigning to each layer as you load it into your map. When you add a layer,you should always give it an id. I give the same id as the variable, just to keep it straight in my head.
educationLayer = new ArcGISDynamicMapServiceLayer(pathName+"/ArcGIS/rest/services/BaseMap/Education/MapServer", {id:'educationLayer', visible:false})
When you start up the runIdentifies function, the first thing it does is look at the current layers you have loaded. It's going to create an array of all the layers. This isn't a list of the names as they are called in the service directory.
var layers = arrayUtils.map(app.map.layerIds, function(layerId) {
return app.map.getLayer(layerId);
});
When you define your identifyParameters, you don't care about the names of the layers here either. I have this set up to generate a new identifyTask and corresponding identifyParameters each time you click. Since the identifyParameters are created on-the-fly, you have the chance to specify which layers you want to identify. You need this extra parameter of layerIds, setting IdentifyParameters.LAYER_OPTION_VISIBLE isn't going to be enough.
var visLayers = layer.visibleLayers;
if (visLayers !== -1) { //TOC lets the user change visibility, layerIDs must be explicitly defined
idParams.layerIds = layer.visibleLayers;
}else {
idParams.layerIds = [];
}
When defining visLayers, it's returning the array of numbers, something like [0,2] or whatever you have currently turned on. Again, it doesn't matter what something is called in the service.
... View more
10-29-2013
12:51 PM
|
0
|
0
|
1611
|
|
POST
|
I missed the ColumnHider part in your declaration before. That works well, thanks. I had a problem with my Floating Pane looking like it was scrolled all the way to the bottom, instead of the top, but adding the overflow style on the TitlePane seems to have fixed it both that issue as well as putting the scrollbars where they needed to be. The last thing I need to get working is the column is "zoom" buttons I used to have, which was a formatted way of showing the Object ID column. I have those functions commented out because I wasn't ready to tackle that yet, especially because that was a dojox/grid/datagrid and now I'm using onDemandGrid. Hopefully there's still a way to add a formatter on a field.
... View more
10-29-2013
11:56 AM
|
0
|
0
|
1709
|
|
POST
|
I realized that I did have headers, but they weren't styled right. I went back to the thread you helped me on earlier (I think it was you) that the 'headers were shoved out the top'. I have headers and data. I'm down to styling. I have a grid, inside a title pane inside a floating pane. The grid's rarely going to fit, no matter how big I size the panes. Obviously I need scrollbars. Would those be a style on the title panes then? I also have some columns I really don't want to appear, like Shape.len and Shape.area. I'll need to figure out where to limit my columns and my data so neither are shown.
... View more
10-29-2013
11:11 AM
|
0
|
0
|
2585
|
|
POST
|
When I've used PrintTask, it was using locally hosted services, not AGO, so my experience might not apply. Past experience in general tells me that there's lot of situations where you end up needing a proxy page. It's not just for security, but any time you are trying to pass too many characters in a request, that's a circumstance that requires a proxy page too. From the help: A proxy page is necessary in the following situations: The application creates requests that exceed 2048 characters. While there is no official maximum length for a URL some modern browsers have imposed limits. Using a proxy works around this issue by performing a POST request rather than a GET request. POST requests are not limited by the 2048 character maximum because the information is transferred in the header instead of the URL. Common situations where you may exceed the URL length are: Buffer complex polygons then use the buffered geometry with a query task. Specify a spatial reference using well-known text (wkt). The application uses a service that is secured with token-based authentication , and you do not wish to allow users to view the token, or you do not want to transmit the token over the network between your Web server and your users. The application edits features in a feature service, unless the application is on the same domain as the GIS Server.
... View more
10-29-2013
09:08 AM
|
0
|
0
|
2266
|
|
POST
|
I had another thread where I was asking the differences between the different types of grids, what data they supported etc, but I got no replies. From what I've read, dGrid supports rendererArray, but if I was using onDemandGrid etc, I could set the store parameter instead and it doesn't support rendererArray. Just for fun, I changed grid to be an OnDemandGrid instead of dGrid, leaving my grid definition with the Memory the way I had it. Suddenly I had data! But now there are no column headers ...
... View more
10-29-2013
08:45 AM
|
0
|
0
|
2585
|
|
POST
|
I should also mention it doesn't completely dislike the columns variable, because the pane is populated with headers, there's just no data. That's why I was focusing more on the Memory than the grid constructor.
... View more
10-29-2013
08:24 AM
|
0
|
0
|
2585
|
|
POST
|
attName is getting returned as a string with the field names I expect, first OBJECTID, then Facility, then Address etc. If it's a column problem, then I'm getting lost in the right way to format it. I was trying to follow the first style in the Hello dGrid example from that page's tutorial. It looks like I can have columns defined as 1. As an array of objects with explicit field and label properties: var columns = [
{
field: "first",
label: "First Name"
},
{
field: "last",
label: "Last Name"
},
{
field: "age",
label: "Age"
}
]; or 2. As a hash map, where the key is used as the "field" and the value is an object containing a "label" property:
var columns = {
first: {
label: "First Name"
},
last: {
label: "Last Name"
},
age: {
label: "Age"
}
};
or 3. As a hash map, where the key is used as the "field" and the value is used as the "label":
var columns = {
first: "First Name",
last: "Last Name",
age: "Age"
};
When it's done looping through to populate gridcolumns, it looks like this:
gridcolumns
[Object { label="OBJECTID",
field="OBJECTID"
},
Object { label="CtyDist",
field="CtyDist"
}, Object { label="Facility"
, field="Facility"
},
Object { label="Address"
, field="Address"
}
This isn't quite perfect looking in this post because I copy/pasted from the Firebug console and it had a lot of extra space that I tried to edit out. But you do see that my attribute names are getting returned. Maybe the format of label:"myfieldName', field:"myfieldName", isn't the right format to follow after all? Or maybe it doesn't like that it's an array of objects?
... View more
10-29-2013
08:20 AM
|
0
|
0
|
2585
|
|
POST
|
Inconceivable! I think I got that code from another forum post. All I'm trying to do is create an array of column names. I'm sure there's a lot of different ways I can go about it. Something I read in another thread suggested there was a problem with IE getting the information in an array and that's when I introduced the line var objects = {} instead. It looks like there are multiple ways to define columns. I think I'm following the 3rd example on the Hello dgrid page http://dojofoundation.org/packages/dgrid/tutorials/hello_dgrid/
... View more
10-29-2013
07:41 AM
|
0
|
0
|
2585
|
|
POST
|
Yes, you can't tell from my thread, by I was able to get my identify to work the way I wanted. One of the gotchas I learned from another thread was that I needed to dynamically create my identifyParameters based on the current visibility. It's not enough to have them defined at the beginning. Once you introduce a TOC into the mix, the visibility isn't fixed. I have this set on a map click event
app.map.on("click", runIdentifies);
These are my identify functions.
// FUNCTION FOR IDENTIFYING MULTIPLE LAYERS AT ONCE
//manually define which layers to do the identify on based on visible Layers
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) { //TOC lets the user change visibility, layerIDs must be explicitly defined
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;
app.map.infoWindow.clearFeatures();
var layers = arrayUtils.map(app.map.layerIds, function(layerId) {
return app.map.getLayer(layerId);
});
layers = arrayUtils.filter(layers, function(layer) {
if (layer.visibleLayers[0] !== -1){
return layer.getImageUrl && layer.visible
}
});
var params = createIdentifyParams(layers,evt);
var tasks = arrayUtils.map(layers, function(layer) {
return new IdentifyTask(layer.url);
});
var IdentifyTaskList = arrayUtils.map(layers, function(layer, index) {
task = new IdentifyTask(layer.url);
return task.execute(params[index]) //assume you have a list of identifyParameters
});
all(IdentifyTaskList).then(showIdentifyResults);
}
function showIdentifyResults(idResults){
var results = [];
idResults = arrayUtils.filter(idResults, function (result) {//filter out any failed tasks
return idResults[0];
});
for (i=0;i<idResults.length;i++) { //combines identifyResults
var lyrResultLen = idResults.length;
var lyrResult = idResults;
for (j = 0; j < lyrResultLen; j++) {
var featRes = lyrResult ;
results.push(featRes);
}
}
formatResults = arrayUtils.map(results, function(result){
var feature = result.feature;
var layerName = result.layerName;
feature.attributes.layerName = result.layerName;
feature.setInfoTemplate(generateInfoTemplate);
generateInfoTemplate.setTitle("Layer Information");
return feature;
});
if (formatResults.length > 0) {
app.map.infoWindow.setFeatures(formatResults);
app.map.infoWindow.show(idPoint);
}
}
I have this other set of functions that allows me to pick and choose which output fields I want to display in the infoTemplate. It's the only 'project specific' bit of code that I have to edit. First you need to define an array of attributes per each layer.
var legisDistAtt = ['OBJECTID','District'];
var prevDistAtt = ['OBJECTID','ID'];
var countyAtt = ['OBJECTID', 'COUNTYNAME'];
Then you want to create a infoTemplate and use a function to set its content:
generateInfoTemplate = new InfoTemplate();
generateInfoTemplate.setTitle("Layer Information");
generateInfoTemplate.setContent(generateWindowContent);
function generateWindowContent(graphic) {
var layerName = graphic.attributes.layerName;//case sensitive field names
var fieldNamesArr = [];
for (fieldName in graphic.attributes) {
if (graphic.attributes.hasOwnProperty(fieldName) && fieldName !=='Shape' && fieldName !== 'Shape.area' && fieldName !== 'Shape.len') {
fieldNamesArr.push(fieldName);
}
}
var attString = "";
switch (layerName) {
case "House District":
attString = createAttRows(graphic, legisDistAtt);
break;
case "Senate District":
attString = createAttRows(graphic, legisDistAtt);
break;
case "Congressional District":
attString = createAttRows(graphic, legisDistAtt);
break;
case "County":
attString = createAttRows(graphic, countyAtt);
break;
default:
attString = createAttRows(graphic, fieldNamesArr);
}
return "<h4>"+ layerName +"</h4>" +"<table id='infoWindowTable' data-dojo-type='dojox/grid/DataGrid' data-dojo-props='class:'infoTable'' ><tr><th></th><th></th></tr>" +attString+ "</table>";
}
function createAttRows(graphic, attArray) {
var returnString = "";
arrayUtils.forEach(attArray, function (attName){
if (attName !== 'OBJECTID' && attName !== 'layerName') {
returnString = returnString + "<tr><td><b>"+attName+"</b></td><td>" + graphic.attributes[attName]+ "</td></tr>";
}
});
return returnString;
}
I throw these last functions in because they're called in the identify results handler to set up the feature's infoTemplate.
... View more
10-28-2013
01:47 PM
|
0
|
0
|
1611
|
|
POST
|
Do you have your proxy page all set up? I don't see any reference to it. I believe it's a requirement for anything related to the IdentityManager.
... View more
10-28-2013
01:29 PM
|
0
|
0
|
2509
|
| 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
|