Solved! Go to Solution.
// Purely sample
// Just demonstrates how you may use the dojo/on method
// with the map click and other click events
define('identifyHandler', ['dojo/on', 'esri/tasks/identify'], function(on) {
var _idhandler = function(map) {
var task = new esri.tasks.IdentifyTask('url');
var idparams = new esri.tasks.IdentifyParameters();
idparams.tolerance = 3;
idparams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_ALL;
// callback train, yeah yeah, it's a sample, jeez
this.handler = on.pausable(map, 'click', function(e) {
// blah blah, set up your Identify Parameters
var deferred = task.execute(idparams);
deferred.then(function(){
// blah blah, do something
});
});
};
return _idhandler;
});
define('mapView', ['dojo/connect', 'identifyHandler', 'esri/map', 'esri/toolbars/draw'], function(connect, IdHandler) {
var _mapview = function() {
var self = this;
this.start = function() {
self.map = new esri.Map('map');
/**
do a bunch of map stuff
**/
connect.connect(self.map, 'onLoad', function() {
// initialize my little identify helper module
var identify = new IdHandler(self.map);
/**
Now, let's say you have a drawtool that will add points
to your map for some reason. A common problem is you can add the point,
but the map click to add a point also triggers the identify.
Easy way to handle this now...
**/
var drawTool = new esri.toolbars.Draw(map);
/** draw nonsense stuff here somewhere **/
connect.connect(someButton, 'click', function() {
drawTool.activate(esri.toolbars.Draw.POINT);
// now pause the identify map click
identify.handler.pause();
});
connect.connect(drawTool, 'onDrawEnd', function(geom) {
drawTool.deactivate();
// turn the identify back on
identify.handler.resume();
});
});
};
};
return _mapview;
});
require(["dojo/_base/connect"], function(Connect){
Connect.connect(map, "onClick", function() {
// do something
});
});require(["dojo/on"], function(On){
On(map, "onClick", function() {
// do something
});
});
map.on("click", function(e) {
console.log("map was clicked: ", e, e.mapPoint);
});