OpenLayer Coordinate System

I'm struggling to understand the coordinate system used by OpenLayers.

Leicester, UK is at approx.

Latitude:  52.63973017532399
Longitude: -1.142578125

But to display the same location using OpenLayers I have to use:

Latitude:  6915601.9146245
Longitude: -125089.1967713

e.g:

var center  = new OpenLayers.LonLat(-125089.1967713, 6915601.9146245);
var map     = new OpenLayers.Map("demoMap");
map.addLayer(new OpenLayers.Layer.OSM());
map.setCenter(center, 12);

These are clearly not Latitude-Longitude coordinates, is there some conversion I need to take account of?

A working example is http://craig-russell.co.uk/demos/openlayers/so_map.html

Answers


It looks like I do need to map between coordinate systems. This is done with the transform() function like so:

var coor_from = new OpenLayers.Projection("EPSG:4326");
var coor_to   = new OpenLayers.Projection("EPSG:900913");
var center    = new OpenLayers.LonLat(-1.142578125, 52.63973017532399);
var map       = new OpenLayers.Map("demoMap");
center.transform(coor_from, coor_to);
map.addLayer(new OpenLayers.Layer.OSM());
map.setCenter(center, 12);

Now it is possible to do:

var map = new OpenLayers.Map("demoMap");
var p = map.getView().getProjection();
var cord = ol.proj.fromLonLat([longitude, latitude], p);

Need Your Help

How can I convert string date number to datetime in JavaScript?

javascript date-format

I have this date format that I wanna show it rightly formatted on the page:

Bad request API google Python

python request

I was getting usually send the request by the code below, but out of nowhere he started the mistake and do not want to send. Could anyone help me?