Hello Khalid,

That looks like you are calling Component.addMouseListener(
MouseListener ) rather
than JMapPane.addMouseListener( MapMouseListener ).

Are you perhaps accessing the map pane via a JPanel or similar reference ?

Michael

On 15 June 2011 22:07, khalid Amiral <[email protected]> wrote:
> thank you for the reply, but when i implements it gives me this error: "The
> method addMouseListener (MouseListener) such Component does not apply to
> arguments (new MapMouseAdapter (){})"!
>
>> Date: Wed, 15 Jun 2011 13:44:00 +1000
>> From: [email protected]
>> To: [email protected]
>> Subject: Re: [Geotools-gt2-users] Get point from click mouse
>>
>> Yes, I was just typing the same thing when Jody's reply came through :)
>>
>> Alexander, your approach works fine but it's less work to let GeoTools
>> do it for you like this...
>>
>> // Listen for mouse clicks in the map pane
>> mapPane.addMouseListener(new MapMouseAdapter() {
>> @Override
>> public void onMouseClicked(MapMouseEvent ev) {
>> // Get the world position of the mouse
>> DirectPosition2D pos = ev.getMapPosition();
>> ...
>> }
>> });
>>
>> You can use the MapMouseListener interface directly, rather than the
>> adapter class, if you wish. Here are some useful javadoc pages...
>>
>>
>> http://docs.geotools.org/stable/javadocs/org/geotools/swing/event/MapMouseEvent.html
>>
>> http://docs.geotools.org/stable/javadocs/org/geotools/swing/event/MapMouseListener.html
>>
>> Michael
>>
>>
>> On 15 June 2011 13:26, Jody Garnett <[email protected]> wrote:
>> > I thought there was some kind of MapEvent that did the coordinate
>> > transformation for you ... MapMouseEvent has some of that figured out
>> > already.
>> >
>> > --
>> > Jody Garnett
>> >
>> > On Wednesday, 15 June 2011 at 8:54 AM, Alexander Lanin wrote:
>> >
>> > Hi,
>> >
>> > here is what I’m using. I’m new to GeoTools so feel free to correct me
>> > everyone!
>> > I have this code in JMapPane:
>> >
>> > public void mouseClicked(MouseEvent e) {
>> > // get the geographic position the mouse is pointing to
>> > DirectPosition2D geoCoords = getScreenToWorldPos(e.getPoint());
>> > ...
>> > }
>> >
>> > /**
>> > * Convert Screen point to Map/World point
>> > * @param point point on screen
>> > * @return point in map
>> > */
>> > public DirectPosition2D getScreenToWorldPos(Point point) {
>> > assert ( point != null );
>> >
>> > DirectPosition2D geoCoords = new DirectPosition2D(point.getX(),
>> > point.getY());
>> >
>> > AffineTransform t = getScreenToWorldTransform();
>> > assert ( t != null );
>> >
>> > t.transform(geoCoords, geoCoords);
>> >
>> >
>> > geoCoords.setCoordinateReferenceSystem(getMapContext().getCoordinateReferenceSys
>> > tem());
>> >
>> > assert ( geoCoords != null );
>> > return geoCoords;
>> > }
>> >
>> > Regards,
>> > Alex
>> >
>> >
>> >
>> > Von: khalid Amiral [mailto:[email protected]]
>> > Gesendet: Mittwoch, 15. Juni 2011 00:25
>> > An: [email protected]
>> > Betreff: [Geotools-gt2-users] Get point from click mouse
>> >
>> > Heloo,
>> > please How can i get coordinates point after click mouse, because i want
>> > to
>> > use
>> > it in  WMS/GetFeatureInfo request (request.setQueryPoint(X,Y)).
>> > if there is an example or tutorial will be better.
>> >
>> > Thank you in advance
>> >
>> >
>> >
>> > ------------------------------------------------------------------------------
>> > EditLive Enterprise is the world's most technically advanced content
>> > authoring tool. Experience the power of Track Changes, Inline Image
>> > Editing and ensure content is compliant with Accessibility Checking.
>> > http://p.sf.net/sfu/ephox-dev2dev
>> > _______________________________________________
>> > Geotools-gt2-users mailing list
>> > [email protected]
>> > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>> >
>> >
>> >
>> > ------------------------------------------------------------------------------
>> > EditLive Enterprise is the world's most technically advanced content
>> > authoring tool. Experience the power of Track Changes, Inline Image
>> > Editing and ensure content is compliant with Accessibility Checking.
>> > http://p.sf.net/sfu/ephox-dev2dev
>> > _______________________________________________
>> > Geotools-gt2-users mailing list
>> > [email protected]
>> > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>> >
>> >
>>
>>
>> ------------------------------------------------------------------------------
>> EditLive Enterprise is the world's most technically advanced content
>> authoring tool. Experience the power of Track Changes, Inline Image
>> Editing and ensure content is compliant with Accessibility Checking.
>> http://p.sf.net/sfu/ephox-dev2dev
>> _______________________________________________
>> Geotools-gt2-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>

------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to