DK7686

pass an object to an evt

Discussion created by DK7686 on Aug 15, 2013
Latest reply on Aug 20, 2013 by DK7686
Hi, we're occasional users of the JSAPI  using an older API (2.1). We're trying to create a page which does 2 things, first using a mark point function, which  gives us a pop up with a symbol for the point and it gets the coords for us (onClick).

function markpoint(evt)

We want to pass this through to an identify function to identify the map at these cords using function 'doIdentify(evt)'

We get the datagrid with no data, so it's not taking the marked point....

The text below is where it gets to: Anyone see any glaring errors?



function doIdentify(evt) {
            //map.graphics.clear();
            identifyParams.geometry = evt;
            identifyParams.mapExtent = map.extent;
            identifyTask.execute(identifyParams, function(idResults) {addToMap(idResults, evt); });

_





bit more of the script for reference... or luck_____________________________________________________



   dojo.connect(map.infoWindow, "onShow", function() {
                dijit.byId("tabs").resize();
                                                               
            });


        dojo.connect(map, "onClick", markpoint);
                               
         };




function markpoint(evt) {
        map.graphics.clear();
        var point = evt.mapPoint;
        var symbol = new esri.symbol.SimpleMarkerSymbol().setStyle(esri.symbol.SimpleMarkerSymbol.STYLE_POINT);
        var graphic = new esri.Graphic(point, symbol);
        var outSR = new esri.SpatialReference({ wkid: 27700});
        map.graphics.add(graphic);

        gsvc.project([ point ], outSR, function(projectedPoints) {
          pt = projectedPoints[0];
          graphic.setInfoTemplate(new esri.InfoTemplate("Coordinates",
            "<p> X: " + pt.x +
            "<br/> Y: " + pt.y +
            "</p>"  +
            "<input type='button' value='Confirm Point' onClick='identifypoint(map);' />" +
            "<div id='latlong'></div>"));
          map.infoWindow
            .setTitle(graphic.getTitle())
            .setContent(graphic.getContent())
            .show(evt.screenPoint, map.getInfoWindowAnchor(evt.screenPoint));
        });
      }



function identifypoint(map){


identifyTask = new esri.tasks.IdentifyTask("http://bl-arcgis-1/ArcGIS/rest/services/CRM/MapServer");


            identifyParams = new esri.tasks.IdentifyParameters();
            identifyParams.tolerance = 3;
            identifyParams.returnGeometry = true;
            identifyParams.layerIds = [1, 2, 3, 4];
            identifyParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_ALL;

            identifyParams.width = map.width;
            identifyParams.height = map.height;

            map.infoWindow.resize(415, 200);

            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.5]));

doIdentify();

}





function doIdentify(evt) {
   //map.graphics.clear();
            identifyParams.geometry = evt;
            identifyParams.mapExtent = map.extent;
            identifyTask.execute(identifyParams, function(idResults) {addToMap(idResults, evt); });

hello();

        }



function addToMap(idResults, evt){

//alert("hello");

 
            layer1results = { displayFieldName: null, features: [] };
            layer2results = { displayFieldName: null, features: [] };
            layer3results = { displayFieldName: null, features: [] };
            layer4results = { displayFieldName: null, features: [] };


            for (var i = 0, il = idResults.length; i < il; i++) {
                var idResult = idResults[i];
                                                                                if (idResult.layerId === 1) {
                    if (!layer1results.displayFieldName) { layer1results.displayFieldName = idResult.displayFieldName };
                    layer1results.features.push(idResult.feature);
                } else if (idResult.layerId === 2) { 
                    if (!layer2results.displayFieldName) { layer2results.displayFieldName = idResult.displayFieldName };
                    layer2results.features.push(idResult.feature);
                } else if (idResult.layerId === 3) {
                    if (!layer3results.displayFieldName) { layer3results.displayFieldName = idResult.displayFieldName };
                    layer3results.features.push(idResult.feature);
                } else if (idResult.layerId === 4) {
                    if (!layer4results.displayFieldName) { layer4results.displayFieldName = idResult.displayFieldName };
                    layer4results.features.push(idResult.feature);
                }
            }

Outcomes