want to customize the  right click menu(conmtext menu) and want to show the map detai

653
4
Jump to solution
08-21-2012 09:04 PM
ARPITJAIN
New Contributor
hi,
i  want to customize the  right click menu(context menu) and want to fetch the details of map like co-ordinate,lat-long on the right click option.Plz help me out.

regards
arpit
0 Kudos
1 Solution

Accepted Solutions
PramodHarithsa1
Occasional Contributor II
I worked it out.
A slight modification of http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples/graphics_contextmenu.html

 function createMapMenu() {             // Creates right-click context menu for map             ctxMenuForMap = new dijit.Menu({                 onOpen: function (box) {                     currentLocation = getMapPointFromMenuPosition(box);                     var infoTemplate = new esri.InfoTemplate();                     identifyParams.geometry = currentLocation;                     identifyParams.mapExtent = map.extent;                     var deferred = identifyTask.execute(identifyParams);                      deferred.addCallback(function (response) {                        eturn dojo.map(response, function (result) {                             var feature = result.feature;                             feature.attributes.layerName = result.layerName;                              if (result.layerName === 'LayerOfInterest') {                                 //This can get you the list of attributes                                    feature.attributes;                                                                  }                             return feature;                         });                     });                  }             });


and you can use the feature values in the menu to do different things.
Herein i have attached my code for infowindow on right click.

View solution in original post

0 Kudos
4 Replies
BarraLoubna
New Contributor
for the context menu, I do this:

// Creates right-click context menu for map
        function createContextMenu(node, layer) {       
             ctxMenu = new dijit.Menu({
             onOpen: function(box) {
             // Lets calculate the map coordinates where user right clicked.
             // We'll use this to create the graphic when the user clicks
             // on the menu item to "Add Point"
             currentLocation = getMapPointFromMenuPosition(box);         
             editToolbar.deactivate();
           }
         });

         ctxMenu.addChild(new dijit.MenuItem({
             label: "Download",
             onClick: function (evt) {
               
             }
         }));

         ctxMenu.addChild(new dijit.MenuItem({
             label: "Datagrid.",
             onClick: function (evt) {
                 document.getElementById("grid").style.visibility = 'visible';
             }
         }));

         ctxMenu.addChild(new dijit.MenuItem({
             label: "Zoom to layer",
             onClick: function (evt) {
                 var layer = map.getLayer(id);
                 map.setExtent(layer.fullExtent);
             }
         }));

            ctxMenu.startup();
            ctxMenu.bindDomNode(node);
        }



The Context Menu appear in the right click of the layers, but nothing worked, the datagrid show me just the fields of the DataGrid without data...

If anyone can help us I would be grateful.

Loubna
0 Kudos
PramodHarithsa1
Occasional Contributor II
I have similar issue.
can any body help!
0 Kudos
PramodHarithsa1
Occasional Contributor II
I worked it out.
A slight modification of http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples/graphics_contextmenu.html

 function createMapMenu() {             // Creates right-click context menu for map             ctxMenuForMap = new dijit.Menu({                 onOpen: function (box) {                     currentLocation = getMapPointFromMenuPosition(box);                     var infoTemplate = new esri.InfoTemplate();                     identifyParams.geometry = currentLocation;                     identifyParams.mapExtent = map.extent;                     var deferred = identifyTask.execute(identifyParams);                      deferred.addCallback(function (response) {                        eturn dojo.map(response, function (result) {                             var feature = result.feature;                             feature.attributes.layerName = result.layerName;                              if (result.layerName === 'LayerOfInterest') {                                 //This can get you the list of attributes                                    feature.attributes;                                                                  }                             return feature;                         });                     });                  }             });


and you can use the feature values in the menu to do different things.
Herein i have attached my code for infowindow on right click.
0 Kudos
ARPITJAIN
New Contributor
thanks pramod 🙂
0 Kudos