|
POST
|
Hi I am trying to implement a toolbar with identify and draw functions initially on it but am having some problems. When I activate the identify tool for the first time it works fine, but if I were to change to the draw tool then back to the identify tool, my infowindow does not pop up, firebug gives me the following message:- TypeError: Cannot call method 'setContent' of undefined{...} There appears to be an issue specifically with how I am setting my content to show but am not too sure why it would initially work, then fail on the next call. Can anyone see any problems with the below code? I am just including how the tool is activated and the identify function so if other bits are required I can post these up. Many thanks! //CODE TO SET THE DIFFERENT TOOLS function turnidTool(ident) { idTool = ident; if (idTool==0) { if (drawHandle!=null) { dojo.disconnect(drawHandle); drawHandle = null; } if (identifyHandle!=null) { dojo.disconnect(identifyHandle); resetFunctionality(); identifyHandle = null; } } if (idTool==1) { if (drawHandle!=null) { dojo.disconnect(drawHandle); drawHandle = null; } if (identifyHandle==null) { identifyHandle = dojo.connect(map, "onClick", doIdentify); } } if (idTool==2) { if (identifyHandle!=null) { dojo.disconnect(identifyHandle); resetFunctionality(); identifyHandle = null; } if (drawHandle==null) { drawHandle = dojo.connect(map, "onClick", doDraw); } } } //CODE FOR THE IDENTIFY TOOL function resetFunctionality() { identifyTask = null; identifyParams = null; symbol = null; } function initFunctionality(map) { if (drawHandle!=null) { dojo.disconnect(drawHandle); drawHandle = null; } identifyTask = new esri.tasks.IdentifyTask("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/BloomfieldHillsMichigan/Parcels/MapServer"); identifyParams = new esri.tasks.IdentifyParameters(); identifyParams.tolerance = 3; identifyParams.returnGeometry = true; identifyParams.layerIds = [0,2]; identifyParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_ALL; identifyParams.width = map.width; identifyParams.height = map.height; map.infoWindow.resize(400, 250); map.infoWindow.setContent(dijit.byId("tabs").domNode); map.infoWindow.setTitle("Identify Results"); symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255,0,0]), 2), new dojo.Color([255,255,0,0.25])); } function doIdentify(evt) { if (identifyParams==null) { initFunctionality(map); } map.graphics.clear(); identifyParams.geometry = evt.mapPoint; identifyParams.mapExtent = map.extent; identifyTask.execute(identifyParams, function(idResults) { addToMap(idResults, evt); }); } function addToMap(idResults, evt) { bldgResults = {displayFieldName:null,features:[]}; parcelResults = {displayFieldName:null,features:[]}; for (var i=0, il=idResults.length; i<il; i++) { var idResult = idResults; if (idResult.layerId === 0) { if (!bldgResults.displayFieldName) {bldgResults.displayFieldName = idResult.displayFieldName}; bldgResults.features.push(idResult.feature); } else if (idResult.layerId === 2) { if (!parcelResults.displayFieldName) {parcelResults.displayFieldName = idResult.displayFieldName}; parcelResults.features.push(idResult.feature); } } dijit.byId("bldgTab").setContent(layerTabContent(bldgResults,"bldgResults")); dijit.byId("parcelTab").setContent(layerTabContent(parcelResults,"parcelResults")); map.infoWindow.show(evt.screenPoint, map.getInfoWindowAnchor(evt.screenPoint)); } function layerTabContent(layerResults, layerName) { var content = ""; switch (layerName) { case "bldgResults": if (bldgResults.features.length !== 0){ content = "<b>Building Footprints</b></br>"; content += "<i>Total features returned: " + layerResults.features.length + "</i>"; content += "<table border='1'><tr><th>ID</th><th>Address</th></tr>"; for (var i=0, il=layerResults.features.length; i<il; i++) { content+="<tr><td>"+layerResults.features.attributes['PARCELID']+" <a href='#' onclick='showFeature(" + layerName + ".features[" + i + "]); return false;'>(show)</a></td>"; content+="<td>"+layerResults.features.attributes['Full Site Address']+"</td>"; } content+="</tr></table>"; } break; case "parcelResults": if (parcelResults.features.length !== 0){ content = "<b>Tax Parcels</b></br>"; content += "<i>Total features returned: " + layerResults.features.length + "</i>"; content += "<table border='1'><tr><th>ID</th><th>Year Built</th><th>School District</th><th>Description</th></tr>"; for (var i=0, il=layerResults.features.length; i<il; i++) { content+="<tr><td>"+layerResults.features.attributes['Parcel Identification Number']+" <a href='#' onclick='showFeature(" + layerName + ".features[" + i + "]); return false;'>(show)</a></td>"; content+="<td>"+layerResults.features.attributes['Residential Year Built']+"</td>"; content+="<td>"+layerResults.features.attributes['School District Description']+"</td>"; content+="<td>"+layerResults.features.attributes['Property Description']+"</td>"; } content+="</tr></table>"; } break; } return content; } Seems like you have two event handlers dealing with onclick event. It would be much easier to have one handler to dealing with two click scenarios, that way you don't have to connect one event and disconnect another. All the actions can be easy handled in one handler. Something like: var actionMode =0; //globle variable, default as do nothing .... dojo.connect(map, "onClick", clickAction); .... function clickAction (evt) { switch (actionMode) { case 0: return; //break; case 1: doIdentify(); break; case 2: doDraw(); break; } } .... function turnidTool(ident) { actionMode =ident; } Hope this code snippets make sense to you.
... View more
06-03-2011
06:39 AM
|
0
|
0
|
804
|
|
POST
|
When you create a BaseMapLayer using the type argument, e.g. esri.dijit.BasemapLayer({ type: "OpenStreetMap" }); there does not seem to be any way to get the thumbnail url for that type. Is the only choice to hardcode the url? Is there some way to retrieve the appropriate url and use it when creating a basemap from that basemap layer? This is part of a project to update my widgit of a dijit.layout.ContentPane with an embedded map object and now an embedded gallery. I would like the addBasemap layer function on that widget to be able to accept a basemap layer type as an argument, but it looks a bit dumb when the thumbnail is blank. Maybe this is not you are looking for, i think this esri sample might give me some clue: http://help.arcgis.com/EN/webapi/javascript/arcgis/demos/widget/widget_basemapsthumbnail.html
... View more
06-02-2011
01:06 PM
|
0
|
0
|
1570
|
|
POST
|
Hi, I have a spatial layer which is join with a table, therefore all the field name will be in substring like PAD.LP_PD.OBJECTID. I have no issue to run query from the substring, but i am stuck at function to zoom to selected feature/polygon when user click a row in datagrid(result from query). Below is the code: //Zoom to the parcel when the user clicks a row function onRowClickHandler(evt){ var OBJECTID = ("PAD.LP_PAD.OBJECTID"); var clickedTaxLotId = grid.getItem(evt.rowIndex).OBJECTID; var selectedTaxLot; dojo.forEach(map.graphics.graphics,function(graphic){ if((graphic.attributes) && graphic.attributes.OBJECTID === clickedTaxLotId){ selectedTaxLot = graphic; return; } }); var taxLotExtent = selectedTaxLot.geometry.getExtent(); map.setExtent(taxLotExtent); } I have tried using this declaration: var clickedTaxLotId = grid.getItem(evt.rowIndex).(PAD.LP_PAD.OBJECTID); var clickedTaxLotId = grid.getItem(evt.rowIndex).valueOf(PAD.LP_PAD.OBJECTID); but those two declaration will take the whole result in datagrid, not the exact selected row. Please advice.. Suggestion is highly appreciated. Try this: either change clickedTaxLotId = grid.getItem(evt.rowIndex).OBJECTID to clickedTaxLotId = grid.getItem(evt.rowIndex).OBJECTID[0], or loose up the comparsion graphic.attributes.OBJECTID === clickedTaxLotId to graphic.attributes.OBJECTID == clickedTaxLotId
... View more
06-02-2011
05:20 AM
|
0
|
0
|
988
|
|
POST
|
I'm seeking some advice on best practices for handling datasets with hundreds of attributes. (I made a typo in the subject of this thread - the attributes would be part of the featureclass, not joined to it.) I'm building some polygon featureclasses from raw census tables, which contain hundreds of fields. I'd like to leave all of the attributes on the featureclasses (rather than stripping off the ones I don't currently need), so I can be flexible about which attributes to show at a later date. Does anyone have any advice on how this will affect performance? 1) is it a bad idea to have a file geodatabase featureclass with hundreds of attributes? 2) is it a bad idea to create a map service from this featureclass, containing hundreds of attributes? 3) is there a performance implication if I build a featureLayer in the JS API, and only specify the attributes I currently need? eg, the map service might contain 500 attributes, but I define my feature layer using featureLayer.fields = [x, y, z] Thanks for any advice, and please let me know if you need any further details. Steve Very good questions. Be nice to see more discussion about these. Here are my thoughts and reads 1) is it a bad idea to have a file geodatabase featureclass with hundreds of attributes? Not that i know of except a file geodatabase featureclass allows only one user at a time can edit the same data. So no editable feature layer allowed. 2) is it a bad idea to create a map service from this featureclass, containing hundreds of attributes? map service include not only the geometries but also the attributes. It would properly be better to make only needed field visible in your .mxd or msd to cut the traffic volumn between server and client. 3) is there a performance implication if I build a featureLayer in the JS API, and only specify the attributes I currently need? I think the No. of records in a featureclass is more of a x factor than the No. of fields in a featureclass while building a featureLayer. In terms of the No. of attributes, see Quotes from the ESRI: "....feature layers bring geometry information across to the client computer to be drawn by the Web browser. Feature layers potentially cut down on round trips to the server. A client can request the features it needs, then perform selections and queries on those features without having to request more information from the server. Feature layers are especially appropriate for layers that respond to user interaction, such as a mouse click or hover." Choosing the attributes you need "Feature layers not only retrieve feature geometries; they can also get attribute information. When you create the feature layer, you can specify which attributes, or "out fields" will be retrieved for your features. It's possible to just request "*" to get all the fields, but to reduce the amount of information sent between the client and server, you should request only the fields you need in your application. If you later perform a query using the feature layer, the query will honor the out fields you set."
... View more
06-01-2011
09:56 AM
|
0
|
0
|
509
|
|
POST
|
Chris, I haven't experienced issues with absolutely positioned divs at 1.6. If you'd like to post the code you are having problems with I'd be happy to take a look? One thing i did to workaround this is to put all the other none region divs within BorderContainer's region ContentPane such as mapGallery in map ContentPane (region="center") etc.
... View more
06-01-2011
08:59 AM
|
0
|
0
|
1077
|
|
POST
|
I am also curious how to modify this widget. I want to change the text size of the drop down menu (ie: where it says Miles, kilometers, etc) as well as shrink down some other elements of it. I cant figure out the CSS to change in order to modify the measurement widget beyond changing what the icons are. Given that the JS API for measurement list very few properties, events and methods. It does not have super class, It really cannot do much modification except change the appearence of the icons such as remove the location icon: .locationIcon { display: none; }. It would be interesting to see ESRI's input on this.
... View more
06-01-2011
06:59 AM
|
0
|
0
|
2897
|
|
POST
|
Hi hzhu, Thank you very very much for your code. it work now. 🙂 Another question, after i added that featurelayer, how could i retrieve it? i don't know which object should be used, "map" or "esri". i mean i want to get that polygon in a event. thanks again, Mike Mike, you already have an event handler in your code: //associate the features with the popup on click dojo.connect(featureLayerPolygon, "onClick", function (evt) { //evt.graphic will be the polygon feature you clicked at. //evt.graphic.geometry will the polygon itself you clicked at map.infoWindow.setFeatures([evt.graphic]); map.infoWindow.show(evt.mapPoint); }); Besides that, you can look at the featurelayer library and pick up any event that fits your need: http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi/featurelayer.htm
... View more
06-01-2011
06:20 AM
|
0
|
0
|
1392
|
|
POST
|
Hi there, I'm curious if there's a method in the JS API v2.2 that will return back the URL of the current state of the map? For instance, in Google Maps, you can click "Link" at the top, and it will give you an URL that will take you directly to the map as you were viewing it, with all the appropriate parameters. (http://maps.google.ca/?ie=UTF8&ll=49.891235,-97.15369&spn=31.500974,79.365234&t=h&z=4) Forgive me if this is a novice question... but I am a novice! Any insight would be greatly appreciated. esri.layers.Layer.url and esri.dijit.BasemapLayer.url will cover all the esri layers that are added to the map. Are these properties you are looking for?
... View more
05-31-2011
01:07 PM
|
0
|
0
|
677
|
|
POST
|
Hi hzhu, Thanks a lot for your code. But it still doesn't work. Thanks again. Mike, since i don't have your complete code, i modified the ESRI sample (http://help.arcgis.com/en/webapi/javascript/arcgis/demos/fl/fl_featureCollection.html) a little bit to include your posted code. It worked. Maybe there are something else in your code (webmap?) that you need look into.
... View more
05-31-2011
12:38 PM
|
0
|
0
|
1392
|
|
POST
|
Please elaborate on what you've tried and what, specifically, is failing. mike, a couple of issues in your function requestPolygon(itemInfo). 1. features is undefined. 2. the attributes of the feature you added to your featureLayerPolygon are missing. Try this: function requestPolygon(itemInfo) { var polygonSymbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_DOT, new dojo.Color([151, 249, 0, .80]), 3), new dojo.Color([151, 249, 0, 0.45])); var polygon = new esri.geometry.Polygon({ "rings": [ [ [-4226661.916056009, 8496372.808143634], [-3835304.3312360067, 8731187.359035634], [-2269873.991956003, 9005137.668409634], [-4304933.433020009, 7635386.121539632], [-4304933.433020009, 7674521.880021632], [-4226661.916056009, 8496372.808143634] ] ], "spatialReference": { "wkid": 102100 } }); var attr = {}; attr["description"] = your description string; attr["title"] = your title string; featureLayerPolygon.applyEdits([new esri.Graphic(polygon, polygonSymbol, attr)], null, null); }
... View more
05-31-2011
11:34 AM
|
0
|
0
|
1392
|
|
POST
|
Heming Zhu, thank you so much! That worked with just a little change to make 'isEditable' false instead of true. Luckily I was able to figure out exactly where those lines of code needed to go. A text area now displays for existing points when you click on them which is great. A text area does not display when a user is creating a new point. While it would be great to have a text area there too, I'm just so thrill to have everything working that I may just leave well enough along. Derek Swingley, thank you as well! Your method on stack exchange worked as well - exactly as Heming's method did, only I didn't have to change 'isEditable' to false... it was already done for me. As I mentioned earlier, I'll leave well enough alone and not worry about how the info window appears when creating a new point. If it's an easy fix, please let me know. The code i provided came from part of my code. I should change a little bit to fit your need (isEditable: false). Sorry for the confustion i caused. I attached a file which is a modified ESRI sample you mentioned. Pay attention to the highlighted portion. It should allow you to add a feature with text area field.
... View more
05-26-2011
07:52 AM
|
0
|
0
|
2320
|
|
POST
|
Hi Derek, I did see that example, but where would I put one of those lines of code if using the sample I mentioned? I tried adding it in a few places, customizing it to reflect the correct field name, but nothing worked for me. (http://help.arcgis.com/en/webapi/javascript/arcgis/demos/ed/ed_multipleAttrInspector.html) var fieldInfos= dojo.map(layer.fields,function(field){ if (field.name === 'description') { return {'fieldName': field.name,'label':'Details',stringFieldOption:esri.dijit.AttributeInspector.STRING_FIELD_OPTION_RICHTEXT} } else{ return {'fieldName': field.name,'lable':field.alias} } }); var layerInfos = [{ 'featureLayer': layer, 'isEditable': true, 'fieldInfos':fieldInfos }] var attInspector = new esri.dijit.AttributeInspector({ layerInfos: layerInfos }, dojo.create("div"));
... View more
05-25-2011
07:48 AM
|
0
|
0
|
2321
|
|
POST
|
Does anyone know the simplest way to return the closest point on a polyline to an input point using the javascript api with/without a geometry service? Perhaps I need to publish my own geoprocessing service to best achieve this functionality? Any pointers would be useful...thanks I don't think the geometry service provide such functionality. Best approach might be to create a gp service that include a modified version of Spatial Join system tool (Match Option set up as CLOSEST) to serve your puopose.
... View more
05-24-2011
09:18 AM
|
0
|
0
|
2698
|
|
POST
|
Hi Heming, Thank you very much for the help! Now it works as required. The only thing that is left is to figure out how the routing can work based on the address and not only on the postcode. I guess you have not noticed that if you choose to route between addresses with the same postcode, the route is not calculated. You might try to enter as an input and an output points the addresses below: 20 Parkvagen, Gavle, 80267, Sweden and 1 Parkvagen, Gavle, 80267, Sweden As you'd see in the Directions window, the route starts at 80267 and ends at 80267. That is, the solver does not parse the addresses properly. If you could take a look at this problem, I would really appreciate this. But, again, this is not a big deal, that is still good enough for testing purposes. Thank you again for the help, Heming, much appreciated. It's rather the locator then the solver (you can debug it). One work around is replace the begin and end directions description with from and end address (The begin and end stop point are accurate address points. i recalled this is what i did in one of my project).
... View more
05-20-2011
07:16 AM
|
0
|
0
|
1144
|
|
POST
|
I've now solved this issue and it turns out it was very simple! All the ESRI documentation that I've read tells you to apply the claro class to the body tag, but actually, I only need to apply it to the map div. It's one of those things that is so simple, you over look it. I am glad that you find your solution. It is logical because most of the components (slider, scale bar, pan arrow) are with the map. However, if you are using toolbar, attribute inspector, template picker etc or some other dojo coponents datagrid etc, you still need to style them. A common way is to apply the css to the body tag.
... View more
05-20-2011
05:34 AM
|
0
|
0
|
1926
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 04-11-2011 12:16 PM | |
| 1 | 05-25-2017 08:26 AM | |
| 1 | 06-02-2017 07:37 AM | |
| 1 | 06-28-2011 07:02 AM | |
| 1 | 06-12-2017 10:10 AM |
| Online Status |
Offline
|
| Date Last Visited |
10-01-2024
09:57 PM
|