How To capture Event in a Layer

View: New views
9 Messages — Rating Filter:   Alert me  

How To capture Event in a Layer

by ta3ban4 :: Rate this Message:

| View Threaded | Show Only this Message

Hi All,
        I have a problem receiving different mouse event on a layer. Created a class that extends OMGraphicHandlerLayer  and  implementing  
        MapMouseListener and adding it to layer handler. That  class simply should detect the mouse X/Y position and display it in the same way 
        for example the DateLayer or ScaleDisplayLayer. My problem i guess that i cant figure out how to capture the mouse event. I have been looking
        at the event class and a lot of example but i can get a good understanding how it works.My main class is  modified simple2 example.
        As far as I know ,  I have to change the mouse event mod to be able to capture the mouse event but not sure how exactly i can
        do that.
           
         
        Would anyone give some idea/Guidance in how to get that mouse event !.
 
 
Thanks in Advance
 
Mike




Wondering what's for Dinner Tonight? Get new twists on family favorites at AOL Food.

Parent Message unknown RE: How To capture Event in a Layer

by Chris Allport-2 :: Rate this Message:

| View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

Hey, Mike,

 

We don’t use the OMGraphicHandlerLayer, but it extends Layer, so the same may hold true.

 

We setup the mouse as follows:

 

    private void setupMouseModes(){

        MouseDelegator md = new MouseDelegator(mapBean);

        mapHandler.add(md);

 

        Layer[] selectLayers = new Layer[] {

            …list layers in here…

        };

 

        com.bbn.openmap.event.SelectMouseMode selectMouseMode = new com.bbn.openmap.event.SelectMouseMode();

 

        md.setupMouseModeWithLayers(selectMouseMode, selectLayers);

 

        com.bbn.openmap.event.MapMouseMode [] mouseModes = new com.bbn.openmap.event.MapMouseMode[] {

            selectMouseMode

        };

 

        md.setMouseModes(mouseModes);

        md.setActiveMouseMode(selectMouseMode);

    }

 

Then, in each layer, we implement the following two methods:

 

    public MapMouseListener getMapMouseListener() {

            return this;

    }

   

    public String[] getMouseModeServiceList() {

        return new String[] {

                com.bbn.openmap.event.SelectMouseMode.modeID

            };

    }   

 

 

After that, things start working for us!

 

Good luck!

 

Chris

 


From: owner-openmap-users@... [mailto:owner-openmap-users@...] On Behalf Of Ta3ban4@...
Sent: Monday, May 12, 2008 2:28 PM
To: openmap-users@...
Subject: [OpenMap Users] How To capture Event in a Layer

 

Hi All,

        I have a problem receiving different mouse event on a layer. Created a class that extends OMGraphicHandlerLayer  and  implementing  

        MapMouseListener and adding it to layer handler. That  class simply should detect the mouse X/Y position and display it in the same way 

        for example the DateLayer or ScaleDisplayLayer. My problem i guess that i cant figure out how to capture the mouse event. I have been looking

        at the event class and a lot of example but i can get a good understanding how it works.My main class is  modified simple2 example.

        As far as I know ,  I have to change the mouse event mod to be able to capture the mouse event but not sure how exactly i can

        do that.

           

         

        Would anyone give some idea/Guidance in how to get that mouse event !.

 

 

Thanks in Advance

 

Mike




Wondering what's for Dinner Tonight? Get new twists on family favorites at AOL Food.


Re: How To capture Event in a Layer

by Davidian :: Rate this Message:

| View Threaded | Show Only this Message

Mike,

Since you're extending OMGraphicHandlerLayer, capturing mouse events is actually pretty easy.  You basically need to do a couple of things:

1) Override the receivesMapEvents() method to return true.

2) Call the setMouseModeIDsForEvents() method in your constructor to set the MapMouseModes that you want to receive mouse clicks from.  You probably want to listen for at least SelectMouseMode.

3) Override the appropriate method(s) to handle clicks on the layer: leftClick(), getItemsForMapMenu(), etc...

One note: I don't think the default StandardMapMouseInterpreter passes left clicks to the OMGraphicHandlerLayer by default.  You may need to create your own class that extends StandardMapMouseInterpreter that overrides leftClick() and passes the mouse event to the leftClick() method of your layer.  I think that's what I did.

I hope this helps.

-Kennedy

Parent Message unknown Re: How To capture Event in a Layer

by ta3ban4 :: Rate this Message:

| View Threaded | Show Only this Message

Chirs , Kennedy and All
 
         Thanks guys for taking the time to reply back.
           
         I got the mouse event working by doing the following ; Not sure if this is the best/correct way  ;
 
            public class MyLatLongLayer extends OMGraphicHandlerLayer implements MapMouseListener
            {   ,,,,,,,
                  public MapMouseListener getMapMouseListener(){return this;}
                  public String[] getMouseModeServiceList(){ return new String[] { SelectMouseMode.modeID };}
            }
        
 
         Then from my main program I load the different layers and then do the following
             MouseDelegator mouseDelegator = new MouseDelegator();
            mapHandler.add(mouseDelegator);
            SelectMouseMode selectMouseMode = new SelectMouseMode();
            mapHandler.add(selectMouseMode);
            NavMouseMode2  nav2=  new NavMouseMode2();
            mapHandler.add(nav2);
            ,,,,,
           mapHandler.add(new MouseModeButtonPanel());
           
          From main gui by selecting Gestures from the MouseModeButton i received the different mouse events in MyLatLongLayer
          The layer would be added to display the lat/long position
 
 
           finally Let me give you an idea about my school project maybe you guys can give me some hints and ideas how to proceed .
           
           My application side of that project is to receive  Aircraft objects that contain a lat/long and
           some other simple information (N objects/sec ), display them on a map  and load the appropriate shape/tiff files.
          User shall be able to click on the aircraft and get the  information about that aircraft in pop up window/or like LocationLayer that holds cities.
           I will implement the ideas that guys mentioned. 
 
 
Thanks  in Advance
 
Mike
            
In a message dated 5/14/2008 2:10:46 P.M. Eastern Standard Time, kroberts@... writes:

Mike,

Since you're extending OMGraphicHandlerLayer, capturing mouse events is
actually pretty easy.  You basically need to do a couple of things:

1) Override the receivesMapEvents() method to return true.

2) Call the setMouseModeIDsForEvents() method in your constructor to set the
MapMouseModes that you want to receive mouse clicks from.  You probably want
to listen for at least SelectMouseMode.

3) Override the appropriate method(s) to handle clicks on the layer:
leftClick(), getItemsForMapMenu(), etc...

One note: I don't think the default StandardMapMouseInterpreter passes left
clicks to the OMGraphicHandlerLayer by default.  You may need to create your
own class that extends StandardMapMouseInterpreter that overrides
leftClick() and passes the mouse event to the leftClick() method of your
layer.  I think that's what I did.

I hope this helps.

-Kennedy
--
View this message in context: http://www.nabble.com/How-To-capture-Event-in-a-Layer-tp17193632p17237519.html
Sent from the OpenMap mailing list archive at Nabble.com.

--
[To unsubscribe to this list send an email to "majdart@..."
with the following text in the BODY of the message "unsubscribe openmap-users"]




Wondering what's for Dinner Tonight? Get new twists on family favorites at AOL Food.

Parent Message unknown Re: How To capture Event in a Layer

by Mike Lackey :: Rate this Message:

| View Threaded | Show Only this Message

Another Mike asks:

My application side of that project is to receive Aircraft objects
that contain a lat/long and some other simple information (N
objects/sec ), display them on a map and load the appropriate
shape/tiff files.  User shall be able to click on the aircraft and get
the information about that aircraft in pop up window/or like
LocationLayer that holds cities.
-------------------------

This Mike replies:  here is an earlier post for somebody who wanted to
display Mil Std icons.  An icon is an icon, maybe some of it is
useful.
--------------------------


I used OMScalingIcon. Here is an example:


public class MyIconObject
{
    /**
     * the openmap icon
     */
    protected OMScalingIcon omIcon = null;


    /** Creates a new instance of an icon object*/
    public MyIconObject(float lat, float lon, String fileName)
    throws MyException
    {
        if (fileName == null) {
            throw new MyException ("MyIconObject: null filename");
        }
        ImageIcon imageIcon = new ImageIcon(fileName);
        if (imageIcon == null) {
            throw new MyException ("MyIconObject: null ImageIcon");
        }
        omIcon = new OMScalingIcon(lat, lon, imageIcon);
        if (omIcon == null) {
            throw new MyException ("PointObject: null OMScalingIcon");
        }
        // at map scale of 1:500,000 the icon will appear full size
omIcon.setBaseScale(500000f);
        // icon will be scaled (larger) until map scale > value
        omIcon.setMaxScale(500000f);
        // icon will be scaled (smaller) until map scale < this value
        omIcon.setMinScale(defaultIconMinScale);
        // when selected, color is red
        omIcon.setSelectPaint(Color.red);
    }
}


For my applicaton, MyIconObject "has a" OMScalingIcon, rather than "is
a" OMScalingIcon. I chose this design for a particular reason. But the
"is a" relationship is also logical (and perhaps more intuituve):


public class MyIconObject extends OMScalingIcon
{
}


Next, BasicLocationHandler.java will need a list of all objects on the
map. The location handler is responsible for the creating/maintaining
the list. Here is sample code:


public class MyObjectHandler
{
    // a list of all objects on the map
    protected Vector<MyIconObject> objList;


    // add an object to the map
    public void addIconObject (MyIconObject obj) {
        objList.add(obj);
    }


    /**
     * When the layer receives a new projection, it goes to each
     * objectHandler and asks it for additions to the layer's graphic list
     */
    public void get
    (float nLat, float wLon, float sLat, float eLon, Vector graphicList)
    {
        for (int i=0; i<objList.size(); i++)
        {
            // the object is an icon image, or similar,
            // and is defined by a singular point.
            // if the point is within the projection, show the image.
            MyIconObject iconObj = objList.get(i);
            if ((sLat <= iconObj .getLat()) && (iconObj .getLat()<= nLat))
            {
                if ((wLon <= iconObj .getLon()) && (iconObj .getLon()<= eLon))
                {
                    graphicList.add(iconObj);
                }
            }
        }
    }
}


Finally, create icons and add them to the map:


      MyIconObject myIcon= new MyIconObject (lat, lon, "C:/somefile.png");
        MyObjectHandler myHandler = myLayer.getMyHandler();
        myHandler.add (myIcon);
        myLayer.doPrepare();

--------------------------
Mike

--
[To unsubscribe to this list send an email to "majdart@..."
with the following text in the BODY of the message "unsubscribe openmap-users"]

Re: How To capture Event in a Layer

by Don Dietrick :: Rate this Message:

| View Threaded | Show Only this Message

Hi Mike,

Do you really need the MouseEvent object, or do you just want to know  
when things (clicks, mouse overs, etc) happen over your map objects?

The OMGraphicHandler has a lot of functionality already built into it  
to let you know when the mouse is doing something over your objects.  
Look at the com.bbn.openmap.layer.learn.InteractionLayer for guidance  
with respect to that.

You can respond to mouse clicks this way, too, with the selected(...)  
method, popping up a window with your picture in it.  Alternatively,  
you could construct html that references an image URL, and call  
layer.fireRequestBrowserContent(String browserContent).

Hope this helps,

Don

On May 14, 2008, at 4:19 PM, Ta3ban4@... wrote:

> Chirs , Kennedy and All
>
>          Thanks guys for taking the time to reply back.
>
>          I got the mouse event working by doing the following ; Not  
> sure if this is the best/correct way  ;
>
>             public class MyLatLongLayer extends  
> OMGraphicHandlerLayer implements MapMouseListener
>             {   ,,,,,,,
>                   public MapMouseListener getMapMouseListener()
> {return this;}
>                   public String[] getMouseModeServiceList(){ return  
> new String[] { SelectMouseMode.modeID };}
>             }
>
>
>          Then from my main program I load the different layers and  
> then do the following
>              MouseDelegator mouseDelegator = new MouseDelegator();
>             mapHandler.add(mouseDelegator);
>             SelectMouseMode selectMouseMode = new SelectMouseMode();
>             mapHandler.add(selectMouseMode);
>             NavMouseMode2  nav2=  new NavMouseMode2();
>             mapHandler.add(nav2);
>             ,,,,,
>            mapHandler.add(new MouseModeButtonPanel());
>
>           From main gui by selecting Gestures from the  
> MouseModeButton i received the different mouse events in  
> MyLatLongLayer
>           The layer would be added to display the lat/long position
>
>
>            finally Let me give you an idea about my school project  
> maybe you guys can give me some hints and ideas how to proceed .
>
>            My application side of that project is to receive  
> Aircraft objects that contain a lat/long and
>            some other simple information (N objects/sec ), display  
> them on a map  and load the appropriate shape/tiff files.
>           User shall be able to click on the aircraft and get the  
> information about that aircraft in pop up window/or like  
> LocationLayer that holds cities.
>            I will implement the ideas that guys mentioned.
>
>
> Thanks  in Advance
>
> Mike
>
> In a message dated 5/14/2008 2:10:46 P.M. Eastern Standard Time, kroberts@...
>  writes:
>
> Mike,
>
> Since you're extending OMGraphicHandlerLayer, capturing mouse events  
> is
> actually pretty easy.  You basically need to do a couple of things:
>
> 1) Override the receivesMapEvents() method to return true.
>
> 2) Call the setMouseModeIDsForEvents() method in your constructor to  
> set the
> MapMouseModes that you want to receive mouse clicks from.  You  
> probably want
> to listen for at least SelectMouseMode.
>
> 3) Override the appropriate method(s) to handle clicks on the layer:
> leftClick(), getItemsForMapMenu(), etc...
>
> One note: I don't think the default StandardMapMouseInterpreter  
> passes left
> clicks to the OMGraphicHandlerLayer by default.  You may need to  
> create your
> own class that extends StandardMapMouseInterpreter that overrides
> leftClick() and passes the mouse event to the leftClick() method of  
> your
> layer.  I think that's what I did.
>
> I hope this helps.
>
> -Kennedy
> --
> View this message in context: http://www.nabble.com/How-To-capture-Event-in-a-Layer-tp17193632p17237519.html
> Sent from the OpenMap mailing list archive at Nabble.com.
>
> --
> [To unsubscribe to this list send an email to "majdart@..."
> with the following text in the BODY of the message "unsubscribe  
> openmap-users"]
>
>
>
> Wondering what's for Dinner Tonight? Get new twists on family  
> favorites at AOL Food.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Don Dietrick, dietrick@...
BBN Technologies, Cambridge MA
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=



--
[To unsubscribe to this list send an email to "majdart@..."
with the following text in the BODY of the message "unsubscribe openmap-users"]

Parent Message unknown Re: How To capture Event in a Layer

by ta3ban4 :: Rate this Message:

| View Threaded | Show Only this Message

Hi Don,
           I was looking how to get any mouse even in a layer i was creating for the purpose of learning by 
           examples. I guess you are write  OMGraphicHandler has a lot of functionality just need to dig a bit
           more in it.
           Another thing,  I just notice a possible bug with the DateLayer, using the OpenMap example. The     
           date is not being updated except when the projection is changed. Did anyone notice that or I missed
           something ?
 
           Thanks      
            Mike
In a message dated 5/16/2008 12:04:16 P.M. Eastern Standard Time, dietrick@... writes:
Hi Mike,

Do you really need the MouseEvent object, or do you just want to know 
when things (clicks, mouse overs, etc) happen over your map objects?

The OMGraphicHandler has a lot of functionality already built into it 
to let you know when the mouse is doing something over your objects.  
Look at the com.bbn.openmap.layer.learn.InteractionLayer for guidance 
with respect to that.

You can respond to mouse clicks this way, too, with the selected(...) 
method, popping up a window with your picture in it.  Alternatively, 
you could construct html that references an image URL, and call 
layer.fireRequestBrowserContent(String browserContent).

Hope this helps,

Don

On May 14, 2008, at 4:19 PM, Ta3ban4@... wrote:

> Chirs , Kennedy and All
>
>          Thanks guys for taking the time to reply back.
>
>          I got the mouse event working by doing the following ; Not 
> sure if this is the best/correct way  ;
>
>             public class MyLatLongLayer extends 
> OMGraphicHandlerLayer implements MapMouseListener
>             {   ,,,,,,,
>                   public MapMouseListener getMapMouseListener()
> {return this;}
>                   public String[] getMouseModeServiceList(){ return 
> new String[] { SelectMouseMode.modeID };}
>             }
>
>
>          Then from my main program I load the different layers and 
> then do the following
>              MouseDelegator mouseDelegator = new MouseDelegator();
>             mapHandler.add(mouseDelegator);
>             SelectMouseMode selectMouseMode = new SelectMouseMode();
>             mapHandler.add(selectMouseMode);
>             NavMouseMode2  nav2=  new NavMouseMode2();
>             mapHandler.add(nav2);
>             ,,,,,
>            mapHandler.add(new MouseModeButtonPanel());
>
>           From main gui by selecting Gestures from the 
> MouseModeButton i received the different mouse events in 
> MyLatLongLayer
>           The layer would be added to display the lat/long position
>
>
>            finally Let me give you an idea about my school project 
> maybe you guys can give me some hints and ideas how to proceed .
>
>            My application side of that project is to receive  
> Aircraft objects that contain a lat/long and
>            some other simple information (N objects/sec ), display 
> them on a map  and load the appropriate shape/tiff files.
>           User shall be able to click on the aircraft and get the  
> information about that aircraft in pop up window/or like 
> LocationLayer that holds cities.
>            I will implement the ideas that guys mentioned.
>
>
> Thanks  in Advance
>
> Mike
>
> In a message dated 5/14/2008 2:10:46 P.M. Eastern Standard Time, kroberts@...
>  writes:
>
> Mike,
>
> Since you're extending OMGraphicHandlerLayer, capturing mouse events 
> is
> actually pretty easy.  You basically need to do a couple of things:
>
> 1) Override the receivesMapEvents() method to return true.
>
> 2) Call the setMouseModeIDsForEvents() method in your constructor to 
> set the
> MapMouseModes that you want to receive mouse clicks from.  You 
> probably want
> to listen for at least SelectMouseMode.
>
> 3) Override the appropriate method(s) to handle clicks on the layer:
> leftClick(), getItemsForMapMenu(), etc...
>
> One note: I don't think the default StandardMapMouseInterpreter 
> passes left
> clicks to the OMGraphicHandlerLayer by default.  You may need to 
> create your
> own class that extends StandardMapMouseInterpreter that overrides
> leftClick() and passes the mouse event to the leftClick() method of 
> your
> layer.  I think that's what I did.
>
> I hope this helps.
>
> -Kennedy
> --
> View this message in context: http://www.nabble.com/How-To-capture-Event-in-a-Layer-tp17193632p17237519.html
> Sent from the OpenMap mailing list archive at Nabble.com.
>
> --
> [To unsubscribe to this list send an email to "majdart@..."
> with the following text in the BODY of the message "unsubscribe 
> openmap-users"]
>
>
>
> Wondering what's for Dinner Tonight? Get new twists on family 
> favorites at AOL Food.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Don Dietrick, dietrick@...
BBN Technologies, Cambridge MA
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=



--
[To unsubscribe to this list send an email to "majdart@..."
with the following text in the BODY of the message "unsubscribe openmap-users"]




Wondering what's for Dinner Tonight? Get new twists on family favorites at AOL Food.

Re: How To capture Event in a Layer

by Don Dietrick :: Rate this Message:

| View Threaded | Show Only this Message

Hi Mike,

Regarding the DateLayer not updating the date except when the projection
changes - I don't know if that's really a bug, it's just how it was
written (in 1998).  It would be trivial to add a javax.swing.Timer class
that updated the label at regular intervals.

Cheers,

Don

Ta3ban4@... wrote:

> Hi Don,
>            I was looking how to get any mouse even in a layer i was
> creating for the purpose of learning by
>            examples. I guess you are write  OMGraphicHandler has a lot
> of functionality just need to dig a bit
>            more in it.
>            Another thing,  I just notice a possible bug with the
> DateLayer, using the OpenMap example. The    
>            date is not being updated except when the projection is
> changed. Did anyone notice that or I missed
>            something ?
>  
>            Thanks      
>             Mike
> In a message dated 5/16/2008 12:04:16 P.M. Eastern Standard Time,
> dietrick@... writes:
>
>     Hi Mike,
>
>     Do you really need the MouseEvent object, or do you just want to know
>     when things (clicks, mouse overs, etc) happen over your map objects?
>
>     The OMGraphicHandler has a lot of functionality already built into it
>     to let you know when the mouse is doing something over your objects.  
>     Look at the com.bbn.openmap.layer.learn.InteractionLayer for guidance
>     with respect to that.
>
>     You can respond to mouse clicks this way, too, with the selected(...)
>     method, popping up a window with your picture in it.  Alternatively,
>     you could construct html that references an image URL, and call
>     layer.fireRequestBrowserContent(String browserContent).
>
>     Hope this helps,
>
>     Don
>
>     On May 14, 2008, at 4:19 PM, Ta3ban4@... wrote:
>
>      > Chirs , Kennedy and All
>      >
>      >          Thanks guys for taking the time to reply back.
>      >
>      >          I got the mouse event working by doing the following ; Not
>      > sure if this is the best/correct way  ;
>      >
>      >             public class MyLatLongLayer extends
>      > OMGraphicHandlerLayer implements MapMouseListener
>      >             {   ,,,,,,,
>      >                   public MapMouseListener getMapMouseListener()
>      > {return this;}
>      >                   public String[] getMouseModeServiceList(){ return
>      > new String[] { SelectMouseMode.modeID };}
>      >             }
>      >
>      >
>      >          Then from my main program I load the different layers and
>      > then do the following
>      >              MouseDelegator mouseDelegator = new MouseDelegator();
>      >             mapHandler.add(mouseDelegator);
>      >             SelectMouseMode selectMouseMode = new SelectMouseMode();
>      >             mapHandler.add(selectMouseMode);
>      >             NavMouseMode2  nav2=  new NavMouseMode2();
>      >             mapHandler.add(nav2);
>      >             ,,,,,
>      >            mapHandler.add(new MouseModeButtonPanel());
>      >
>      >           From main gui by selecting Gestures from the
>      > MouseModeButton i received the different mouse events in
>      > MyLatLongLayer
>      >           The layer would be added to display the lat/long position
>      >
>      >
>      >            finally Let me give you an idea about my school project
>      > maybe you guys can give me some hints and ideas how to proceed .
>      >
>      >            My application side of that project is to receive  
>      > Aircraft objects that contain a lat/long and
>      >            some other simple information (N objects/sec ), display
>      > them on a map  and load the appropriate shape/tiff files.
>      >           User shall be able to click on the aircraft and get the  
>      > information about that aircraft in pop up window/or like
>      > LocationLayer that holds cities.
>      >            I will implement the ideas that guys mentioned.
>      >
>      >
>      > Thanks  in Advance
>      >
>      > Mike
>      >
>      > In a message dated 5/14/2008 2:10:46 P.M. Eastern Standard Time,
>     kroberts@...
>      >  writes:
>      >
>      > Mike,
>      >
>      > Since you're extending OMGraphicHandlerLayer, capturing mouse
>     events
>      > is
>      > actually pretty easy.  You basically need to do a couple of things:
>      >
>      > 1) Override the receivesMapEvents() method to return true.
>      >
>      > 2) Call the setMouseModeIDsForEvents() method in your constructor
>     to
>      > set the
>      > MapMouseModes that you want to receive mouse clicks from.  You
>      > probably want
>      > to listen for at least SelectMouseMode.
>      >
>      > 3) Override the appropriate method(s) to handle clicks on the layer:
>      > leftClick(), getItemsForMapMenu(), etc...
>      >
>      > One note: I don't think the default StandardMapMouseInterpreter
>      > passes left
>      > clicks to the OMGraphicHandlerLayer by default.  You may need to
>      > create your
>      > own class that extends StandardMapMouseInterpreter that overrides
>      > leftClick() and passes the mouse event to the leftClick() method of
>      > your
>      > layer.  I think that's what I did.
>      >
>      > I hope this helps.
>      >
>      > -Kennedy
>      > --
>      > View this message in context:
>     http://www.nabble.com/How-To-capture-Event-in-a-Layer-tp17193632p17237519.html
>      > Sent from the OpenMap mailing list archive at Nabble.com.
>      >
>      > --
>      > [To unsubscribe to this list send an email to "majdart@..."
>      > with the following text in the BODY of the message "unsubscribe
>      > openmap-users"]
>      >
>      >
>      >
>      > Wondering what's for Dinner Tonight? Get new twists on family
>      > favorites at AOL Food.
>
>     =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>     Don Dietrick, dietrick@...
>     BBN Technologies, Cambridge MA
>     =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>
>
>
>     --
>     [To unsubscribe to this list send an email to "majdart@..."
>     with the following text in the BODY of the message "unsubscribe
>     openmap-users"]
>
>
>
>
> ------------------------------------------------------------------------
> Wondering what's for Dinner Tonight? Get new twists on family favorites
> at AOL Food <http://food.aol.com/dinner-tonight?NCID=aolfod00030000000001>.

--
[To unsubscribe to this list send an email to "majdart@..."
with the following text in the BODY of the message "unsubscribe openmap-users"]

Re: How To capture Event in a Layer

by ramanForU :: Rate this Message:

| View Threaded | Show Only this Message

hi  

i am trying to do same but my object is city icon  by clicking on it it show information of city please guide me

i am using  SimpleMap2 example.
can mail also raman.pisl@gmail.com







Mike Lackey wrote:
Another Mike asks:

My application side of that project is to receive Aircraft objects
that contain a lat/long and some other simple information (N
objects/sec ), display them on a map and load the appropriate
shape/tiff files.  User shall be able to click on the aircraft and get
the information about that aircraft in pop up window/or like
LocationLayer that holds cities.
-------------------------

This Mike replies:  here is an earlier post for somebody who wanted to
display Mil Std icons.  An icon is an icon, maybe some of it is
useful.
--------------------------


I used OMScalingIcon. Here is an example:


public class MyIconObject
{
    /**
     * the openmap icon
     */
    protected OMScalingIcon omIcon = null;


    /** Creates a new instance of an icon object*/
    public MyIconObject(float lat, float lon, String fileName)
    throws MyException
    {
        if (fileName == null) {
            throw new MyException ("MyIconObject: null filename");
        }
        ImageIcon imageIcon = new ImageIcon(fileName);
        if (imageIcon == null) {
            throw new MyException ("MyIconObject: null ImageIcon");
        }
        omIcon = new OMScalingIcon(lat, lon, imageIcon);
        if (omIcon == null) {
            throw new MyException ("PointObject: null OMScalingIcon");
        }
        // at map scale of 1:500,000 the icon will appear full size
omIcon.setBaseScale(500000f);
        // icon will be scaled (larger) until map scale > value
        omIcon.setMaxScale(500000f);
        // icon will be scaled (smaller) until map scale < this value
        omIcon.setMinScale(defaultIconMinScale);
        // when selected, color is red
        omIcon.setSelectPaint(Color.red);
    }
}


For my applicaton, MyIconObject "has a" OMScalingIcon, rather than "is
a" OMScalingIcon. I chose this design for a particular reason. But the
"is a" relationship is also logical (and perhaps more intuituve):


public class MyIconObject extends OMScalingIcon
{
}


Next, BasicLocationHandler.java will need a list of all objects on the
map. The location handler is responsible for the creating/maintaining
the list. Here is sample code:


public class MyObjectHandler
{
    // a list of all objects on the map
    protected Vector<MyIconObject> objList;


    // add an object to the map
    public void addIconObject (MyIconObject obj) {
        objList.add(obj);
    }


    /**
     * When the layer receives a new projection, it goes to each
     * objectHandler and asks it for additions to the layer's graphic list
     */
    public void get
    (float nLat, float wLon, float sLat, float eLon, Vector graphicList)
    {
        for (int i=0; i<objList.size(); i++)
        {
            // the object is an icon image, or similar,
            // and is defined by a singular point.
            // if the point is within the projection, show the image.
            MyIconObject iconObj = objList.get(i);
            if ((sLat <= iconObj .getLat()) && (iconObj .getLat()<= nLat))
            {
                if ((wLon <= iconObj .getLon()) && (iconObj .getLon()<= eLon))
                {
                    graphicList.add(iconObj);
                }
            }
        }
    }
}


Finally, create icons and add them to the map:


      MyIconObject myIcon= new MyIconObject (lat, lon, "C:/somefile.png");
        MyObjectHandler myHandler = myLayer.getMyHandler();
        myHandler.add (myIcon);
        myLayer.doPrepare();

--------------------------
Mike

--
[To unsubscribe to this list send an email to "majdart@bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]