[OpenLayers-Users] google, kml and projection alignment

Tim Perkis tim at perkis.com
Tue Dec 16 15:46:50 EST 2008


I'm new to this list, and to openlayers, so pardon me if this is a
well-discussed problem. But where I have seen some discussion of
projection issues with spherical mercator maps such as google's, I don't
seem to be able to find the right combination that allows my application
to work properly.

I'm attempting to build a viewer of a client's plant, an openlayers-based
view of three layers: a satellite base map such as a google hybrid, some
simple site features (building outlines) and a layer of real-time computed
data.  To derive the building layer, I defined a set of polygons tracing
building features in google earth and exported them as a .kml file.

The polygons display properly over the satellite map in Google Earth, but
in openlayers they are skewed and float nearby (moving relative to the base layer
with zoom level and site center). My openlayers code:
          ...
      function init() {
            var map = new OpenLayers.Map("map", {
              projection: new OpenLayers.Projection("EPSG:900913")
            });
             map.addControl(new OpenLayers.Control.LayerSwitcher());

           var ghyb = new OpenLayers.Layer.Google(
                "Google Hybrid",
                {type: G_HYBRID_MAP,
                  sphericalProjection: true,
                   numZoomLevels: 30}
            );
            map.addLayer(ghyb);

             var pgbldgs = new OpenLayers.Layer.GML("Buildings",
"kml/png-stl-SF.kml",
              {
              projection: new OpenLayers.Projection("EPSG:4326"),
              format: OpenLayers.Format.KML,
               formatOptions: {
                  extractStyles: true,
                  extractAttributes: true
                 }
            });
            map.addLayer(pgbldgs);
          map.zoomToExtent(new OpenLayers.Bounds(long1, lat1, long2, lat2));
}
...

Any help at where I might be going wrong in setting up the layer
projections -- or whatever else might be the problem! -- would be appreciated.





More information about the Users mailing list