openlayers/openlayers — pull request #248 by ahocevar (2012-02-27 08:36:07+00:00)
Title: Allow map and layer coordinates to be provided as latitude and longitude.

As a follow-up to bce3aced237ef2cdbd74d464bf03ee1692e7047a, this change adds more convenience to coordinate handling. Instead of configuring a map like this:

var map = new OpenLayers.Map({
div: "map",
projection: "EPSG:3857",
maxExtent: [-18924313.432222, -15538711.094146, 18924313.432222, 15538711.094146],
restrictedExtent: [-13358338.893333, -9608371.5085962, 13358338.893333, 9608371.5085962],
center: [-12356463.476333, 5621521.4854095]
});

uses can now use latitudes and longitudes to set extents and center:

var map = new OpenLayers.Map({
div: "map",
projection: "EPSG:3857",
maxExtent: [{lat: -80, lon: -170}, {lat: 80, lon: 170}],
restrictedExtent: [{lat: -65, lon: -120}, {lat: 65, lon: 120}],
center: {lat: 45, lon: -111}
});

And instead of configuring a layer like this:

var layer = new OpenLayers.Layer(null, {
projection: "EPSG:3857",
maxExtent: [-20037508.34, 5621521.4854095, 0, 19971868.877628]
});

it is now possible to work with latitude and longitude as well:

var layer = new OpenLayers.Layer(null, {
projection: "EPSG:3857",
maxExtent: [{lat: 45, lon: -180}, {lat: 85, lon: 0}]
});