Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

When I plot an image on OpenLayers, it looks like that image is stretched a little bit as compared to Google Maps. I was wondering if it is normal or there is something wrong with my code.

OpenLayers: enter image description here

Google Maps (maps.google.com): enter image description here

Following is the XML :

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
  <Folder>
    <name>Ground Overlays</name>
    <description>Examples of ground overlays</description>
    <GroundOverlay>
      <name>Large-scale overlay on terrain</name>
      <description>Overlay shows Mount Etna erupting 
          on July 13th, 2001.</description>
      <Icon>
        <href>http://code.google.com/apis/kml/documentation/etna.jpg</href>
      </Icon>
      <LatLonBox>
        <north>37.91904192681665</north>
        <south>37.46543388598137</south>
        <east>15.35832653742206</east>
        <west>14.60128369746704</west>
        <rotation>59.1556640799496235</rotation>
      </LatLonBox>
    </GroundOverlay>


  </Folder>
</kml>

And following is my JavaScript code:

xml=jQuery.parseXML(oRequest.responseText)  //oRequest.responseText contains above xml

    groundOverlays=jQuery(xml).find('GroundOverlay');

    jQuery.each(groundOverlays,function(index, value){
        var groundOverlay=new Object();
        parentFolder=jQuery(groundOverlays).parent('Folder').find('name').text();

        groundOverlay.href=jQuery(value).find('href').text();
        groundOverlay.name=jQuery(value).find('name').text();
        groundOverlay.description=jQuery(value).find('description').text();
        groundOverlay.north=jQuery(value).find('north').text();
        groundOverlay.south=jQuery(value).find('south').text();
        groundOverlay.east=jQuery(value).find('east').text();
        groundOverlay.west=jQuery(value).find('west').text();
        groundOverlay.rotation=jQuery(value).find('rotation').text();



        var options = {   
            'opacity': 1.0, 
            'isBaseLayer': false,
            numZoomLevels : 20 ,
            //aspectRatio:50,

        };
        var image = new OpenLayers.Layer.Image(
            groundOverlay.name,
            groundOverlay.href,
            new OpenLayers.Bounds( groundOverlay.west, groundOverlay.south,  groundOverlay.east, groundOverlay.north),
            new OpenLayers.Size(1, 1),
            options
            );

        map.addLayers([image]);


    });
share|improve this question

2 Answers 2

up vote 2 down vote accepted

Spherical Mercator Projection is used for Google Maps API/Bing Map API.

One of the reasons that the Spherical Mercator projection is so important is that it is the only projection which will allow for overlaying image data on top of commercial layers like Google Maps correctly. When using raster images, in the browser, it is not possible to reproject the images in the same way it might be in a ‘thick’ GIS client. Instead, all images must be in the same projection.

How to create Spherical Mercator projected tiles depends on the software you are using to generate your images. MapServer is a possible route.

http://docs.openlayers.org/library/spherical_mercator.html

(See Creating Spherical Mercator Raster Images)

share|improve this answer

If you look closely, the map itself is also streched, so the image is displayed correctly related to the geographic coordinates in both maps.

share|improve this answer
    
Yes. You are right. Maps are itself stretched. Did not notice it before, thanks for pointing it out! I guess, this is because of different projects. –  Ajinkya Kulkarni Nov 15 '11 at 17:25
1  
If you look at the sea-lines you will see that the maps fits the image overlays perfectly, so It's really nothing wrong here. –  awe Nov 16 '11 at 8:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.