On Tuesday, November 17, 2009, plen <petera...@earthlink.net> wrote: > > Hello, > > I am using OpenLayers 2.8 and based on multiple examples I found, I use the > following to load a Google Map map layer: > > ------------------------------ > var options = { > projection: new OpenLayers.Projection("EPSG:900913"), > units: "m", > maxResolution: 156543.0339, > maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34, > 20037508.34, 20037508.34) > }; > map = new OpenLayers.Map('map', options); > var layer = new OpenLayers.Layer.Google("Google", {"sphericalMercator": > true}); > map.addLayer(layer); > ------------------------------ > > I do indeed get the google map layer displayed but what I ran into is that > these options change how the OL API handles or deals with latlon > coordinates. For example, when I click on the map I get the following type > of "coordinate" when calling the OL getLatLongFromViewportPX() function: > (Lat: -39135.7584 / Lon: -273950.3093). If I do a map.getExtent(), which > typically returns the latlon for the SW and NE boundary corners, now returns > a value like -381458.9896 / -722521.0097, -322984.6629 / -686366.2955. > These are obviously not coordinates in degrees but some other value. My > application is expecting a decimal coordinate in degrees, which OL returns > in the getgetLatLongFromViewportPX() and getExtent() function calls when > google maps are not used. Now the app does not work. > > I see that the "unit" value listed in the options is "m". Not sure if that > is meters or some other value. The OpenLayers.Bounds value also does not > seem to be listed in a latlon coordinate. In order to get my coordinate > values in degrees, is there another set of options to use or is there some > formula/algorithm that can be applied to what comes back from the OL > functions in order to get the value I am looking for. > > Thanks for any insight - Peter
Yes, Google layers do not use the EPSG:4326 (lonl/at) coordinates system. You can reproject lonlat, bounds and geometry objects to EPSG:4326 using the transform method: obj.transform( new OpenLayers.Projection("EPSG:900913"), new OpenLayers.Projection("EPSG:4326") ); where obj is a LonLat, Bounds or Geometry object. Cheers, -- Eric Lemoine Camptocamp France SAS Savoie Technolac, BP 352 73377 Le Bourget du Lac, Cedex Tel : 00 33 4 79 44 44 96 Mail : eric.lemo...@camptocamp.com http://www.camptocamp.com _______________________________________________ Users mailing list Users@openlayers.org http://openlayers.org/mailman/listinfo/users