<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.StileMessaggioDiPostaElettronica17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 2.0cm 2.0cm 2.0cm;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=IT link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span lang=EN-US>I have to draw an image over the map as an overlay. The image is, for example, 400x400 pixels and represents an area of 400x400 kilometers. I'm using an Image Layer to do this. I have, as reference to place the image in the map, the lat/lon point of the center where the image should be positioned. To draw the image layer, I have to create a Bounds object, which needs the south-west lat/lon point and the north-east lat/lon point.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>The idea is this:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>    starting from the center point I calculate the south-west point going 200km south from center, and then 200km west. This way I get the south-west lat/lon point.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>    starting from the center point I calculate the north-east point going 200km north from center, and then 200km east. This way I get the north-east lat/lon point.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>    now I have the two points to create the Bounds object needed to create the image layer.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Everything is fine, but the problem is that the image is not rendered in the right position. The center of the image does not correspond to the center point I started the calculation but it's a little shifted like this:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>(see fig1.png in attachment)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>To calculate the south-west and north-east lat/lon coordinates I use a library found on Internet called "Geodesy by Mike Gavaghan".<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Here the code:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>//lat, lon are the coordinates of the center point<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>//initialize geodesy<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>GeodeticCalculator geoCalc = new GeodeticCalculator();<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>Ellipsoid reference = Ellipsoid.WGS84;<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>GlobalCoordinates coords = new GlobalCoordinates(lat, lon);<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>//get south-west corner<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>GlobalCoordinates south = geoCalc.calculateEndingGlobalCoordinates(reference, coords, 180, imgMetersHeight/2);<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>GlobalCoordinates southwest = geoCalc.calculateEndingGlobalCoordinates(reference, south, 270, imgMetersWidth/2);<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>//get north-east corner<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>GlobalCoordinates north = geoCalc.calculateEndingGlobalCoordinates(reference, coords, 0, imgMetersHeight/2);<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>GlobalCoordinates northeast = geoCalc.calculateEndingGlobalCoordinates(reference, north, 90, imgMetersWidth/2);<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>//create a bound using the calculated coordinates<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>Bounds bounds = new Bounds(southwest.getLongitude(), southwest.getLatitude(), northeast.getLongitude(), northeast.getLatitude());<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>bounds.transform(m_Proj4326, new Projection(m_Map.getProjection()));<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>//set options of the image<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>ImageOptions imgOptions = new ImageOptions();<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>imgOptions.setIsBaseLayer(false);<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>imgOptions.setTransitionEffect(TransitionEffect.RESIZE);<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>imgOptions.setAlwaysInRange(true);<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>imgOptions.setLayerOpacity(0.7);<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>imgOptions.setProjection("EPSG:900913");<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>//create the image layer and add to the map<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>imgLayer = new Image("my name", null, bounds, new Size(400, 400), imgOptions);<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>map.addLayer(imgLayer);<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>My questions:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>    What am I doing wrong?<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>    Are my calculations of south-west and north-east points correct?<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>    What should I do to draw correctly on the map an image placed and centered correctly?<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal>Thanks.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Magallo79<o:p></o:p></p></div></body></html>