[OpenLayers-Users] google, kml and projection alignment

Jan van der Ven j.vanderven at magion.nl
Tue Dec 16 16:04:10 EST 2008


Dear Tim,

I add my hybrid google layer like this (sphericalMercator instead of
sphericalProjection):

    layer = new OpenLayers.Layer.Google( "Hybrid" , {type: G_HYBRID_MAP,
'sphericalMercator':true} );
    layer.addOptions({isBaseLayer: true, buffer: 1});
    map.addLayer(layer);  

And 900913 is in meters, not degrees, like Christopher Schmidt said.

Kind regards,


Jan


-----Original Message-----
From: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org] On
Behalf Of Tim Perkis
Sent: Tuesday, December 16, 2008 21:47
To: users at openlayers.org
Subject: [OpenLayers-Users] google, kml and projection alignment

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.


_______________________________________________
Users mailing list
Users at openlayers.org
http://openlayers.org/mailman/listinfo/users
No virus found in this incoming message.
Checked by AVG - http://www.avg.com
Version: 8.0.176 / Virus Database: 270.9.18/1848 - Release Date: 14-12-2008
12:28




More information about the Users mailing list