Positioning_to_geo_coordinates

3 messages Options
Embed this post
Permalink
iceDice

Positioning_to_geo_coordinates

Reply Threaded More More options
Print post
Permalink
Hello,

I am trying to implement positioning to geo-coordinates in JMapPane.
E.g. when user sets latitude and longitude of location, i need to zoom to and to center to
that location on map in JMapPane.
Any ideas how this could be accomplished?

Thanks.
mbedward

Re: Positioning_to_geo_coordinates

Reply Threaded More More options
Print post
Permalink
Hello,

Something like this perhaps...

double centreX = ...  // desired map location x coord
double centreY = ...  // desired map location y coord
double mapSide = ...  // length of the longest side of the new map
display, in appropriate geo coords

com.vividsolutions.jts.geom.Envelope env = new
com.vividsolutions.jts.geom.Envelope(
    centreX - mapSide/2, centreX + mapSide/2,
    centreY - mapSide/2, centreY + mapSide/2);

myMapPane.setMapArea( env );
myMapPane.repaint();


Hope this helps
Michael

------------------------------------------------------------------------------
_______________________________________________
Geotools-gt2-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
iceDice

Re: Positioning_to_geo_coordinates

Reply Threaded More More options
Print post
Permalink
Thank you Michael, it works.

I have just one question:
How to transform latitude and longitude of the point on the map to the screen coordinates?
Is there some API for that in GeoTools?

Thanks.

mbedward wrote:
Hello,

Something like this perhaps...

double centreX = ...  // desired map location x coord
double centreY = ...  // desired map location y coord
double mapSide = ...  // length of the longest side of the new map
display, in appropriate geo coords

com.vividsolutions.jts.geom.Envelope env = new
com.vividsolutions.jts.geom.Envelope(
    centreX - mapSide/2, centreX + mapSide/2,
    centreY - mapSide/2, centreY + mapSide/2);

myMapPane.setMapArea( env );
myMapPane.repaint();


Hope this helps
Michael

------------------------------------------------------------------------------
_______________________________________________
Geotools-gt2-users mailing list
Geotools-gt2-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users