|
POST
|
I'm playing around with layouts using an example from the Dojo documentation. It works properly when using the dojo.js source, but when I use the Esri 3.5 API, it doesn't work. Here's a fiddle showing the layout. Why isn't it working properly with the 3.5 API?
... View more
06-05-2013
08:03 AM
|
0
|
2
|
970
|
|
POST
|
Here's the way I got the layer name into my infoWindow. This shows all the visible attributes for the layer
connect.connect(map, "onClick", executeIdentifyTask);
identifyTask = new esri.tasks.IdentifyTask(parameters.url);
identifyParams = new esri.tasks.IdentifyParameters();
identifyParams.tolerance = 3;
identifyParams.returnGeometry = true;
//identifyParams.layerIds = [0, 117];
identifyParams.layerIds = myLayer.visibleLayers;
identifyParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_ALL;
identifyParams.width = map.width;
identifyParams.height = map.height;
map.infoWindow.resize(415, 200);
map.infoWindow.setTitle("Results");
function executeIdentifyTask(evt) {
identifyParams.geometry = evt.mapPoint;
identifyParams.mapExtent = map.extent;
identifyParams.layerIds = myLayer.visibleLayers; //in case the visible layers have changed for the layer
var deferred = identifyTask.execute(identifyParams);
deferred.addCallback(function (response) {
return dojo.map(response, function (result) {
var feature = result.feature;
var infoTemplate = new esri.InfoTemplate("test", "${*}");
var contentString = "";
var sp = new Array();
var sp = feature.attributes;
contentString += "<b>" + result.layerName + "</b><hr width = '90%'>";
for (x in sp) {
contentString += x + ": " + feature.attributes + "<br/>";
}
var infoTemplate = new esri.InfoTemplate();
var titleText = "<div>" + "Title" + "</div>"
infoTemplate.setTitle(titleText);
infoTemplate.setContent(contentString);
feature.setInfoTemplate(infoTemplate);
return feature;
});
});
map.infoWindow.setFeatures([deferred]);
map.infoWindow.show(evt.mapPoint);
}
... View more
06-04-2013
12:20 PM
|
0
|
0
|
1885
|
|
POST
|
This should do it
function processServiceInfo(info) {
console.log('layer info: ', info);
console.log("info.name: " + info.name + ",info.id: " + info.id);
var fieldInfos = "";
fieldInfos += "[";
dojo.forEach(info.fields, function(field) {
console.log( "Name: " + field.name + ", Alias: " + field.alias);
if (field.name != "Shape" & field.name != "OBJECTID") {
fieldInfos += "{'fieldName': '" + field.name + "',";
fieldInfos += "'label': '" + field.alias + "',";
fieldInfos += "'visible':" + true + "},";
}
});
fieldInfos += "],";
console.log("fieldInfos: " + fieldInfos);
return fieldInfos;
}
... View more
05-31-2013
11:07 AM
|
0
|
0
|
2181
|
|
POST
|
Thanks, Kelly, that did the trick. Here's the code I that works. Now to get everything formatted to look good. function populateTC1(results, evt) {
try {
if (dijit.byId('tabs').hasChildren) {
dijit.byId('tabs').destroyDescendants();
}
if (results.length == 0) {
console.log('Nothing found.');
return;
}
var combineResults = {};
for (var i = 0, len = results.length; i < len; i++) {
var result = results;
var feature = result.feature;
var lyrName = result.layerName.replace(' ', '');
if (combineResults.hasOwnProperty(lyrName)) {
combineResults[lyrName].push(result);
}
else {
combineResults[lyrName] = [result];
}
}
for (result in combineResults) {
var columns = buildColumns(combineResults[result][0].feature);
var features = [];
for (i = 0, len = combineResults[result].length; i < len; i++) {
features.push(combineResults[result].feature);
}
var data = array.map(features, function (feature) {
return lang.clone(feature.attributes);
});
var dataGrid = new (declare([Grid, Selection]))({
id: "dgrid_" + combineResults[result][0].layerName,
bufferRows: Infinity,
columns: columns
});
dataGrid.renderArray(data);
var cp = new ContentPane({
id: result,
//content: combineResults[result][0].layerName + '<br/>Found ' + combineResults[result].length,
content: dataGrid,
title: combineResults[result][0].layerId
}).placeAt(dijit.byId('tabs'));
}
map.infoWindow.show(evt.screenPoint, map.getInfoWindowAnchor(evt.screenPoint));
}
catch (e) { console.log(e.message); }
}
function buildColumns(feature) {
var attributes = feature.attributes;
var columns = [];
for (attribute in attributes) {
var objects = {};
objects.label = attribute;
objects.field = attribute;
columns.push(objects);
}
return columns;
}
And this is what it looks like now [ATTACH=CONFIG]24872[/ATTACH]
... View more
05-31-2013
10:59 AM
|
0
|
0
|
1169
|
|
POST
|
I'm building a data viewer application where a user can click on the map and see the attributes of all the features for the visible layers. This is a project I had originally built in Flex that I'm moving over to JavaScript. I would to put a dgrid into an InfoWindow that shows the results of an IdentifyTask for the visible layers in a map service. This would be similar to this sample, but using dgrids instead of tables. I'm getting close, using this example from Derek Swingley, but I'm hitting a brick wall when it comes to creating the data store for the dgrid. While the dgrid sample shows how to do this using hardcoded field names, I have to do this dynamically. My application will be a template for several different projects, each with their own map service. Additionally, the map services may change over time, with new layers added or different fields being made visible.
... View more
05-31-2013
07:42 AM
|
0
|
2
|
1691
|
|
POST
|
Don't forget to click the check mark and promote the post that best answered your original question. The conversion will only work for a geographic coordinate system, and I believe (and someone please correct me if I'm wrong) only with 4326.
... View more
05-30-2013
09:49 AM
|
0
|
0
|
6446
|
|
POST
|
Remember, though, that you're executing an IdentifyTask for each individual map service. If you simply wanted to get the visible layers for each service, you could use this
var visLayers = dojo.map(layers, function (layer) {
return layer.visibleLayers;
});
but that would give you more layers than you want, I suspect. Instead, you'd cycle through each service and add the visible layers for that specific service, so you'd have something like visibleLayers = {[0,1],[0,1],[0,2],[0,1,2,3,4],[0,1,2,3,4,5]} These would have to be in the same order as the tasks, so you could use the line idParams.layerIds = visibleLayers;
... View more
05-30-2013
07:57 AM
|
1
|
1
|
2146
|
|
POST
|
The layerIds property is expecting a array of numbers, like idParams.layerIds = [0,1,5,9]; Instead of using identLayers, you'll have to build an array that holds the layers you want to show in your popup for each map service.
... View more
05-30-2013
07:09 AM
|
0
|
0
|
2146
|
|
POST
|
You can use esri.geometry.xyToLngLat, which translates Web Mercator coordinates to lat/long.
... View more
05-29-2013
09:56 AM
|
0
|
0
|
6446
|
|
POST
|
In your loop where your executing each task, why not set the layerIds parameter of idParams for each of the tasks? You could use another array (visibleLayers) where you have stored the visible layers for each layer
for ( i = 0; i < tasks.length; i++) {//Use 'for' instead of 'for...in' so you can sync tasks with defTasks
try {
idParams.layerIds = visibleLayers;
tasks.execute(idParams, 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
}
}
... View more
05-29-2013
07:44 AM
|
0
|
0
|
2146
|
|
POST
|
IdentifyParameters has the property layerIds, where you can set the layers that the are used in the task.
... View more
05-28-2013
01:23 PM
|
0
|
0
|
2146
|
|
POST
|
Here's an example of using a DeferredList to await for the results of two different IdentifyTasks.
... View more
05-28-2013
07:13 AM
|
0
|
0
|
2264
|
|
POST
|
This is an old thread, but it shows one way of getting that.
... View more
05-24-2013
07:53 AM
|
0
|
1
|
1220
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 02-04-2025 06:39 AM | |
| 1 | 05-01-2026 08:26 AM | |
| 1 | 04-10-2026 12:01 PM | |
| 1 | 04-13-2026 09:11 AM | |
| 1 | 10-11-2023 06:18 AM |
| Online Status |
Offline
|
| Date Last Visited |
yesterday
|