|
POST
|
How about similar to the on.once() method,you try on.pausable(). I made a fiddle demonstrating it here. http://jsfiddle.net/odoe/DtJcH/ Here is the js for it.
require([
'dojo/on',
'dojo/query',
'esri/map',
'esri/tasks/IdentifyTask',
'esri/tasks/IdentifyParameters',
'esri/layers/ArcGISDynamicMapServiceLayer',
'dojo/domReady!'
], function (
on, query,
Map,
IdentifyTask, IdentifyParameters,
ArcGISDynamicMapServiceLayer
) {
var map,
layer,
idTask,
idParams,
handler,
paused = false,
$button = query('#btnIdentify')[0];
map = new Map('mapDiv', {
basemap: 'streets',
center: [-83.275, 42.573],
zoom: 18
});
layer = new ArcGISDynamicMapServiceLayer('http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/BloomfieldHillsMichigan/Parcels/MapServer', {
opacity: 0.5
});
map.addLayer(layer);
on.once(map, 'load', function () {
// define a pausable handler
handler = on.pausable(map, 'click', doIdentify);
idTask = new IdentifyTask('http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/BloomfieldHillsMichigan/Parcels/MapServer');
idParams = new IdentifyParameters();
idParams.tolerance = 3;
idParams.returnGeometry = true;
idParams.layerIds = [0, 2];
idParams.layerOption = IdentifyParameters.LAYER_OPTION_ALL;
idParams.width = map.width;
idParams.height = map.height;
});
// handle the pausable handler
on($button, 'click', function () {
paused = !paused;
if (paused) {
handler.pause();
$button.innerHTML = 'Paused';
} else {
handler.resume();
$button.innerHTML = 'Not Paused';
}
});
function doIdentify(e) {
console.debug('identify on the map');
idParams.geometry = e.mapPoint;
idParams.mapExtent = map.extent;
idTask.execute(idParams).then(function () {
alert('Identify Complete');
}, function (err) {
alert('Error, sorry');
});
}
});
... View more
12-20-2013
07:43 AM
|
0
|
0
|
2313
|
|
POST
|
Odd, I would think the context for this would the toolbar, but you can bind the context of your widget to the addToMap function using dojo/_base/lang. Instead of this.toolbar.on("draw-end", this.addToMap); Try this.toolbar.on("draw-end", lang.hitch(this, "addToMap")); That should make sure your addToMap method has a context bound the widget.
... View more
12-19-2013
11:02 AM
|
0
|
0
|
1021
|
|
POST
|
I know no details yet, but a REST API would be a great way to include this in current build systems. I'm just saying.
... View more
12-12-2013
01:53 PM
|
0
|
0
|
1550
|
|
POST
|
It's the same as I would do saving to a regular FeatureService. I have a module that is used to perform all my saves/syncs I put together a more comprehensive example of how I use perform saves/updates.
// using the historyutil.js module I posted earlier
var Service = declare([], {
constructor: function(options) {
this.options = options;
this.map = this.options.map;
// the options will have a URL to the
// non-spatial table in my FeatureService
// for recording the history of my edits
this.editHistory = new HisotryUtil(this.options);
// this is the actual layer with spatial features that
// I will edit.
this.editLayer = this.map.getLayer('defectsLayer');
},
save: function(name, adds, updates) {
var deferred = new Deferred();
var self = this;
// first edit my spatial layer
// NOTE - Deletes not allowed in app, but you could track that if
// needed.
this.editLayer.applyEdits(adds, updates, null, function (results) {
// when spatial table successfully edited, send same
// edits to history table using the HistoryUtil
// module in previous post.
self.editHistory.save(adds, filterUpdate(updates));
self.editLayer.refresh(); // quick refresh
// I don't to see if
// history update finished because I don't care.
// History is a backend thing, not app related.
// In production I would check if this failed and
// log it somewhere else.
// Now I can resolve my results.
deferred.resolve(results);
}, function (error) {
deferred.reject(error);
});
return deferred.promise;
},
});
// This function finds out if two field
// values are identical
function statsMatch(obj, field1, field2) {
return obj[field1] === obj[field2];
}
// If I'm doing an update of data, I just track status changes.
// So I filter out any features where the status did NOT change.
function filterUpdate(items) {
return arrayUtil.filter(items, function(item) {
// helper function to see if the status changed
return !statsMatch(item.attributes, 'PreviousStatus', 'DefectStatus');
});
}
return Service;
... View more
12-06-2013
05:49 AM
|
0
|
0
|
1398
|
|
POST
|
Is this table published on your ArcGIS Server? If so, I just publish it in a FeatureService with related Features and load the table as a FeatureLayer and apply edits as needed. It's worked great for me so far. For example, in one app, I need to update a history table when ever some features get added/updated/deleted. So I have this utility module that simply accepts arrays of graphics with empty geometries (or not, it doesn't matter) with the updated information and updates the table as a FeatureLayer. The CRUD functions don't care if it has a geometry or not.
define([
'dojo/_base/declare',
'esri/layers/FeatureLayer'
], function(
declare,
FeatureLayer
) {
'use strict';
return declare(null, {
constructor: function(options) {
this.historyLayer = new FeatureLayer(options.settings.defectHistory);
},
save: function(adds, updates, deletes) {
return this.historyLayer.applyEdits(adds, updates, deletes);
}
});
});
... View more
12-04-2013
08:15 AM
|
0
|
0
|
1398
|
|
POST
|
If you want to get hacky, you can use the 'returnDistinctValues' in the query as described here.http://forums.arcgis.com/threads/95739-Why-isn-t-quot-returnDistinctValues-quot-an-option-for-the-quot-Query-quot-object-in-the-JS-API This will limit the result to distinct results. Works well when returning a single field from a request.
... View more
12-02-2013
04:39 AM
|
0
|
0
|
1621
|
|
POST
|
The symbology of a FeatureLayer will be drawn with API based on the DrawingInfo section of the Layer details from a URL similar to this one. http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/0?f=pjson So individual features returned as JSON from the server will not have a symbology defined, this saves on network bandwidth.
... View more
11-19-2013
09:57 AM
|
0
|
0
|
979
|
|
POST
|
You mway want to make sure the results are in the proper spatial reference. Make sure you have this in your code some where before executing the QueryTask. query.outSpatialReference = map.spatialReference; https://developers.arcgis.com/en/javascript/jsapi/query-amd.html#outspatialreference This has bitten me on more than one occasion.
... View more
11-13-2013
11:16 AM
|
0
|
0
|
3478
|
|
POST
|
I haven't tried this with IE10 yet, but it worked in IE9, you might be able to do it like this.
// using the container div
map.container.onkeydown = function(e) {
console.log("container: native listen down", e);
};
map.container.onkeyup = function(e) {
console.log("container: native listen up", e);
};
// using the root div
map.root.onkeydown = function(e) {
console.log("root: native listen down", e);
};
map.root.onkeyup = function(e) {
console.log("root: native listen up", e);
};
However this is only works on the map in IE on my end, it didn't work in Chrome for me, so mileage may vary.
... View more
11-08-2013
06:36 AM
|
0
|
0
|
1322
|
|
POST
|
An "esri-" prefix would be awesome. You should submit that to http://ideas.arcgis.com/
... View more
11-06-2013
01:57 PM
|
0
|
0
|
1505
|
|
POST
|
Esri-leaflet is using karma with mocha for testing to conform to Leaflet practices. https://github.com/Esri/esri-leaflet Here is a project using karma with ArcGIS JS API. https://github.com/DavidSpriggs/esri-karma-tutorial Jasmine is pretty popular too, but until recently development was a bit stagnant. http://blog.davebouwman.com/2013/07/26/automated-headless-unit-tests-with-esri-js-api/ I prefer to use mocha under Grunt as I prefer how mocha handles asynchronous testing. http://visionmedia.github.io/mocha/ I would also take a look at the agrc/StubModule project that can help you stub ArcGIS JS API modules for testing. https://github.com/agrc/StubModule Most developers don't write enough tests, I know I don't write as much as I should, but a good set of tests pays for itself in the long run. Also, tests are documentation. If I ever need a better understanding of a library or project, I can usually clear it up by looking over the tests. So that's one thing to keep in mind, if I hand this project off to someone else, will my tests guide another developer to better understand what it is doing?
... View more
11-06-2013
01:49 PM
|
0
|
0
|
2595
|
|
POST
|
I've seen people mention they use the API with PhoneGap, but I haven't tried it yet. I know PhoneGap can access the file system http://docs.phonegap.com/en/1.7.0/cordova_file_file.md.html, so maybe if you stored the images as base64 encoded, you could modify the local storage example to work with it. https://developers.arcgis.com/en/javascript/jssamples/exp_webstorage.html Geolocation requires a connection, so if you can geolocate, you should be able to fall back to using regular web services anyway.
... View more
11-01-2013
09:40 AM
|
0
|
0
|
992
|
|
POST
|
In AMD style codes, I don't understand what happens when a function is in inside the require([...], function() {}); for example, the following codes: require([...], function() { ..... function ABC () {a = c + b; } ..... }); The function ABC is very confusing to me. When the program runs, when will function ABC be executed? To understand this, should I go study more dojo language? Thanks a lot! The ABC function lives in the scope of the require() function, but isn't executed unless you call it in the require function. It is only accessible inside that particular require function. This isn't really a Dojo specific issue. Modules simply scope functionality. But when you define() a module, unless you return something, it doesn't provide anything. This is why you may come across errors like variable equals 3 or something odd, because maybe you forgot to place a return in the module. To help illustrate, let's look at a define() module. // ABCModule define([], function() { function ABC (b, c) { var a = c + b; return a; } return ABC; // defined modules should return something, object or function. }); // Main JS file require(['./ABCModule'], function(ABC) { ABC(1, 2); // returns 3; }); If you didn't actually return ABC in the defined module, you would never be able to use it, as it's not exposed to the outside world. AMD modules essentially use the revealing module pattern to share their innards (or the important parts anyway) with the everyone else. http://addyosmani.com/resources/essentialjsdesignpatterns/book/#revealingmodulepatternjavascript http://requirejs.org/docs/whyamd.html#amd Here are a couple of links that discuss scope. http://dailyjs.com/2012/07/23/js101-scope/ https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions_and_function_scope http://javascriptplayground.com/blog/2012/04/javascript-variable-scope-this/ Also, you typically only have a single require() per application, an entry point to start the application. This SO answer covers if pretty nicely. http://stackoverflow.com/questions/11559270/what-is-the-main-difference-between-require-and-define-function-in-dojo-and Hope that helps a bit.
... View more
10-29-2013
11:17 AM
|
0
|
0
|
1161
|
|
POST
|
You'd have to expose the stored procedure via your own web service. You could also do it with an SOE or a GP service.
... View more
10-25-2013
07:06 AM
|
0
|
0
|
1155
|
|
POST
|
Nevermind, I was able to just use http://james.newtonking.com/json List<List<int>> results = FlowTrace.RunFlowTrace(dto);
return Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(results)); Even using StringBuilder and it worked. Thanks.
... View more
10-25-2013
05:46 AM
|
0
|
0
|
773
|
| Title | Kudos | Posted |
|---|---|---|
| 2 | 05-19-2026 02:12 PM | |
| 1 | 04-24-2026 11:01 AM | |
| 2 | 04-21-2026 07:06 AM | |
| 1 | 02-27-2026 06:31 AM | |
| 1 | 01-13-2026 02:15 PM |
| Online Status |
Online
|
| Date Last Visited |
3 hours ago
|