|
POST
|
The definition of getContent on a graphic says Returns the content string based on attributes and infoTemplate values You don't have an infoTemplate defined, only attributes. That's why getContent is failing. If you plan is to use the information to show a popup or infoWindow, you'll need something like an infoTemplate anyway to define how your tag comes up.
... View more
10-02-2014
12:46 PM
|
1
|
0
|
3907
|
|
POST
|
I'm using the TOC dijit just fine with the 3.10 version of the API. It's the same TOC that I downloaded several months ago.
... View more
10-02-2014
12:15 PM
|
0
|
0
|
2956
|
|
POST
|
If there is something wrong with the graphic before you add attributes, there's already an issue before you get to the setAttributes line. Could you also provide the definitions for the variables you're using like iconPath, myColor etc.
... View more
10-02-2014
12:08 PM
|
0
|
1
|
3907
|
|
POST
|
I have a project with multiple layers. The user can control the layers through the TOC. I have a popup with a fillSymbol added, because all my layers are polygons. An identifyTask executes on the map click and depending in the layer, a different infoTemplate is used, as well as a different color for the header. There's other tools that load a grid based on a user drawn graphic, so some of the choices I've made in the code have to deal with it. This project was written originally in legacy and I"m trying to get all that code updated to AMD. I noticed today that although my infoTemplates display correctly with the color changes as expected, the polygon isn't highlighting. I explicitly added highlight:true to my popup definition, but that's the default anyway, so that didn't help. I'm not including all the code and I don't think I can get it working in Fiddle. Our test site is public facing: EEZ Viewer AMD style selectSymbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([255,0,0]), 3), new Color([255,255,0, 0.25])); //red outline, yellow fill popup = new Popup({ fillSymbol: selectSymbol }, domConstruct.create("div")); map = new Map("mapDiv", { infoWindow: popup, center: [-92.593, 38.5], zoom: 7 }); // ---- define information tag formats---- bg_infoTemplate = new InfoTemplate(); bg_infoTemplate.setTitle("Block Group 2010"); bg_infoTemplate.setContent( "<b>${GEOID10}</b> <br>" + "Population: ${Population}<br>" + "Unemployment: ${Unemployment}<br/>" + "County Poverty: ${CountyPoverty}<br>" + "State Poverty: ${StatePoverty}<br>" + "Overlap %: ${ZoneCrossPct}" ); eez_infoTemplate = new InfoTemplate(); eez_infoTemplate.setTitle("EEZ 2000"); eez_infoTemplate.setContent( "<b>${EEZ_DESC}</b> <br>" + "City: ${CITY}<br>" + "Township: ${TOWNSHIP}<br>" + "County: ${COUNTY}<br/>" + "Tract: ${TRACT}<br>" + "Block Group: ${BLKGRP}" ); eez10_infoTemplate = new InfoTemplate(); eez10_infoTemplate.setTitle("EEZ 2010"); eez10_infoTemplate.setContent( "Tract: ${TRACT}<br>" + "Block Group: ${BLKGRP}" ); tif_infoTemplate = new InfoTemplate (); tif_infoTemplate.setTitle("Tax Inc Financing"); tif_infoTemplate.setContent ( "<b>${Name}</b><br>" + "Description: ${Description}<br/>" +"Legal Def: ${LegalDef}" ); //----------- add layers -------------------- countyLayer = new ArcGISDynamicMapServiceLayer(pathName+"/ArcGIS/rest/services/BaseMap/county_simple/MapServer", {id:"countyLayer" }); selGraphicsLayer = new GraphicsLayer({id:'selGraphicsLayer'}); var districtLayer = new ArcGISDynamicMapServiceLayer(pathName+"/ArcGIS/rest/services/LEGIS/legisDistrict/MapServer",{ id:'districtLayer', visible:false}); eezLayer = new ArcGISDynamicMapServiceLayer(pathName+"/ArcGIS/rest/services/DED/EEZ/MapServer",{ id:'eezLayer',visible:true, opacity:0.6}); eezFeatureLayer = new FeatureLayer(pathName+"/ArcGIS/rest/services/DED/EEZ/MapServer/3", {mode: FeatureLayer.MODE_SELECTION, id: "eezFeatureLayer", outFields: ["*"], autoGeneralize: true, maxAllowableOffset:5}); eezFeatureLayer.setSelectionSymbol(highlightFillSymbol); eezSelectFeatureLayer = new FeatureLayer(pathName+"/ArcGIS/rest/services/DED/EEZ/MapServer/3", {mode: FeatureLayer.MODE_SELECTION, id: "eezSelectFeatureLayer", outFields: ["*"], autoGeneralize: true, maxAllowableOffset:5}); eezSelectFeatureLayer.setSelectionSymbol(selectSymbol); map.addLayers([countyLayer,selGraphicsLayer,districtLayer, eezLayer, eezFeatureLayer, eezSelectFeatureLayer]); // ---- populates the Table of contents -------- map.on("layers-add-result", function (event) { try { var toc = new TOC({ map: map, layerInfos: [{ layer: eezLayer, title: "Enhanced Enterprise Zones", slider:true },{ layer: districtLayer, title: "Legislative Districts" }] }, 'tocDiv'); toc.startup(); } catch (e) { console.log(e.message); } }); // ---- change infoWindow header color based on content ---- popup.on( "selection-change", function(){ count = popup.count; query(".esriPopup .titlePane").style("backgroundColor", "#7EABCD"); query(".esriPopup .titlePane .title").style("backgroundColor", "#7EABCD"); if (count >= 1) { var feature = popup.getSelectedFeature(); var featureTitle = feature.infoTemplate.title; switch (featureTitle) { case "EEZ 2010": query(".esriPopup .titlePane").style("backgroundColor", "#ff5b5b"); query(".esriPopup .titlePane .title").style("backgroundColor", "#ff5b5b"); break; case "EEZ 2000": query(".esriPopup .titlePane").style("backgroundColor", "#bc79ff"); query(".esriPopup .titlePane .title").style("backgroundColor", "#bc79ff"); break; case "Tax Inc Financing": query(".esriPopup .titlePane").style("backgroundColor", "#facb74"); query(".esriPopup .titlePane .title").style("backgroundColor", "#facb74"); break; default: query(".esriPopup .titlePane").style("backgroundColor", "#7EABCD"); query(".esriPopup .titlePane .title").style("backgroundColor", "#7EABCD"); break; } } }); //---- identify setup and functions ---- identifyClickHandler = on.pausable(map, 'click', executeIdentifyTask); identifyTask = new IdentifyTask(eezLayer.url); identifyParams = new IdentifyParameters(); identifyParams.tolerance = 1; identifyParams.returnGeometry = true; identifyParams.layerOption = IdentifyParameters.LAYER_OPTION_VISIBLE; identifyParams.width = map.width; identifyParams.height = map.height; function executeIdentifyTask(evt){ map.infoWindow.hide(); identifyParams.mapExtent = map.extent; var currentVis = getVisibleLayers(eezLayer); if (mapClick) { idPoint = evt.mapPoint; identifyParams.layerIds = currentVis; }else { identifyParams.layerIds = [3]; } identifyParams.geometry = idPoint; var deferred = identifyTask.execute(identifyParams); deferred.addCallback(function(response){// response is an array of identify result objects return arrayUtils.map(response, function(result){ var feature = result.feature; feature.attributes.layerName = result.layerName; switch (result.layerName) { case 'EEZ 2000': feature.setInfoTemplate(eez_infoTemplate); break; case 'EEZ 2010': feature.setInfoTemplate(eez10_infoTemplate); break; case 'Tax Increment Financing Areas': feature.setInfoTemplate(tif_infoTemplate); break; default: feature.setInfoTemplate(bg_infoTemplate); break; } return feature; }); }); map.infoWindow.setFeatures([deferred]); map.infoWindow.show(idPoint); mapClick = true; } //---- determines current layer visibility, used for identifyParameter -- function getVisibleLayers(myLayer) { var visibleLayers = []; var items = arrayUtils.map(myLayer.layerInfos, function (info, index) { layerID = info.id; if (info.visible && !info.subLayerIds) { visibleLayers.push(layerID) } }); return visibleLayers; }
... View more
10-02-2014
07:42 AM
|
0
|
0
|
1024
|
|
POST
|
The Missouri Legislative Analysis example uses QueryTask, not FindTask, because its based on a polygon as input to the Query. It should still show how to manage multiple tasks as well as a corresponding grid for each.
... View more
09-10-2014
06:54 AM
|
1
|
0
|
1853
|
|
POST
|
If I remember correctly, the code assist has more to do with the Aptana IDE and less of what is or isn't in the API. If that's the case, this would be something you'd have to investigate through Aptana forums, if there are any.
... View more
09-08-2014
06:14 AM
|
0
|
0
|
1704
|
|
POST
|
In the end, I changed my error handler for my queryTask not to be as an event listener and it started working. Instead I put it at the end of the queryTask.execute(query, queryCountyResults, errorHandler); I shouldn't have had to do it that way, but it worked. I marked the answer earlier as correct, since it addressed the issue of the post.
... View more
09-05-2014
02:47 PM
|
0
|
0
|
4454
|
|
POST
|
It sounds like a bit of a gray area. If you aren't keeping the results beyond the session, then are you meeting the definition of 'batch'? For myself, I have used the geocoder just as a means for getting the map focused to a particular area. It might be OK in this scenario, but of course the next request from the user could be 'now I want to keep what I'm seeing' which just crosses over to 'not OK' without use of a subscription.
... View more
09-05-2014
02:44 PM
|
0
|
1
|
4871
|
|
POST
|
I must be getting tired. I forgot to set my query.where to my string once I had it all formatted! Now instead of the original type function, I'm getting another one: 'undefined' is not a function.
... View more
09-05-2014
01:43 PM
|
0
|
1
|
4454
|
|
POST
|
You're right! That didn't fix it, though. I do think I must have an error somewhere else. My queryTask error handler isn't executing, which it normally does when I have a syntax problem on the query.
... View more
09-05-2014
01:30 PM
|
0
|
0
|
4454
|
|
POST
|
I tried a join like var countyString = countyCheck.split(', ').join("','"); and my string looks OK. I also tried your way too, again the string looks OK The console log shows whereClause2 = COUNTYNAME IN ('Cole','Dent') , which looks like the REST syntax, so I figured I was good to go. Either method of creating the string, the queryTask is failing though. I'm getting an error: TypeError: a.toJson is not a function
... View more
09-05-2014
01:13 PM
|
0
|
2
|
4453
|
|
POST
|
I get what you're saying, but I get lost trying to replace in a string where it needs to escape things like quotes.
... View more
09-05-2014
12:42 PM
|
0
|
1
|
4453
|
|
POST
|
Looking at my rest endpoint, I can enter a where clause of COUNTYNAME IN ('Dent', 'Holt'). I'd like to let the user enter a list of county names in an input field and parse that information into a where clause for a Query. I assume if I can run a query from the endpoint, I ought to be able to do the same thing programmatically as long as I can get my syntax correct on my where clause. The user has an input text field and they should enter county names separated by commas. Once they click a button, a where clause is created with all the counties specified. The queryTask doesn't execute because my query syntax is wrong.
function checkCountyInput() {
var countyCheck = registry.byId('countySel').get("value");
console.log("countyCheck = " + countyCheck);
var countyArray = countyCheck.split(",");
console.log("countyArray = " + countyArray);
idList.length = 0;
countyList.length = 0;
//the syntax that worked on the REST endpoint
//COUNTYNAME IN ('Dent', 'Holt')
var whereClause = "COUNTYNAME IN (" + countyArray + ")";
query.outSpatialReference = spatialReference;
query.returnGeometry = false;
query.outFields = "*";
console.log("where clause = " + whereClause);
var queryTask = new QueryTask(featureLayer.url);
queryTask.on ("error", function (err) {
console.log("error in queryTask: " + err.message);
});
queryTask.execute(query, queryCountyResults);
}
I'm I not going about this the right way?
... View more
09-05-2014
12:17 PM
|
0
|
9
|
5526
|
|
POST
|
I don't believe ESRI licensing allows batch geocoding in this manner. That is part of an ArcOnline subscription.
... View more
09-05-2014
11:30 AM
|
0
|
3
|
4871
|
|
POST
|
I have a dGrid declared with both Selection and selector, to have check boxes for each row. I let the user select multiple rows and use those to create a chart. In addition, if they click on a single feature on the map, this also creates a chart for just that feature. This is all working, my problem is with what is happening to my grid. Once I've gone through the process of creating my chart, either from the grid selection, or the click on the featureLayer, my grid only contains the selected records I used for the chart and nothing else. I can't figure out how to get my grid back to it's previously unselected, all records original. This is how I'm creating my grid. It's generated as a results handler on a featureLayer.queryFeatures where the query contains a where clause of 1=1, so it returns all records. My grid has the correct data in it and shows all records. The grid doesn't have hard coded column names. I have a function that builds the columns from an array of field names I define earlier.
function createGrid(results) {
domConstruct.empty(dom.byId('gridDiv'));
var gridColumns = buildColumns();
var data = arrayUtils.map(results.featureSet.features, function(feature){
return feature.attributes;
});
var currentMemory = new Memory ({data:data, idProperty:'OBJECTID'});
grid = new (declare([Grid, Selection, selector]))({
id:'grid',
columns: gridColumns,
selectionMode:'single',
store: currentMemory
}, "gridDiv");
grid.sort('County');
}
//creates a column definition for the grid based on the attributes returned from the query
function buildColumns() {
var columns = [];
//qryOutFields is an array of fieldNames defined earlier
arrayUtils.forEach(qryOutFields, function(field){
var objects = {};
objects.label = field;
objects.field = field;
if (field === 'OBJECTID') {//assumed name for internal ID from map service
objects.hidden = true;
}
columns.push(objects);
});
var sel = selector({ label: '', sortable: false });
columns.splice(0, 0, sel);
return columns;
}
The Make Chart button executes the function getIdFromGrid, checks to see what's currently selected in the grid, gathers the objectids and county names. The initializeChart uses those objectIDs to execute another query to get the attributes for those records. These become the input needed for the chart (the lists of rates and the maximum value for the Y axis) Last, it calls a function to finish the chart.
function getIdFromGrid(){
var rowid,gQuery;
idList.length = 0;
countyList.length = 0;
maxList.length = 0;
for (var rowid in grid.selection) {
var row = grid.row(rowid);
idList.push(parseFloat(rowid)); //list of objectIds
countyList.push(row.data.County); // list of county names
}
initializeChart();
}
function initializeChart(){
// console.log("county list = " + countyList);
domConstruct.empty("chartDiv");
lineChart = new Chart2D("chartDiv");
gQuery = new Query();
gQuery.objectIds = idList;
seriesList.length = 0;
featureLayer.queryFeatures(gQuery, function(results) {
arrayUtils.forEach(results.features, function (result){
createRateList(result);//builds an array of attributes for each records
});
});
var maxRate = findMax(maxList);
var maxVal = Math.round(maxRate);
var axisYMax = (parseInt(maxVal/10)+1)*10; //extends the Y axis to an even interval
finishLineChart(axisYMax);
}
In finishLineChart, my chart gets created. That function is rather long, so I'm leaving it out. Once the chart is displayed, the grid changes. It only includes the selection made when I executed Make Chart. I can't figure out how to get back to the 'unselected' state. I have a clear button where I'm attempting to get rid of everything I can think of. I've thought of running another query of '1=1' just to select all my features again, but that seems extreme.
registry.byId('btnClearChart').on('click', function (){
grid.clearSelection();
featureLayer.clearSelection();
grid.refresh();
});
Is there some other method of clearing out my grid selection and getting back to the original? I've used grids in nearly every map I've created, but this is the first time I've used either Selection or selector. I'm wondering if there is something buggy in other of those?
... View more
09-05-2014
07:14 AM
|
0
|
2
|
3901
|
| 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
|