Identify From Button

931
8
04-16-2014 05:33 AM
jaykapalczynski
Frequent Contributor
Identify from Button
I was on here working out a solution to fire some code that did a buffer and selection of features within and return to a grid. That works, but I now have a button that I want to run an identify and send results to a side bar. I believe the code is in place to pause the buffer code when switching between buttons.
But the way I have it set up below its requiring a click event on the map to start running the Identify code...if I click a feature in the map it does not run the code. So I am confused on how to start the Identify

Trying to call the identify sidebar code in red
the blue is where I am seeing a required map click to run the code...but it does not fire when I click a feature I want to identify on.

When I click the map I am not even getting to the Function and the alert.... alert("In SidebarApp");

Thoughts?
Thanks

   
        on(dojo.byId('Identify'), "click", function () {

         if (Buffer != undefined) {
             Buffer.pause();
         }
         if (Identify == undefined) {
             Identify = on.pausable(app.map, "click", function (evt) {
    
   initializeSidebar(map);
             });
         }
         else {
             Identify.resume();
         }
    });





// SIDEBAR IDENTIFY START

    function initializeSidebar(map){
 
 alert("In SidebarApp");
 
 
        var popup = map.infoWindow;

        //when the selection changes update the side panel to display the popup info for the
        //currently selected feature.
        connect.connect(popup, "onSelectionChange", function(){
            displayPopupContent(popup.getSelectedFeature());
        });

        //when the selection is cleared remove the popup content from the side panel.
        connect.connect(popup, "onClearFeatures", function(){
           //dom.byId replaces dojo.byId
           dom.byId("featureCount").innerHTML = "Click to select feature(s)";
           //registry.byId replaces dijit.byId
           registry.byId("leftPane").set("content", "");
           domUtils.hide(dom.byId("pager"));
        });

        //When features are associated with the map's info window update the sidebar with the new content.
        connect.connect(popup, "onSetFeatures", function(){
           displayPopupContent(popup.getSelectedFeature());
           dom.byId("featureCount").innerHTML = popup.features.length + " feature(s) selected";

       //enable navigation if more than one feature is selected
       popup.features.length > 1 ? domUtils.show(dom.byId("pager")) : domUtils.hide(dom.byId("pager"));
         });
       }

    function displayPopupContent(feature){
       if(feature){
           var content = feature.getContent();
           registry.byId("leftPane").set("content", content);
       }
    }

    function selectPrevious(){
       map.infoWindow.selectPrevious();
    }

    function selectNext(){
       map.infoWindow.selectNext();
    }

    function clearContent() {
       registry.byId("leftPane").set("content", "");
       domUtils.hide(dom.byId("pager"));
    }
0 Kudos
8 Replies
jaykapalczynski
Frequent Contributor
I am trying as such

http://jsfiddle.net/Jaykapalczynski/SDpM3/49/

Any thoughts...not even getting into the Identify Function
0 Kudos
RaymondGoins
Occasional Contributor
I am a little confused on your flow.

How is the buffer and selection being done?
Do you want to run an identify of the buffer that was previously created or is this all going to be done at the same time?

Ray
0 Kudos
jaykapalczynski
Frequent Contributor
I am going to post a jsfiddle that has both idenitfy and buffer in a few....with an explanation of what I am trying to do.
0 Kudos
jaykapalczynski
Frequent Contributor
Alright...I think a jsfiddle might help more...

If you open this jsfiddle and click the buffer button:  Then click the map (around the shore line) it will draw a buffer and select the Boat Ramps inside the buffer and return the results to a Grid...great

on(dojo.byId('btnAction1'), "click", function () {
});
on(dojo.byId('btnAction2'), "click", function () {
});


The two functions above in the code are handling the pausing of each tool....
This was added with the help of others here in this forum to cancel the Buffer Tool as it was continually o


Now I have the identify button as well...I want to be able to click the identify button and then select one of the Green Features in the map and have the results show up in the sidebar...This sort of works BUT only when i click the Identify button then click in the map only...this fires the Alert in the 
on(dojo.byId('btnAction1'), "click", function () {
  

and then when i click the map it fires the alert in the 

function initializeSidebar(map){



I think this is happening because of the below.  its looking for a map click....but I want to identify on a feature....

action1 = on.pausable(app.map, "click", function (evt) {



I hope that makes sense adn you can help with this

http://jsfiddle.net/Jaykapalczynski/SDpM3/62/
0 Kudos
jaykapalczynski
Frequent Contributor
right now I can click the Identify Button
Click in the map to fire the alerts....telling me I am in the function

Now when you click one of the features in the map notice the text change in the blue box from
"2Click to select feature(s)"
to this
"Click Identify Tool to select feature(s)"

So I know that I am in the function initializeSidebar(map)

I just cant seem to figure out how to get the results from the Identify to be displayed in the sidebar, it should be beneath the text "Click Identify Tool to select feature(s)"

Seems that I cannot select features or something!!!!
0 Kudos
jaykapalczynski
Frequent Contributor
THINK I GOT IT.....BRB
0 Kudos
jaykapalczynski
Frequent Contributor
I added another Accordion Pane that is opened when you click the Identify Button in the "Tools" Accordion Pane.
Then select a Green Feature in the map and it will return the values...

You can then Click the Buffer Tool and click the map to retrieve Boat Ramp Info to the Grid...

Although Last Issue....I havent figured out how to turn off the Identify Tool....if AFTER I click the Idenitiy tool and then click and use the buffer tool ...I can still Identify on the Green Features....Any thoughts on how to Destroy the Identify Tool after I select the Buffer Tool?

Solution:
http://jsfiddle.net/Jaykapalczynski/SDpM3/63/
0 Kudos
MayJeff
Occasional Contributor

Can you post it on jsfiddle? Your link is not working.  I try to put my infowindow result on left pane when button click to active identify tool.

Thanks.

0 Kudos