Thanks for #openlayers help on Friday, updating the OpenStreetMap slippy map [

http://www.openstreetmap.org/index.html]

At our next stage, we'll be looking at the MetaCarta TileCache, for integration with mapnik, and live requests

The tiles were generated in the Google Maps style (based off old code for generating tiles in the GMaps API).

This is almost exactly the same as TMS Global Profile 2, except that the Origin is in the Upper Left,

and tile number increases South-East.

(Slightly concerning, it seems that TMS could not theoretically be applied to Google Tiles, since the Origin is always Lower Right.

I wonder if this has been discussed? if it's a concern?)

The code to implement the Google Maps style tiling in OL was pretty easy, based off crschmidt's refractions class.

LikeGoogle.js is at

http://brainoff.com/osm/mapnik/OpenLayers-2.1/lib/OpenLayers/Layer/LikeGoogle.jsif it's useful to OL generally.

The tiling scheme also requires the correct bounds, projection, resolution, etc for the map..

map = new OpenLayers.Map( "map",

{maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34), maxResolution:156543, units:'meters', projection: "EPSG:41001"} );

layer = new OpenLayers.Layer.LikeGoogle( "OSM", "

http://artem.dev.openstreetmap.org/osm_tiles/", {type:'png'} );

This does mean that all map coordinates are in northing/easting, which required us to convert to lat/lon for integration in other parts of OSM

Perhaps this could be a useful small addition to OpenLayers, as it's likely the most common projection conversion people will want.

Degrees to Mercator

lon = lon * 20037508.34 / 180;

lat = Math.log(Math.tan( (90 + lat) * PI / 360)) / (PI / 180);

lat = lat * 20037508.34 / 180;

Mercator to Degrees

lon_deg = (lonlat.lon / 20037508.34) * 180;

lat_deg = (lonlat.lat / 20037508.34) * 180;

lat_deg = 180/PI * (2 * Math.atan(Math.exp(lat_deg * PI / 180)) - PI / 2);

-Mikel

_______________________________________________

Dev mailing list

[hidden email]
http://openlayers.org/mailman/listinfo/dev