neerajbharti2007

how to call click event on marker using java arc objects

Discussion created by neerajbharti2007 on Apr 10, 2014
Latest reply on Apr 11, 2014 by ldonahue
Hii I am new in GIS and java arcobjects. I have to call a click event on simple marker element
on mapbean using java arc objects but i dont know how to do it.

in my application I put approx 200 markers in mapbean now i have to select few of them approx 6 marker which is selected by user but i dont know how to select this particular marker I think if i am able to call click event on marker. then I would select it .

putiing a marker on mapbean code is there.

public static void  drawBlackPoint(IPoint fpoint, double hieght,double prev_hieght) {
    try {


        ////for Starting point
        ISimpleMarkerSymbol markerSymbol2 = new SimpleMarkerSymbol();
        markerSymbol2.setStyle(esriSimpleMarkerStyle.esriSMSCircle);


        IRgbColor rgbColor2 = new RgbColor();
        if (hieght!=prev_hieght) {
            count1++;
        }
        if(count1==1){
            rgbColor2.setRed(34);
            rgbColor2.setBlue(139);
            rgbColor2.setGreen(24);
        }else if(count1==2){
            rgbColor2.setRed(0);
            rgbColor2.setBlue(0);
            rgbColor2.setGreen(205);
        }else if(count1==3){
            rgbColor2.setRed(112);
            rgbColor2.setBlue(219);
            rgbColor2.setGreen(147);
        }else if(count1==4){
            rgbColor2.setRed(255);
            rgbColor2.setBlue(255);
            rgbColor2.setGreen(0);
        }else if(count1==5){
            rgbColor2.setRed(127);
            rgbColor2.setBlue(0);
            rgbColor2.setGreen(255);
}else if(count1==6){
            rgbColor2.setRed(138);
            rgbColor2.setBlue(69);
            rgbColor2.setGreen(19);
        }else if(count1==7){
            rgbColor2.setRed(139);
            rgbColor2.setBlue(131);
            rgbColor2.setGreen(120);
        }else{
            rgbColor2.setRed(255);
            rgbColor2.setBlue(255);
            rgbColor2.setGreen(255);
        }
        markerSymbol2.setColor(rgbColor2);
        markerSymbol2.setSize(5.0);
        IMarkerElement markerElementOne2 =  new MarkerElement();
        markerElementOne2.setSymbol(markerSymbol2);
     IElement elementOne2 = (IElement) markerElementOne2;
        IElementProperties elementPropertiesTwo = (IElementProperties) elementOne2;
        elementPropertiesTwo.setName("FP");
        elementOne2.setGeometry(fpoint);



        ILayer layer;
        int count = BasicViewer.getMapBean().getLayerCount();



        if (hieght!=prev_hieght) {

            ICompositeGraphicsLayer cgl=new CompositeGraphicsLayer();
            IGraphicsContainer gl=(IGraphicsContainer)cgl;
            gl.addElement(elementOne2, 0);
            layer = (ILayer) gl;
            layer.setName("hieght_"+hieght);    
            BasicViewer.getMapBean().addLayer(layer, 0);
            BasicViewer.getMapBean().getActiveView().partialRefresh(esriViewDrawPhase.esriViewGeography,layer, null);

        }else{


            for (int i = 0; i < count; i++) {
                if(BasicViewer.getMapBean().getLayer(i).getName().equals("hieght_"+hieght))
                {
                    System.out.println("--Layer Name- if-"+BasicViewer.getMapBean().getLayer(i).getName());
                    layer=BasicViewer.getMapBean().getMap().getLayer(i);

                    IGraphicsContainer gl=(IGraphicsContainer)layer;

                    gl.addElement(elementOne2, 0);

                }
            }

        }

    } catch (Exception e) {
        System.out.println("Exception In drawPoint :: " + e.toString());
        e.printStackTrace();
    }
}

Outcomes