[OpenLayers-Users] yet another spherical mercator / geographic question

Christopher Schmidt crschmidt at metacarta.com
Wed Nov 5 09:27:48 EST 2008


On Tue, Nov 04, 2008 at 04:36:27PM -0800, Andrew Schuh wrote:
> 
> I have managed to get all of my data in EPSG900913 believing that would help
> me overlay on google imagery but I still have a nagging problem.  I have a
> vector data source representing some polygons.  These display very
> accurately against google imagery at very high zoom levels, several hundred
> meters across in window.  As one zooms out, it becomes just slightly offset
> to the south, several hundred miles in window.  Not terrible, but definitely
> noticeable to a user, especially when the polygons are sandwiched up against
> a river bank.  The basics of the code are below.  Is this an error in my
> coding or a limit of what one can do w/ overlaying on the spherical mercator
> imagery?

I don't see an obvious error in your code, nor is this a problem I've
ever run into. Cna you provide an example that reproduces this publicly?
If not, ca you publish a full HTML page and a copy of data you can
reproduce the problem with?

-- Chris

> function initmap(){
>   var options = {
>       projection: new OpenLayers.Projection("EPSG:900913"),
>       displayProjection: new OpenLayers.Projection("EPSG:900913"),
>       units: "m",
>       maxResolution: 156543.0339,
>       maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,
> 20037508.34, 20037508.34),
>       numZoomLevels:22
>     };
> 
>   map = new OpenLayers.Map('map', options);
>    var gsat = new OpenLayers.Layer.Google(
>                 "Google Satellite",
>                 {type: G_SATELLITE_MAP,
>                  sphericalMercator: true }
>             );
> 
> 
> OpenLayers.loadURL("/rcbra/web/content/maps/DecisionUnits.geojson",
> 			null,
> 			this,
> 			onGeoJsonLoadSuccess,
> 			onGeoJsonLoadFailure
> 	);
> 			      	     
> 
> function onGeoJsonLoadSuccess(data) {
> 	var geojson_format = new OpenLayers.Format.GeoJSON();
> 	var pizzastores = new OpenLayers.Layer.Vector("GeoJSON Layer");  
>         map.addLayer(pizzastores);
>         //alert(data.responseText);
>         pizzastores.addFeatures(geojson_format.read(data.responseText));
> }
> 
> function onGeoJsonLoadFailure(data) {
>    
> }
> 
>     map.addLayers([gsat,terraservice]);
>     map.addControl(new OpenLayers.Control.ZoomBox());
>     map.addControl(new OpenLayers.Control.LayerSwitcher());
>     map.addControl(new OpenLayers.Control.MousePosition());
>     map.addControl(new OpenLayers.Control.Permalink());
> }
> -- 
> View this message in context: http://www.nabble.com/yet-another-spherical-mercator---geographic-question-tp20334402p20334402.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

-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list