|
POST
|
Have you tried setting the doLayout property of the StackContainer to false? This sets the size of the container to the size of the selected child pane. All of your panes would need to be 100% x 100%. I have never tried it in a mobile layout. It might not work, but then again it might.
... View more
06-18-2013
12:29 PM
|
0
|
0
|
1385
|
|
POST
|
1. Try using dijit/layout/BorderContainer with the toolbar as the top region and map as the center region. This is the best way to get a dynamically sized map. 2. Always use #map { overflow:hidden; } to remove scrollbars from map no matter what you do for layout.
... View more
06-18-2013
06:56 AM
|
1
|
0
|
1442
|
|
POST
|
I have all but given up on switch. Kept running into unexplained problems. This is out of an identify task, but same concept. var feature = results[0].feature;
var atts = feature.attributes;
var type = feature.geometry.type;
if (type == 'point') {
var sym = POINT_SYMBOL
} else if (type == 'polyline') {
var sym = POlYLINE_SYMBOL
} else if (type == 'polygon') {
var sym = POLYGON_SYMBOL
}
var graphic = new esri.Graphic(feature.geometry, sym, atts, null); Also, I always create an esri.Graphic.
... View more
06-12-2013
10:58 AM
|
0
|
0
|
3480
|
|
POST
|
Glad to help. Couple of things: 1) Keep in mind that the esri api is simply an extension of the dojo api. I spend way more time working with dojo than with the esri api. If you want to build powerful, high functioning apps, you must know dojo. 2) I mentioned adding your own objects to existing objects. When doing this you need to make sure the class doesn't use the same name. When 3.0 was released I ran into problems because the api added new objects and functions to classes with names I was using for objects and functions. 3) You can create your controls in the same function as you create the layer. The snippet I shared sends the layer object to a toc widget which adds the controls, menus, etc, but it's easily done with some simple dojo. Suppose we have a region and we want add simple layer toggle controls to it: [HTML]<div id="left" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'left'"> </div>[/HTML] In that same function (truncated for ease of reading) we build a control, place it and add layer toggle functionality to the checkbox: ms: function (l) {
if (l.type === 'dynamic') {
var imageParameters = new esri.layers.ImageParameters();
imageParameters.format = l.imageFormat;
imageParameters.dpi = l.dpi;
var layer = new esri.layers.ArcGISDynamicMapServiceLayer(l.url, {
id: l.id,
imageParameters: imageParameters,
visible: l.visible,
opacity: l.opacity
});
layer.layer_params = l; //add params to layer object
app.map.addLayer(layer);
//create control
var control = '<div style="padding:6px 0 3px; margin-bottom:3px; border-bottom:solid 1px #000;">'
+ '<input id="' + l.id + '_layer_control" />'
+ ' '
+ l.name
+ '</div>';
//place contol
dojo.place(control, 'left', 'first');
//create checkbox
var checkbox = new dijit.form.CheckBox({
checked: l.visible, //set checked same as default visibility
onChange: function () { //onChange function to toggle layer using the layer object itself
if (layer.visible) {
layer.hide()
} else {
layer.show()
}
}
}, l.id + '_layer_control');
} else if (l.type === 'tiled') {
//add tiled layer
}
} Once again the indents are goofy.
... View more
06-12-2013
10:37 AM
|
0
|
0
|
1549
|
|
POST
|
Yes. You can output in any spatial reference you would like. So if your data is in some state plane projection you can set outSpatialReference to that projection and that will be what is output. My mistake was thinking that if I set the projection of the data frame in the template it would output in that projection, but the print task overrides it. Foolishly I didn't test that theory. Setting outSpatialReference fixed it and I'm getting accurate scales. If outSpatialReference is not set it uses the map's projection (102100). You may also want to set preserveScale to false if your output has different units (feet not meters); else the extent of the output will be different than the map. var template = esri.tasks.PrintTemplate(); template.preserveScale = false;
... View more
06-12-2013
07:13 AM
|
0
|
0
|
5706
|
|
POST
|
I don't know if I totally have my head wrapped around what you are trying to do. I get the feeling you are trying to load layers dynamically on application load using custom parameters. I start with an object containing the info I need to create the layer plus added functionality, either by making a server call that returns the object in json or a javascript object in a config .js file. Here's an example of the latter: var config = {
layersMapService: [
{
url: 'http://www.sample.com/arcgis/rest/services/some_layer/MapServer', //url
type: 'dynamic', //type (dynamic or tiled)
name: 'Some Layer', //name as shown in toc and elsewhere
id: 'somelayer', //id must be unique
visible: false, //initial visibility
opacity: 1, //initial opacity
imageFormat: 'png32', //image format
dpi: 96, //dpi
legend: true, //legend in toc and map
identify: false, //is layer available in identify widget
identifyLayers: [], //which layers
query: false, //is layer available in query widget
queryLayers: [] //which layers
}, {
url: 'http://www.sample.com/arcgis/rest/services/another_layer/MapServer',
type: 'dynamic',
name: 'Another Layer',
id: 'anotherlayer',
visible: false,
opacity: 0.5,
imageFormat: 'png32',
dpi: 96,
legend: true,
identify: true,
identifyLayers: [0,1,6],
query: true,
queryLayers: [0,1,3,4,5,6]
}
]
}; Then during your initialization function, after initializing your map iterate through the config.layersMapService object to add them to the map: var app = {
build: function() {
//build viewer, load mods, etc
//map
app.map = new esri.Map('map', {});
//add layers
dojo.forEach(config.layersMapService, app.layers.add.ms);
},
layers: {
add: {
ms: function(l) {
//l is the object with all the params
if (l.type === 'dynamic') {
var imageParameters = new esri.layers.ImageParameters();
imageParameters.format = l.imageFormat;
imageParameters.dpi = l.dpi;
var layer = new esri.layers.ArcGISDynamicMapServiceLayer(url, {
id: l.id,
imageParameters: imageParameters,
visible: l.visible,
opacity: l.opacity
});
/*
//because the layer is an object I add the params object
//directly to the layer object in case I want them
//again for some other functionality
//
//this is an important concept to really leverage the api
//
//for example: when the query widget gets the json object
//back from the server for each map service layer that information
//(fields, domains, etc) will be stored as an object in the
//corresponding layerIds object
*/
layer.layer_params = l;
app.map.addLayer(layer);
/*
//this is the time to do all the extra things
//while we have the layer variable
*/
app.toc.add(layer, l.legend);
if (l.identify) {
app.identify.add(layer, l.identifyLayers)
}
if (l.query) {
app.query.add(layer, l.queryLayers)
}
} else if (l.type === 'tiled') {
//add tiled layer
}
}
}
}
}; Don't know if this is what you're looking for, but hope it helps. PS: you'll have to clean up the 2nd piece of code; it wouldn't hold the indents for some reason.
... View more
06-11-2013
05:46 PM
|
0
|
0
|
1549
|
|
POST
|
You are using the same variable for two different things.
var setTiledLayer = function(URL) {
var tuID = makeid(); //here tuID is whatever makeid() returns
//now tuID is is the layer object
tuID = new esri.layers.ArcGISTiledMapServiceLayer(URL, {id: tuID + 'ID'}); //you are trying to use an object for part of the string "id"
return tuID; //this should throw an error - are you watching this in firebug?
}; Try this.
var setTiledLayer = function(URL) {
var tuID = makeid();
var layer = new esri.layers.ArcGISTiledMapServiceLayer(URL, {id: tuID + 'ID'});
return layer;
};
... View more
06-11-2013
01:55 PM
|
0
|
0
|
1549
|
|
POST
|
Will be spending the day fixing that with an extent reprojection. Already taken care of. Set outSpatialReference of esri.tasks.PrintParameters.
... View more
06-11-2013
10:39 AM
|
0
|
0
|
2066
|
|
POST
|
@ben i dont think thats actually correct. its my understanding that the projection of the print output will be determined by the spatial reference which is passed within the WebMapJSON. Yep. And here I had been using that reasoning for a couple of print tasks. Will be spending the day fixing that with an extent reprojection.
... View more
06-11-2013
10:02 AM
|
0
|
0
|
2066
|
|
POST
|
Mike, Another option is to set the projection of your print task template map to that of the data if you want to keep the scale bar and have it accurate. This can cause a slightly longer print task processing time with tiled web mercator layers.
... View more
06-11-2013
09:45 AM
|
0
|
0
|
3640
|
|
POST
|
A couple other things with your code that may or may not be causing problems. 1) You should be using dijit.byId() instead of dojo.byId(). dojo.byId() is for regular elements like '<div id="myDiv"></div>', while dijit.byId() should be used for dijits like '<div id="myDiv" data-dojo-type="dijit/form/Button"></div>'. 2) When you connect to a dijit the onClick event is 'onClick', not 'click'. 3) You don't need to recreate the toolbar every time. In your initialization code, after you have created the map, create the toolbar once using a global var like you have done. I create one toolbar and use it for everything that may need to draw, e.g. measurement, creating features, etc. 3) The onClick property in data-dojo-props does not need to be wrapped in a function or use parentheses if you are not passing variables. [HTML]<div id="myDiv" data-dojo-type="dijit/form/Button" data-dojo-props="onClick: myFunction "></div>[/HTML] 4) You should disconnect from events once they fire. The way your code is now every time the toolbar is initialized you add another identical 'onDrawEnd' listener. It's not that big of a deal if the user just performs 1 or 2 cycles through the task, but it adds up to decreased performance in a heavily used app. Here's how I would do it with one function: var map, tb; function init() { //initialize the app map = new esri.Map({}); tb = new esri.toolbars.Draw(map); } function draw() { tb.activate(esri.toolbars.Draw.EXTENT); var conn = new dojo.connect(tb, 'onDrawEnd', function(evt) { dojo.disconnect(conn); //disconnect tb.deactivate(); map.graphics.clear(); //create and add graphic }); }
... View more
06-10-2013
12:24 PM
|
0
|
0
|
3480
|
|
POST
|
var titleText = dijit.byId('tasks-print-title-text');
var authorText = dijit.byId('tasks-print-author-text');
var title = 'My Map';
if (titleText.get('value') != '') {
title = titleText.get('value')
}
var author = 'Me';
if (authorText.get('value') != '') {
author = authorText.get('value')
}
var params = new esri.tasks.PrintParameters();
params.map = app.map;
var template = esri.tasks.PrintTemplate();
template.exportOptions = {};
legendLayers = [];
dojo.forEach(app.map.layerIds, function(id) {
var l = app.map.getLayer(id);
if (l.visible && l.id !== 've' && l.id !== 'esriworldimagery' && l.layer_params.legend) {
var layer = new esri.tasks.LegendLayer();
layer.layerId = l.id;
legendLayers.push(layer);
}
});
template.layoutOptions = {
'legendLayers': legendLayers,
'customTextElements': [{ 'Title': title }, { 'Author': author}]
};
template.format = 'PDF';
template.layout = 'Letter Landscape';
params.template = template;
... View more
06-07-2013
12:47 PM
|
1
|
0
|
1601
|
|
POST
|
i wrote up a quick fiddle which shows how to pass one layer "as is" and another with a new renderer and transparency set. you could skip the custom renderer if you wanted.... John - I'd like to see your example but the fiddle is blank. Thanks, Ben
... View more
06-07-2013
11:04 AM
|
0
|
0
|
972
|
|
POST
|
shameless plug for the little utility app i wrote to help define map constructor options.. Thanks John. Added to my list of helpful jsapi links.
... View more
06-06-2013
02:15 PM
|
0
|
0
|
1587
|
|
POST
|
I've never used the editor widget until now. The api reference doesn't list any events for the editor widget and looking through the editor in the DOM didn't help much either. The feature layer has an 'onEditsComplete' event. Connect to this event when you create the feature layer: var editSignSupports = new esri.layers.FeatureLayer("https://myserver/pubgis/rest/services/Signs/Signs2/FeatureServer/1", { id: 'editSignSupports', //always assign the layer id to all layers of all types; never let the api do it mode: esri.layers.FeatureLayer.MODE_ONDEMAND, outFields: ["*"] }); dojo.connect(editSignSupports, 'onEditsComplete', function(result) { var add = result[0]; if (add !== undefined && add.success) { //check to see that add was successful and in fact this was an add and not an update or delete dojo.forEach(editSignSupports.graphics, function(graphic) { //iterate through feature layer graphics if (graphic.attributes.OBJECTID === add.objectId) { graphic.attributes.SOME_OTHER_FIELD = add.objectId; //set your other field with object id editSignSupports.applyEdits(null, [graphic], null, function (response) { //apply edits to object //console.log(response); }, function (error) { //console.log(error) }); return; //stop loop once the only feature with that object id has been updated } }) } }); Attribute/field names are case sensitive. If your feature class has an OID called "objectid", referring to "OBJECTID" won't work. Hope this helps. I got it to work with this example http://developers.arcgis.com/en/javascript/samples/ed_simpletoolbar/. Probably needs some clean up and thorough testing prior to deployment.
... View more
06-06-2013
01:57 PM
|
0
|
0
|
2823
|
| 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
|