[OpenLayers-Users] projections, ESPG 4326 and 900913

George Mu'ammar George at muammar.net
Sat Sep 27 15:28:37 EDT 2008


Andrew,

Openlayers cannot reproject a layer on the fly.
If you have administrator access to the WMS server you must configure  
it to serve maps in the projection that you need. Presumably this will  
be 900913 (because you can't ask Google and others to serve you maps  
in 4326).
Therefore you must request maps from all servers in the same  
projection if you want to overlay them. If google/MS/yahoo are  
involved then it must be 900913.

Hope that helps

-- 
George


Quoting Andrew Schuh <andys at neptuneinc.org>:

>
> I want to say first of all that this is a great suite of code and I apologize
> in advance if this question has been posed in various fashions before,
> because I assume most people have run into this.  I tend to find a lot of
> GIS data coming over the web in either ESPG 4326 or 900913 and often it
> doesn't seem like there is a an easy way to get both on the same map.  For
> example, I would like to use the USGS aerial imagery at www.terraservice.net
> and overlay either political boundaries or roads or something.  Previously I
> have used landsat7 w/ Mapnik using an example I found on the web.  Currently
> I'm trying to bring together the terraservice w/ openstreetmap or mapnik.  I
> can get terraservice working in 4326 and openstreetmap in 900913 but I can't
> seem to get them together, regardless of being willing to work in either
> projection.  I understand projections reasonably enough but I must be
> confused about the way reprojections are available.  The type of thing I'm
> trying to do is in code below (not complete).  Server side projections seem
> like the way to go if they are available but I have not had much luck in
> trying to reproject in this way.  Often it seems that either 4326 or 900913
> is available but not the other.  I'm assuming that "projection:" arg is fed
> to the WMS server to get data is that projection.  The reprojection examples
> always concern a couple of points (and not layer) so I've assumed either
> this can't be done w/ layers or is too inefficient.  Am I just confused
> about how to do it or is there really a void between putting many maps
> together on the fly?
>
> function initmap(){
>   var options = {
>       //projection: "EPSG:900913",
>       projection: "EPSG:4326",
>       //displayProjection: new OpenLayers.Projection("EPSG:4326"),
>       maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34,
>                                      20037508.34, 20037508.34),
>       //maxExtent: new OpenLayers.Bounds(-130, 20,
>       //                                -90, 50),
>   };
>
>   var terraservice = new OpenLayers.Layer.WMS(
>       "Terraservice",
>       ["http://terraservice.net/ogcmap.ashx?"],
>       {'layers': 'DOQ',
>       }
>   );
>
>  var mapnik = new OpenLayers.Layer.TMS(
>       "Mapnik",
>
> ["http://t1-overlay.hypercube.telascience.org/tiles/1.0.0/osm-merc-google-hybrid/",
>
> "http://t3-overlay.hypercube.telascience.org/tiles/1.0.0/osm-merc-google-hybrid/",
>
> "http://t2-overlay.hypercube.telascience.org/tiles/1.0.0/osm-merc-google-hybrid/"],
>       {
>           type: 'png', getURL: osm_getTileURL,
>           displayOutsideMaxExtent: true,
>           isBaseLayer: false, visibility: true
>       }
>   );
>
> map.addLayers([terraservice,mapnik]);
>
>
>
> I also tried to modify the javascript in the OpenStreetMap.js available for
> the Open Street data by changing the parameters in the top class from 900913
> to 4326 but that didn't seem to work either.   Not sure if this is even
> reasonable to try.  A bit confused about this all, any help would be
> appreciated.  By the way, I have used the openlayers code successfully but
> just where the map servers are all providing stuff in the same projection.
>
>
>
> /**
>  * @requires OpenLayers/Layer/TMS.js
>  *
>  * Class: OpenLayers.Layer.OSM
>  *
>  * Inherits from:
>  *  - <OpenLayers.Layer.TMS>
>  */
> OpenLayers.Layer.OSM = OpenLayers.Class(OpenLayers.Layer.TMS, {
>     /**
>      * Constructor: OpenLayers.Layer.OSM
>      *
>      * Parameters:
>      * name - {String}
>      * url - {String}
>      * options - {Object} Hashtable of extra options to tag onto the layer
>      */
>     initialize: function(name, url, options) {
>         options = OpenLayers.Util.extend({
>             attribution: "Data by  http://openstreetmap.org/ OpenStreetMap
> ",
>             maxExtent: new
> OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),
>             maxResolution: 156543.0339,
>             //maxExtent: new OpenLayers.Bounds(-130, 20,-90, 50),
>             units: "m",
>             //projection: "EPSG:4326",
>             projection: "EPSG:900913",
>             transitionEffect: "resize"
>         }, options);
>         var newArguments = [name, url, options];
>         OpenLayers.Layer.TMS.prototype.initialize.apply(this, newArguments);
>     },
> --
> View this message in context:   
> http://www.nabble.com/projections%2C-ESPG-4326-and-900913-tp19697076p19697076.html
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>





More information about the Users mailing list