[OpenLayers-Users] Trouble getting Yahoo layer to line up with mercator coordinates.

J. Clifford Dyer jcd at sdf.lonestar.org
Mon Nov 23 16:54:01 EST 2009


Hey all,

I posted a week or so back about some trouble I was having getting
coordinates from a box that users draw.  

Thanks for all the  help with the  box drawing code, and pointers to
information on Spherical Mercator and other projection issues.  I think
I'm starting to get a handle  on it.  

It never quite solved my original problem, but I've definitely managed
to narrow it down.  I'm drawing on a YahooMaps base layer, and the
latitude of the box that gets drawn seems not to line up with what I'm
actually drawing.  Specifically, it seems to show up about 15% of the
way between where I draw it and the top of the view window.  If I draw
at the top of the window, it's accurate; if I draw at the bottom of the
window, it's about 15% up the map from the  bottom.  Longitude renders
properly.

However, I've noticed that if I switch to a different base layer (I'm
working with an ol_wms layer right now), the box moves, and the base
layer moves, and everything lines up as it should.  So there's something
wrong with how I'm using the Yahoo Map.  I'm doing this:

    var yahoo_layer = new OpenLayers.Layer.Yahoo("Yahoo", {});

And all of my layers plus the map show up as EPSG:4326.

I had tried defining sphericalMercator: True, but then the map shows up
zoomed in on Sao Tome, and won't let me pan away from it.  The yahoo
layer and the map itself then show up as EPSG:900913, while the vector
layer and ol_wms layer show up as EPSG:4326.  

For what it's worth, I'm getting that information  from the following
code:

    alert("Map: " + map.getProjectionObject());
    alert("Yahoo: " + yahoo_layer.projection);
    alert("WMS: " + ol_wms.projection);
    alert("Vector: " + vector_layer.projection);

I'm still missing something in how to get my data into a consistent,
usable format.  Any ideas?

Cheers,
Cliff




More information about the Users mailing list