|
POST
|
i guess the short answer to why do i need identifyTask is because I saw this method in the samples. Now that I look back, the identifyTask seems to only be necessary if it's a dynamicLayer? There are multiple points atop each other at full scale, and when zoomed in, multiple layers can be selected, so I stuck with the deferred = identifyTask.execute() deferred.addCallback() then switch for each featureLayer name and set infoWindow accordingly. There are also several queryRelatedFeatures tasks for some of the layers. Do you have a sample of an identify tool, I've never seen one? Do you just use a dijit.form.button? thanks!
... View more
07-19-2012
03:39 PM
|
0
|
0
|
1141
|
|
POST
|
feature layer is added to map. I would like to hover and get basic info, then click and execute onClick identify task. the hover works great, the popup is displayed and the graphic is cleared onMouseOut, but as soon as the onClick is fired, it immmediately gets replaced by the basic onMouseOver popup. Im assuming this is becasue my hand isn't steady, onMouseOver -- basic popup, onClick --detailed popup, slight movement onMouseOver --basic popup. any help? function init() {
featlayer = new esri.layers.FeatureLayer("url",{
mode:esri.layers.FeatureLayer.MODE_ONDEMAND,
//infoTemplate:template,
id: 'facs',
outFields:["*"]
});
dojo.connect(featlayer, "onMouseOver", showHoverPopup);
dojo.connect(featlayer, "onMouseOut", hideHoverPopup);
dojo.connect(map,"onClick",executeIdentifyTask);
}
function showHoverPopup(evt){
map.graphics.enableMouseEvents();
var infoTemplate = new esri.InfoTemplate();
infoTemplate.setTitle(evt.graphic.attributes.facil_name);
infoTemplate.setContent("<b>${facil_name}</b>");
map.infoWindow.resize(245,125);
var highlightSym = new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_SQUARE, 10,
new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID,
new dojo.Color([255,0,0]), 1),
new dojo.Color([0,255,0,0.25]));
evt.graphic.setInfoTemplate(infoTemplate);
var content = evt.graphic.getContent();
map.infoWindow.setContent(content);
var title = evt.graphic.getTitle();
map.infoWindow.setTitle(title);
highlightGraphic = new esri.Graphic(evt.graphic.geometry,highlightSym);
map.graphics.add(highlightGraphic);
map.infoWindow.show(evt.screenPoint,map.getInfoWindowAnchor(evt.screenPoint));
}
function hideHoverPopup(evt){
map.graphics.remove(highlightGraphic);
}
... View more
07-19-2012
02:25 PM
|
0
|
5
|
2266
|
|
POST
|
anyone ever get this error in manager log? It happens from time to time when someone accesses the JS api web map. Seems like it's related to the sql server sde geodatabase, I never saw the problem with a file geodatabase being hosted. directly following the spatial filter invalid error, this is always posted in manager log: Method failed.HRESULT = 0x80041251 : This is a FACILITY_ITF error that is specific to the interface that returned this error. See the documentation of the interface that returned this error for information about this HRESULT. any advice? Thanks
... View more
07-18-2012
09:58 AM
|
0
|
1
|
949
|
|
POST
|
after some brainstorming, I decided to do away with the identifyTask and replace it with a findTask when a grid row click is detected. The existing code to process the response can remain exactly the same since both the identifyTask and findTask returns a dojo.deferred incase anyone's interested, here's the solution:
function executeIdentifyTask(evt) {
if (evt.mapPoint == undefined){
//grid click, lets switch to a find task
anchorPt = evt.geometry;
siteCode = evt.attributes.site_code[0];
lids.push(0);
var findTask2 = new esri.tasks.FindTask("https://mydomain.com/MapServer/");
var fParams = new esri.tasks.FindParameters();
fParams.searchText = siteCode;
fParams.returnGeometry = true;
fParams.searchFields = ["site_code"];
fParams.layerIds = lids; //set lids to include only facil layer
fParams.contains = false;
var deferred = findTask2.execute(fParams);
}
else{
//map click;
identifyParams.tolerance = 5;
anchorPt = evt.mapPoint;
//since LAYER_OPTION_VISIBLE only pertains to scale visibility, not TOC checked/not checked, we have to manually set the identifyParams.layerIds
dojo.forEach(legendLayers, function(layer){
//layer must be checked in toc AND not be parcels, bndry or prtct;
if (layer.layer.visible === true && (!(layer.layer.id == "parcels" || layer.layer.id == "bndry" || layer.layer.id == "prtct"))){
lids.push(map.getLayer(layer.layer.id).layerId); //set lids to include all visible facilities
}
})
//click dependent identifyparams
identifyParams.layerIds = lids;
identifyParams.width = map.width;
identifyParams.height = map.height;
identifyParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_VISIBLE;
identifyParams.geometry = anchorPt;
identifyParams.mapExtent = map.extent;
var deferred = identifyTask.execute(identifyParams);
}
deferred.addCallback(function(response) {
//set esri.dijit.PopupTemplate for each layer
});
};
... View more
07-03-2012
05:57 AM
|
0
|
0
|
513
|
|
POST
|
the executeIdentifyTask function is fired from either a map click or grid row click. Since the executeIdentifyTask is responsible for identifying/formatting/displaying popups, I'd like to use the existing executeIdentifyTask to display a popup after a grid row click. If a grid click, I want to display the popup, stripping out any close-by identify results that may have been included. If grid click, I lower the identifyParams.tolerance, but I still pickup a few unwanted results around the facility point geometry that was grid-clicked
dojo.connect(grid1, "onRowClick", onRowClickHandler);
dojo.connect(map,"onClick",executeIdentifyTask);
function onRowClickHandler(evt){
var selectedFac;
//other non-pertinent code
map.centerAndZoom(selectedFac.geometry, 15);
executeIdentifyTask(selectedFac);
}
function executeIdentifyTask(evt) {
var lids = []; //array to hold layer id's to identify
var anchorPt; //facility point, substitute for a mouse click
var siteCode; //id for the grid row that was clicked
var j; //index of response object that was grid clicked
var res; //filtered array of response objects
//lets detect if this was fired by a map click or a grid click
if (evt.mapPoint == undefined){
//grid click, only identify the facility point corresponding to the grid row that was clicked i.e. lower identify tolerance
identifyParams.tolerance = 1;
anchorPt = evt.geometry;
siteCode = evt.attributes.site_code;
//set lids to include only facil layer
lids.push(0);
}
identifyParams.layerIds = lids;
var deferred = identifyTask.execute(identifyParams);
deferred.addCallback(function(response) {
if (!(siteCode == undefined)){
for (var i in response){
var fac = response;
if (fac.feature.attributes.site_code == siteCode){
j = i;
break;
}
}
res = response ;
}
else{
//no filtering the identify response; this was fired by map click
res = response;
}
return dojo.map(res, function(result) {
//if res is set to response , script never gets here, ends at break above <----problem
var feature = result.feature;
//esri.dijit.PopupTemplate's set here
return feature;
}
})
}
any advice would be great! Thanks.
... View more
07-02-2012
10:50 AM
|
0
|
1
|
850
|
|
POST
|
I occasionally get these errors in the manager error log: Method failed.HRESULT = 0x80041251 : This is a FACILITY_ITF error that is specific to the interface that returned this error. See the documentation of the interface that returned this error for information about this HRESULT. Method failed.HRESULT = 0x80070057 : The parameter is incorrect. . The error is recorded when using the identifyTask is fired, which in turn triggers a bunch of relationshipQueries. I put my code below. Usually, clearing rest Cache, restarting the service and refreshing the browser clears the problem. Anyone know what could be happening? Thanks!
function executeIdentifyTask(evt) {
identifyParams.layerIds = lids;
identifyParams.width = map.width;
identifyParams.height = map.height;
identifyParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_VISIBLE;
identifyParams.geometry = anchorPt;
identifyParams.mapExtent = map.extent;
var deferred = identifyTask.execute(identifyParams);
deferred.addCallback(function(response) {
return dojo.map(response, function(result) {
var feature = result.feature;
feature.attributes.layerName = result.layerName;
//setup case switches for each layer
switch(result.layerName){
case "Facilities":
var x = feature.geometry.x;
var y = feature.geometry.y;
var featObjId = feature.attributes.OBJECTID;
//" + getZip(feature.attributes.zip) + "
var tmpCont = "<span>{address}<br/>{facil_location}<br/>" + getZip(feature.attributes.zip) + "Acres: {acres}<br/><br/></span><div id='graphic" + featObjId + "'>{graphicCmdData}</div>";
var relatedBranch = new esri.tasks.RelationshipQuery();
relatedBranch.outFields = ["*"];
relatedBranch.relationshipId = 0; //fac -to- Branch relationshipID
relatedBranch.objectIds = [featObjId];
facSel.queryRelatedFeatures(relatedBranch, function(relatedBranches) {
var branchFound = false;
if(relatedBranches.hasOwnProperty(featObjId) == true){
branchFound = true;
var branchSet = relatedBranches[featObjId];
var cmdBranch = dojo.map(branchSet.features, function(feature){
return feature.attributes;
})
//console.log(cmdBranch);
}
//regardless of whether a branch is found or not, we have to run the cmdMain relationship query
//the parent is still fac, no advantage of the parent being branch since cmcMain query has to be run regardless
//fac - branch - cmdMain - cmdSub <--sometimes
//fac - cmdMain - cmdSub <-- sometimes
var relatedQuery = new esri.tasks.RelationshipQuery();
relatedQuery.outFields = ["*"];
relatedQuery.relationshipId = 1; //fac -to- cmdMain relationshipIP
relatedQuery.objectIds = [featObjId];
//rather then listen for "OnSelectionComplete" we are using the queryRelatedFeatures callback function
facSel.queryRelatedFeatures(relatedQuery, function(relatedRecords) {
var data = []; //this holds our branch - cmdMain - cmdSub data
//if any cmdMain records were found, relatedRecords object will have a property == to the OBJECTID of the clicked feature
//i.e. if cmdMain records are found, true will be returned; and continue with finding cmdSub records
if(relatedRecords.hasOwnProperty(featObjId) == true){
var fset = relatedRecords[featObjId]
var cmdMain = dojo.map(fset.features, function(feature) {
return feature.attributes;
})
//we need to fill an array with the objectids of the returned cmdMain records
//the length of this list == total number of mainCmd records returned for the clicked facility
objs = [];
for (var k in cmdMain){
var o = cmdMain ;
objs.push(o.OBJECTID)
}
//third relationship query to find records related to cmdMain (cmdSub)
var subQuery = new esri.tasks.RelationshipQuery();
subQuery.outFields = ["*"];
subQuery.relationshipId = 2; //cmdMin -to- CmdSub relationshipId
subQuery.objectIds = [objs]
subTbl.queryRelatedFeatures(subQuery)
//we are using the queryRelatedFeatures callback method function(subRecords) fires when the subQuery is complete
//a dojo.connect(subTbl,onSelectionComplete, function) was initially used here but it wasn't disconnecting, so it would fire multiple times
subTbl.queryRelatedFeatures(subQuery, function(subRecords){
//subRecords is an object where each property is the objectid of a cmdMain record
//if a cmdRecord objectid is present in subRecords property, cmdMain has sub records
//we no longer need these objectids, so we'll remove them and put the array into cmdsub
var cmdSub = [];
for (id in subRecords){
dojo.forEach(subRecords[id].features, function(rec){
cmdSub.push(rec.attributes)
})
}
var j = cmdSub.length;
var p;
var sub_key;
var obj;
if (branchFound == true){
var p1 = "branch";
obj1 = {};
obj1[p1] = [cmdBranch[0].Branches]
data.push(obj1)
}
for (var i=0, iLen = cmdMain.length; i<iLen; i++) {
p = cmdMain.ASGMT_Name
obj = {};
obj
= [];
sub_key = cmdMain.sub_key;
for (var j=0, jLen=cmdSub.length; j<jLen; j++) {
if (cmdSub .sub_key == sub_key) {
obj
.push(cmdSub .Long_Name);
}
}
data.push(obj);
}
//set the graphic feature.attributes.Unit_Struc to our formatted cmdData String
var cmdData = formatCmdData(data, featObjId, x, y);
feature.attributes.graphicCmdData = cmdData;
//this handles the display of the first facility record in the popup; feat.attributes.graphicCmdData handles the rest
var tmpSpan = dojo.byId("graphic" + featObjId);
if (tmpSpan != null){
tmpSpan.innerHTML = cmdData;
};
});
}
//since i'm a dumba** and can't figure out a single exit point for this function, we have to add the else clause below...
else {
p = "No Unit Data Available"
obj = {}
obj
= []
data.push(obj)
//set the graphic feature.attributes.Unit_Strucure to our formatted cmdData String
var cmdData = formatCmdData(data, featObjId, x, y);
feature.attributes.graphicCmdData = cmdData;
//this handles the display of the first facility record in the popup; feat.attributes.graphicCmdData handles the rest
var tmpSpan = dojo.byId("graphic" + featObjId);
if (tmpSpan != null){
tmpSpan.innerHTML = cmdData;
};
}
//for some reason the cmd info div was still showing after infoWindow was cosed, this fixes that
dojo.connect(map.infoWindow, "onHide", function() {dojo.destroy("obj" + featObjId);});
})
})
var template = new esri.dijit.PopupTemplate({
title: "{site_code} - {facil_name}",
description: tmpCont,
mediaInfos: [{
"title": "",
"caption": "",
"type": "image",
"value": mediaInfoPhoto(feature.attributes,"Photo_URL")
}]
});
feature.attributes.graphicCmdData = "Processing...";
feature.setInfoTemplate(template);
break;
}
return feature;
});
});
// InfoWindow expects an array of features from each deferred
// object that you pass. If the response from the task execution
// above is not an array of features, then you need to add a callback
// like the one above to post-process the response and return an
// array of features.
map.infoWindow.resize(265,300)
map.infoWindow.setFeatures([ deferred ]);
map.infoWindow.show(anchorPt);
}
... View more
05-23-2012
12:12 PM
|
0
|
0
|
1769
|
|
POST
|
I am very new to webapi, so pardon me if my questions are too simple. I developed a map at arcgis.com with added layers from files. then i developed a webmap using the basic viewer and uploaded it to a webserver. it seems to be working. however the Print function will not work. when I click on it, it will change from Print to Printing then back to Print, but nothing happened. assuming the print button on your web app is using the Print Widget or printTask have a look at this requirement: "requires an ArcGIS Server 10.1 Export Web Map Task." so, perhaps you could add a ref to esri's 10.1 server if you dont' have 10.1 running yet; I'm not sure this is possible though??
... View more
05-08-2012
01:08 PM
|
0
|
0
|
619
|
|
POST
|
i think this is what your looking for hxxp://gis.stackexchange.com/questions/12407/how-to-identify-layers-from-multiple-arcgis-server-instances
... View more
05-08-2012
12:57 PM
|
0
|
0
|
1724
|
|
POST
|
works perfect...after setting var lbls globally.
dojo.connect(map, "onZoomEnd", checkScale);
function checkScale(extent, zoomFactor, anchor, level){
if (level > 7 && level < 16){
lbls.show()
}
else {
lbls.hide()
}
//we can retreive the scale here, but level works just as well
//var scale = esri.geometry.getScale(map)
}
... View more
05-07-2012
08:35 AM
|
0
|
0
|
1375
|
|
POST
|
building html strings can be tricky; use of double vs single quote this should work content+="<td><a href='http://surveyor.slco.org/javamap/mrs_test.cfm?"+layerResults.features.attributes['POINT_NAME']+layerResults.features.attributes['LATITUDE_DD'] + " target='_blank'>Mon. Ref Sheet</a></td>"; In js, you can't have a string containing double quote "; the string has to contain single quote ' like this var str = "<a href='myurl'>text</a>"; // <-- single quotes around href attribute, inside of " "
... View more
05-04-2012
04:19 PM
|
0
|
0
|
1260
|
|
POST
|
In your locomotive query, you need to change the last line from: MPQueryTask.execute(LocQuery, LocSymbology); to: LocQueryTask.execute(LocQuery, LocSymbology); think you forgot to change it to the locomotive query task after you c/p it
... View more
05-04-2012
04:09 PM
|
0
|
0
|
615
|
|
POST
|
it's hard to say for sure what the problem is, but it looks like something's wrong with your config.js fields & aliases objects. Browse to the rest endpoint of this feature layer: MontroseCOfeatures/MapServer/10 and have a look at what the actual field names & aliases, then directly copy/paste these into the fields & aliases objects in config.js I know that a dojox.grid.datagrid store requires that keyField, also defined in config.js be a field with unique values I am adapting the Tax Parcel Viewer from the link below to my map services. The basics are working fine, but the problem appears to be with the InfoWindow. Tax Parcel Viewer The problem is that when I click on a record in the Search (FindTask) results table, the target feature is highlighted on the map (which is good) but the app does not zoom to the feature or show the InfoWindow for that feature as it is supposed to. All this works perfectly fine though if I just click directly on a feature on the map. The problem only occurs when selecting a record in the Search results table. Furthermore, it will work fine from the Search results table if I 'hard code' in the InfoWindow Title text, as opposed to what I want which is to pass in a variable attribute value from the Graphics object. When using Firebug to debug, the app code halts at line 183 - the map.infoWindow.setTitle statement. So something about the infoWindow or infoTemplate, plus the passing of a variable, is not working properly with the results table click event. Any insight would be welcomed. Thanks much. Lee Code attached as Zip files - one Zip has the Index.html and the other Zip has the Common.js and Config.js.
... View more
05-04-2012
03:58 PM
|
0
|
0
|
1010
|
|
POST
|
I filled a new graphics layer with text symbols; one for each point in a feature layer. The below function works fine and the labels are displayed correctly in their +50,+50 offset location, but how do I control the graphics layer visibility based on scale? thanks! function createLabels(){ var queryTask = new esri.tasks.QueryTask("REST url"); var query = new esri.tasks.Query(); query.returnGeometry = true; query.outFields = ["site_code"]; query.where = "site_code LIKE '%'"; queryTask.execute(query, function(featureSet){ map.graphics.clear(); var lbls = new esri.layers.GraphicsLayer(); var font = new esri.symbol.Font("9px", esri.symbol.Font.STYLE_NORMAL, esri.symbol.Font.VARIANT_SMALLCAPS, esri.symbol.Font.WEIGHT_BOLDER); for (var i=0, il=featureSet.features.length; i<il; i++) { var x = featureSet.features.geometry.x + 50; var y = featureSet.features.geometry.y + 50; featureSet.features.geometry.x = x; featureSet.features.geometry.y = y; var graphic = featureSet.features.attributes.site_code; var textSymbol = new esri.symbol.TextSymbol(graphic, font, new dojo.Color([0, 0, 0])); var symb = featureSet.features; symb.setSymbol(textSymbol); lbls.add(symb); }; map.addLayer(lbls); }); }
... View more
05-03-2012
02:38 PM
|
0
|
2
|
3272
|
|
POST
|
adding the onUpdateEnd listener to the last featLayer that's added to the map seemed to do the trick. I also changed to "ONDEMAND" mode.
dojo.connect(map, "onLayerAdd", function(layer) {
//console.log(layer.id);
if(layer.id == "featLayer1"){
ShowLoadingMessage('Loading...'); // <-- fires loading indicator
}
});
var handle = dojo.connect(featLayer3, "onUpdateEnd", function(){
createLabels();
HideLoadingMessage(); <--hides load indicator
dojo.disconnect(handle)
});
... View more
05-03-2012
02:33 PM
|
0
|
0
|
2145
|
|
POST
|
onLayerAdd fires when a layer is added to the map. A layer being added to the map is not the same as all features being visible on the map. Ideally, your features would load fast enough that you don't need to show a loading icon. If that's not the case, look at using your layers' onUpdateEnd event. You could set up a listener for this event and then disconnect the listener after the event fires the first time. To do this for multiple layers, you could check each layer's updating property. When all updating is false for all your feature layers, you would hide your loading icon and disconnect your event listener using dojo.disconnect. thanks for the reply. I noticed that when the featlayer is added to the map a RestURL/layerID/query? call is made to the server. It looks like the features aren't actually displayed until the query is returned from the server, which in my case takes awhile because some of the featlayers have >1K records. I'll try this out and report back...
... View more
05-03-2012
09:39 AM
|
0
|
0
|
2145
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 3 weeks ago | |
| 2 | 06-19-2026 05:33 AM | |
| 1 | 05-02-2024 04:44 PM | |
| 1 | 11-04-2025 11:45 AM | |
| 1 | 10-31-2025 06:53 AM |
| Online Status |
Offline
|
| Date Last Visited |
Friday
|