[OSM-dev] strange OpenLayers longitude and latitude
Vladimir Elistratov
v_elistratov at rambler.ru
Thu Aug 30 18:06:58 BST 2007
Hi!
I added the option to see the longitude and latitude for the TMS Layer
http://tile.openstreetmap.org
It is well known line:
map.addControl(new OpenLayers.Control.MousePosition());
The longitude and latitude seem to be quite strange. Say, the
longitude for London is around 90.
What is the problem about! How is it possible to get "normal"
longitude and latitude?
I attach the small file for you to see how it happens.
The related Javascript code:
<script type="text/javascript">
var lon = 90;
var lat = 29;
var zoom = 6;
var map, layer;
function init(){
map = new OpenLayers.Map( 'map',
{maxResolution:1.40625/2} );
var mapnik = new OpenLayers.Layer.TMS("Mapnik",
"http://tile.openstreetmap.org/",
{ type: 'png', getURL:
getTileURL, displayOutsideMaxExtent: true });
map.addLayer(mapnik);
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.addControl(new OpenLayers.Control.MousePosition());
map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
}
function getTileURL(bounds) {
var res = this.map.getResolution();
var x = Math.round((bounds.left - this.maxExtent.left) / (res *
this.tileSize.w));
var y = Math.round((this.maxExtent.top - bounds.top) / (res *
this.tileSize.h));
var z = this.map.getZoom();
var limit = Math.pow(2, z);
if (y < 0 || y >= limit)
{
return OpenLayers.Util.getImagesLocation() + "404.png";
}
else
{
x = ((x % limit) + limit) % limit;
return this.url + z + "/" + x + "/" + y + "." + this.type;
}
}
</script>
Thank you for any advice!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/dev/attachments/20070830/28e1a154/attachment.html>
More information about the dev
mailing list