|
POST
|
I'm not sure if you're aware but the api reference (the tab right next to the samples tab) has a wealth of information. Here's what it says: MODE_SELECTION In selection mode, features are retrieved from the server only when they are selected. Features are available on the client only while they are selected. To work with selected features: Call the selectFeatures method. Listen for the onSelectionComplete event. Once onSelectionComplete fires, retrieve the selected features using the getSelectedFeatures method. When editing feature layers in selection mode, you will need to add the map service associated with the feature service to the map as a dynamic map service. After modifying features, listen for the onEditsComplete event and manually refresh the associated dynamic map service layer so the modified features are rendered. If you do not have the map service added as a dynamic map service then the changes will not be visible because once the edits are complete the feature is no longer selected. MODE_SNAPSHOT In snapshot mode, the feature layer retrieves all the features from the associated layer resource and displays them as graphics on the client. Definition expressions and time definitions are honored. The features are retrieved once the feature layer is added to the map. After the onUpdateEnd event has fired, you can access the features using the graphics property of the layer or through selection and query operations. Nothing shows up in selection mode because you haven't selected any features. Note that it MODE_SELECTION requires you to add the layer as a dynamic layer too.
... View more
06-05-2012
08:16 PM
|
0
|
0
|
956
|
|
POST
|
Are you wanting the geometry and attributes for a gis purpose or just to save them for the user in a more permanent form than local storage? If it's the latter, I suggest using php and mysql to store and retrieve data. I use them so users can save maps, graphics, bookmarks and more. This approach does require some form of authentication for the application. The basic concept involves using dojo's xhrGet, xhrPost, toJson and fromJson on the front-end, and php (php has great json capabilities) & mysql on the back-end. Serialize objects with dojo on the front-end, post and save on the back-end. Retrieve them as needed and use the returned information to return a map to a previous state, recreate graphics, etc. In my opinion it's easier and more functional for such things. One of my newest features (the client who's testing it for me in their application loves it) is the ability to move and size the regions (i.e. map, controls, toolbar, etc) just like ArcMap. Not only is the map, it's layer state and user graphics just as it was last time they used it, so is the individual user's preferred layout of the application. It sounds like you have access to AGS, but it is possible to build a GIS data store with mysql. Mysql does have geometry field types. The JSAPI can be used to add feature layers, query, find, identify, etc from any url that returns json in the proper format. I've even seen dynamic layers returned with php and mysql; albeit slow and graphically unappealing. That's my broad, non-technical take. If it's of no help, my apologies; but whatever your goal and however you end up there, good luck.
... View more
06-05-2012
04:22 PM
|
0
|
0
|
1236
|
|
POST
|
I'm not sure. I checked some of my map services and they all have drawing info. I don't have any proportional symbology for any of them so I'm not sure if AGS supports it or not. Bad mxd or msd? What about a custom renderer in jsapi? Just ideas. Do post an answer here when you figure it out. Good luck.
... View more
06-05-2012
10:17 AM
|
0
|
0
|
933
|
|
POST
|
Did setting outFields to just the ones you want work?
... View more
06-05-2012
09:32 AM
|
0
|
0
|
933
|
|
POST
|
Check out http://dojotoolkit.org/reference-guide/1.7/dojo/io/script.html#dojo-io-script All my apps are module based, pulling snippets and code from my server; consequently I make a ton xhrGet and xhrPost requests and have always used a proxy. I'm in the process of converting all my apps to dojo 1.7 in anticipation of jsapi v3, and will be doing more with io-script.
... View more
06-05-2012
09:07 AM
|
0
|
0
|
2387
|
|
POST
|
Try: var cntryLyr = new esri.layers.FeatureLayer("http://sdnarc.worldbank.org/SDNARC/rest/services/benMisc/AfricanPowerPlants/MapServer/1",{
mode: esri.layers.FeatureLayer.MODE_ONDEMAND,
infoTemplate: infoTemplate,
outFields: ["*"]
}); I'm not sure, but mode might be a required param. I never not used it.
... View more
06-05-2012
08:32 AM
|
0
|
0
|
933
|
|
POST
|
When you add a dynamic layer the api makes a rest call to the map service (http://MY_URL/ArcGIS/rest/services/MY_MAP_SERVICE/MapServer?f=json) which includes sub-layer information but not detailed sub-layer info like extent. The only way to get a sub-layer's extent to to make some some kind of rest call on said sub-layer (http://MY_URL/ArcGIS/rest/services/MY_MAP_SERVICE/MapServer/0?f=json). Creating a feature layer is one way, but a lot of work just to get the extent.
... View more
06-05-2012
08:26 AM
|
0
|
0
|
2387
|
|
POST
|
The code looks good. I went to check the map service but that's a 404 url.
... View more
06-05-2012
08:13 AM
|
0
|
0
|
933
|
|
POST
|
Individual layers in a map service have an extent but I don't see where dynamic layer creates an object for for it. You could always make a rest call to the layer and get it's extent: var getLayerExtent = dojo.xhrGet({
url: 'http://MY_URL/ArcGIS/rest/services/MY_MAP_SERVICE/MapServer/0?f=json',
handleAs: 'json',
load: function(r) {
var extent = r.extent;
//zoom to it
}
);
... View more
06-05-2012
08:06 AM
|
0
|
0
|
2387
|
|
POST
|
You cannot change opacity of sub-layers independently. Opacity only applies to the entire layer. The reason is that AGS creates an image with all visible layers (a composite) every time the map extent changes and places that image as a div in the map's domNode. The opacity of the layer is simply the image's opacity. The api uses the setOpacity method on the layer's domNode. If you gave your layer a unique id, you can change opacity using dojo.style by finding the div in the HTML in firebug. But why? The good folks at esri gave us setOpacity. The earthquake map uses two separate map services. The solution is to split layers into multiple map services, or initiate multiple map layers from the same service and set visible sub-layers for each onLoad and then control opacity.
... View more
06-01-2012
03:06 PM
|
0
|
0
|
1163
|
|
POST
|
This is one method I use to add dijits to infoWindow template. This example loads a feature layer as part of the apps onLoad from a js object. The concept is the same for your needs. Here's the object:
{
type: 'feature',
requireToken: true,
url: 'http://SOME_URL/ArcGIS/rest/services/SOME_TOWN_IN_OREGON/Fire_Hydrants/MapServer/0',
name: 'Fire Hydrants',
id: 'fire_hydrants',
outFields: ['*'],
itTitle: 'Hydrant',
itContentType: 'function', //'function' or 'text'
itContent: '',
itContentFunction: 'hydrant',
visible: false,
opacity: 1,
legend: true,
toc: true,
info: false,
infoHtml: ''
} When it runs through this loop we set up the infoTemplate. dojo.forEach(config.featureLayers, function(fl) {
var url;
if (fl.requireToken == true) {
url = fl.url + '?token=' + config.app.token
} else {
url = fl.url
}
var it = new esri.InfoTemplate();
it.setTitle(fl.itTitle);
if (fl.itContentType == 'text') {
it.setContent(fl.itContent);
} else if (fl.itContentType == 'function') { //turns out we want some dijits in our infoWindow
eval('it.setContent(viewer.itContentFunctions.' + fl.itContentFunction + ')') //set the content via a function; in this case viewer.itContentFunctions.hydrant; see below
} else {
it.setContent('There must not be any important info about this feature.');
}
var layer = new esri.layers.FeatureLayer(url, {
mode: esri.layers.FeatureLayer.MODE_ONDEMAND,
outFields: fl.outFields,
infoTemplate: it,
id: fl.id,
visible: fl.visible,
opacity: fl.opacity
});
if (fl.legend == true) { viewer.legendLayers.push({ layer: layer, title: fl.name }) }
var info = '';
if (fl.info == true) {
info = fl.infoHtml
}
//toc controls
viewer.map.addLayer(layer);
}); At this point the template is just a domNode and has not been rendered in a container object yet. Now when we click on a hydrant the infoWindow popups up because the graphic has a template, with that specific graphic's template domNode appearing in said infoWindow. In this example a function is connected to the buffer button's onClick event, which when clicked buffers the hydrant the specified distance and adds the geometry to the map. [ATTACH=CONFIG]14868[/ATTACH] var viewer = {
itContentFunctions: {
hydrant: function(graphic) {
var x = Math.round(Math.random() * 1000000);
var content = new dijit.layout.ContentPane({ style: 'padding:0;', content: '<div style="padding-bottom:6px;">Buffer this hydrant:</div><div id="hydrant_buffer_dist_' + x + '" dojoType="dijit.form.NumberSpinner" value="500" smallDelta="25" contraints="{min:100,max:1200,places:0}" style="width:80px;"></div> <div id="hydrant_buffer_button_' + x + '" dojoType="dijit.form.Button">Buffer</div>' });
dojo.connect(dijit.byId('hydrant_buffer_button_' + x), 'onClick', function() { viewer.itContentFunctions.hydrantBuffer(graphic.geometry, x); viewer.map.infoWindow.hide(); /* viewer.mapTipsShow('<img src="images/waiting_map_tips.gif" style="height:14px; width:14px;" /> Buffer in progress...');*/ });
return content.domNode;
},
hydrantBuffer: function(geom, id) {
viewer.map._layers.gl.clear();
var params = new esri.tasks.BufferParameters();
params.geometries = [geom];
params.distances = [eval('parseInt(dijit.byId("hydrant_buffer_dist_' + id + '").value)')];
params.unit = esri.tasks.GeometryService.UNIT_FOOT;
params.outSpatialReference = viewer.map.spatialReference;
viewer.geoSrv.buffer(params, function(geoms) {
//viewer.mapTipsHide();
var symbol = new esri.symbol.SimpleFillSymbol('solid', new esri.symbol.SimpleLineSymbol('solid', new dojo.Color([0, 0, 255]), 2), new dojo.Color([0, 0, 255, 0.25]));
dojo.forEach(geoms, function(geometry) {
var graphic = new esri.Graphic(geometry, symbol, { ID: '7', __print: true, __whatAmI: 'a hydrant buffer', __addToMapSave: false, __style: { who: 'mxdSelect' }, __db: 'schema.gdb', __sdeDump: config.app.dumpUserGraphicsToSde });
viewer.map._layers.gl.add(graphic);
viewer.map.setExtent(graphic.geometry.getExtent(), true);
});
});
}
}
} Here's the buffered hydrant: [ATTACH=CONFIG]14874[/ATTACH] Notice that I created a ContentPane and it's content in html. All the content could be created programmatically, but with simpler items it's easier to create a ContentPane and use it's content property. In your case, where you may have multiple tasks executing, a TabContainer and tabs I would probably build my own dijit (see No. 2 & 3 below). You said you were just getting started. I don't know what your long term goals are, but if the shoe fits: 1) The arcgis js api just extends dojo. An above average understanding of how dojo works is important. http://dojotoolkit.org/documentation/ The reference guide and documentation are indispensable, as is the API reference. 2) Use Firefox for development with Firebug add-in. Use Firebug to dissect every last corner of the DOM related to the esri classes. 3) Creating modules, custom dijits, and working from a programmatic view point will make your life easier. For example, I've used the same custom measuring module for years. With two lines of code I can load the module and place it anywhere in the application (e.g. a tab, accordion pane, floating pane, etc). The three files for the module only exist once on my server. Write once, use many. Easy to update. Company A and Company B both have intranet web apps, but the measure module comes from the same place every time someone initiates its use. This same idea allows me to choose the api version for every app I have deployed by changing a single variable in one file on my server. When a new version comes out I test it out in the development environment and if there's no problems I update all my apps at once, by changing 2.7 to 2.8 for example. 4) All my apps' index.html look like this: [HTML]<!DOCTYPE HTML> <html> <head> </head> <body> </body> </html>[/HTML] The rest is programmatic. Many of my apps have measuring capabilities, but the module and the controls are only downloaded when the user first uses the module. This on-demand method keeps the app lean and quick. The code samples above come from a app I'm currently working on that has 20+ dynamic layers, 5+ feature layers, more tasks than I can count and 28 geoprocessing tasks. If I had to load all that onLoad it would take forever to load and be slow. Not to mention taxing on bandwidth. Well Jeremy, I hope I didn't confuse you. I never post on the forum, but I noticed your post just as I was finishing up the hydrant buffer and thought I might weigh in for once. Good luck!
... View more
06-01-2012
02:36 PM
|
0
|
0
|
1513
|
|
POST
|
var query = (qu).split(' ').join('%');
if (query == '') {
dojo.byId('parcel_search_info').innerHTML = '<span style="color:#900;">You must enter a search value. Try again.</span>'
} else if (new String(query).length < 3) {
dojo.byId('parcel_search_info').innerHTML = '<span style="color:#900;">Searchs must contain at least 3 characters. Try again.</span>'
} else {
dojo.byId('parcel_search_info').innerHTML = '<img src="images/waiting.gif" /> Searching...';
var qt = new esri.tasks.QueryTask(config.parcelQueryUrl + '?token=' + config.app.token);
var q = new esri.tasks.Query();
q.returnGeometry = true;
q.outFields = config.parcelQueryOutFields;
q.where = "UPPER(PID) like '%" + query.toUpperCase() + "%' or UPPER(ADDRESS) like '%" + query.toUpperCase() + "%' or UPPER(OWNER) like '%" + query.toUpperCase() + "%'";
qt.execute(q, function(results) {
if (results.features.length == 0) {
dojo.byId('parcel_search_info').innerHTML = '<span style="color:#900;">Sorry, but your search did not return any parcels. Try again.</span>'
} else if (results.features.length > 120) {
dojo.byId('parcel_search_info').innerHTML = '<span style="color:#900;">Sorry, but your search returned too many parcels. Try again.</span>'
} else {
//build grid
}
})
} [HTML]<h3>Enter Parcel ID (PID), address or owner</h3> <form action="javascript:viewer.parcelSearch()"> <input id="parcel_search_value" dojoType="dijit.form.TextBox" placeholder="PID, address or owner" style="width:250px; font-size:14px;" /> <br /> <div dojoType="dijit.form.Button" iconClass="iconSearch" type="submit" style="margin-top:8px;">SEARCH</div> </form> <div id="parcel_search_info" style="margin-top:4px;"></div>[/HTML] This is a query, but the same principle. Other point of info options include a dialog, tooltip, js alert, etc. I saw a pretty cool one the other day that displayed info in the textbox itself with different colored text.
... View more
06-01-2012
09:28 AM
|
0
|
0
|
469
|
|
POST
|
esri.virtualearth.VETiledLayer was having a problem. It started around 7pm PST and ended 11:15pm. Apps with a VE layer weren't loading. The GET to http://serverapi.arcgisonline.com/veadaptor/production/services/imagery/getmetadata?token= (token and callback of url removed) was throwing the following error after timing out: error: "500", message: "The remote name could not be resolved: 'dev.virtualearth.net'", details: []. After that failed the following came up in console: Component returned failure code: 0x80004003 (NS_ERROR_INVALID_POINTER) [nsIDOMHTMLDivElement.removeChild]. esri.Map crashes while the rest of app loads normally. My apps locally and remotely across several servers; both desktop and mobile were having the issue. The VE Layer sample at the API, other samples and code gallery apps with VE were experiencing the same issue. Thought you guys on the back-end should know. Keep up the good work.
... View more
05-31-2012
10:37 PM
|
0
|
0
|
782
|
|
POST
|
Hey ArcGIS API for JavaScript Team, The color palette isn't displaying properly in v2.3. The color chips are not filling the td fully, just coloring the 1x1 img. Changing back to v2.2 works fine. It's not an issue with css. I use dojo css from google cdn. Tried using api's css and switching versions. Same result. Could you please take a look at this. Switched all my apps to v2.3 this week and had to switch back after client complaints. Thanks, btfou
... View more
06-18-2011
12:20 PM
|
0
|
0
|
527
|
|
POST
|
Google and ESRI are in some kind of GIS power struggle. I'm not sure what it's about. I suppose you could find some answers on the internet. I asked an ESRI rep about it at a class and the very question made him uncomfortable. You will note that the ArcGIS JS API can consume Bing's map tiles. This is how I see it; ESRI and Microsoft are friends while Google and Microsoft aren't, and all of them are tech giants. Draw your own conclusions. ArcGIS Extension for the Google Maps API is simple and beautiful, however it has some limitations. Concerning GMaps v3, the API itself has changed to MVC and is hard to work with for in-depth GIS web app development. Google Code has a code library called google-maps-utility-library-v3 which can be found here. While it works well for adding dynamic layers, etc; it has some problems. The biggest one is you cannot print maps with overlays on. I suppose it works well enough for simple maps. I personally wouldn't spend a second with it, unless you like being disappointed. I've been deploying ArcGIS Server and building full functioning web-based GIS applications for a few years now. Here's my advice: switch to ArcGIS JS API or Flex. Both are way more powerful. ArcGIS JS API is particularly powerful when deployed with asp.net instead of just html. Even better if your data is stored in ArcSDE. The web-based GIS application possibilities are endless. But you say you want GMap tiles? You can have it. Find a library here that allows you to consume Gmap tiles with ArcGIS JS API. This is a simple example. To make it work well in a complex application you have to apply some tweaks.
... View more
04-06-2011
02:44 PM
|
0
|
0
|
1200
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 06-18-2013 06:56 AM | |
| 1 | 06-30-2015 09:17 AM | |
| 1 | 10-12-2013 07:14 AM | |
| 1 | 02-05-2014 11:05 AM | |
| 1 | 05-28-2015 11:41 AM |
| Online Status |
Offline
|
| Date Last Visited |
11-11-2020
02:23 AM
|