1

Any ideas on how to get my raster overlay lined up properly on google maps? The geoserver layer is re-projected from EPSG:4269 to 3857 before serving it to google maps. To me it looks as if the longitudes are flipped.

Here is my code snippet and output on JSFiddle.

Here is the javascript:

function display_kmlmap() {
  var map_options = {};
  var map = new google.maps.Map(document.getElementById("map_canvas"), map_options);

  var kmlUrl = 'http://geoserver.usanpn.org/geoserver/si-x/wms?service=wms&request=GetMap&version=1.1.1&format=kml&layers=si-x:zabelli_bloom_prism&styles=leafout&height=1000&width=1000&transparent=true&bbox=-125.02083333333302,24.06249999929686,-66.479166666662,49.937499999073005&srs=EPSG:4326';
  var kmlOptions = {
    map: map
  };

  var kmlLayer = new google.maps.KmlLayer(kmlUrl, kmlOptions);
}

and html:

<body onload="display_kmlmap()">
  Testing SI-X kml overlay.
  <br/>
  <div id="map_canvas" style="width:500px; height:400px; float:left">
  </div>
</body>

And a screenshot: enter image description here

Here is a geoserver screenshot of my layer crs reprojection and bounding box: enter image description here

Here is the KML file as produced by geoserver:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:ns2="http://www.google.com/kml/ext/2.2" xmlns:ns3="http://www.w3.org/2005/Atom" xmlns:ns4="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0">
    <Document>
        <LookAt>
            <longitude>-101.29187627494827</longitude>
            <latitude>40.68941860702888</latitude>
            <altitude>6884659.870044568</altitude>
            <heading>0.0</heading>
            <tilt>0.0</tilt>
            <range>5563166.286905736</range>
            <altitudeMode>clampToGround</altitudeMode>
        </LookAt>
        <Folder>
            <name>si-x:zabelli_bloom_prism</name>
            <LookAt>
                <longitude>-101.29187627516126</longitude>
                <latitude>40.689418607858016</latitude>
                <altitude>6884659.869997282</altitude>
                <heading>0.0</heading>
                <tilt>0.0</tilt>
                <range>5563166.286867525</range>
                <altitudeMode>clampToGround</altitudeMode>
            </LookAt>
            <GroundOverlay>
                <name>si-x:zabelli_bloom_prism</name>
                <drawOrder>0</drawOrder>
                <Icon>
                    <href>http://geoserver.usanpn.org:80/geoserver/si-x/wms?service=wms&amp;request=GetMap&amp;version=1.1.1&amp;format=image%2Fpng&amp;layers=si-x%3Azabelli_bloom_prism&amp;styles=leafout&amp;height=1433&amp;width=768&amp;transparent=true&amp;bbox=-125.02083333333302%2C24.06249999929686%2C-66.479166666662%2C49.937499999073005&amp;srs=EPSG%3A4326</href>
                    <refreshInterval>0.0</refreshInterval>
                    <viewRefreshMode>never</viewRefreshMode>
                    <viewRefreshTime>0.0</viewRefreshTime>
                    <viewBoundScale>0.75</viewBoundScale>
                </Icon>
                <altitude>0.0</altitude>
                <LatLonBox>
                    <north>49.937499999073005</north>
                    <south>24.06249999929686</south>
                    <east>-125.02083333333302</east>
                    <west>-66.479166666662</west>
                    <rotation>0.0</rotation>
                </LatLonBox>
            </GroundOverlay>
        </Folder>
    </Document>
</kml>

If I edit the KML file and swap the values for east and west like so:

<LatLonBox>
<north>49.937499999073005</north>
<south>24.06249999929686</south>
<east>-66.479166666662</east>
<west>-125.02083333333302</west>
<rotation>0.0</rotation>
</LatLonBox>

and point Google Maps to the edited KML file then the raster overlays correctly. However, I don't want to manually edit the KML files.

Update (Aug 24, 2017) - Never did figure this out and we ended up not using kml to deliver these maps. I will point out that this server is currently running geoserver version 2.10.1.

  • Please put useful code and a screenshot in the question body, so that folks who won't (or can't) follow links aren't excluded from answering. This way the question can't be broken if a different site goes dark. – Vince Dec 8 '15 at 18:08
  • Please post the extents and coordinate system of your raster. Is it georeferenced? – mkennedy Dec 8 '15 at 18:44
  • Are you sure that the bbox parameter of your kmlURL is in the right order? – AndreJ Dec 9 '15 at 6:37
  • @AndreJ They are listed as minx,miny,maxx,maxy. &bbox=-125.02083333333302,24.06249999929686,-66.479166666662,49.937499999073005 The problem is that minx is getting mapped to east and maxx is getting mapped to west, but since they are both negative this should be reversed. Is there a way to flip the mapping? – apricity Dec 9 '15 at 18:38
  • I have the same problem, do you found a solution? I'm using geoserver 2.7.2 – Cintia Jan 18 '16 at 11:54
1

It looks like it might be a GeoServer bug on creating the KML.

I can see that a GetMap request with image/png output works:

http://geoserver.usanpn.org/geoserver/si-x/wms?service=WMS&request=GetMap&version=1.1.1&layers=si-x:zabelli_bloom_prism&styles=&WIDTH=786&HEIGHT=348&bbox=-125.02083333333302,24.06249999929686,-66.479166666662,49.937499999073005&srs=epsg:4326&FORMAT=image/png&

(I changed the width and height values to avoid distortion)

So asking for KML (I think the correct MIME type for the format is application/vnd.google-earth.kml+xml) as below should work, but as you say the West and East bounds are swapped.

http://geoserver.usanpn.org/geoserver/si-x/wms?service=WMS&request=GetMap&version=1.1.1&layers=si-x:zabelli_bloom_prism&styles=&WIDTH=786&HEIGHT=348&bbox=-125.02083333333302,24.06249999929686,-66.479166666662,49.937499999073005&srs=epsg:4326&format=application/vnd.google-earth.kml+xml&

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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