A mixin for layers that wraps up the pieces neccesary to have a coordinate conversion for working with commercial APIs which use a spherical mercator projection. Using this layer as a base layer, additional layers can be used as overlays if they are in the same projection.
A layer is given properties of this object by setting the sphericalMercator property to true.
+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs
900913=PROJCS[“WGS84 / Simple Mercator”, GEOGCS[“WGS 84”, DATUM[“WGS_1984”, SPHEROID[“WGS_1984”, 6378137.0, 298.257223563]], PRIMEM[“Greenwich”, 0.0], UNIT[“degree”, 0.017453292519943295], AXIS[“Longitude”, EAST], AXIS[“Latitude”, NORTH]], PROJECTION[“Mercator_1SP_Google”], PARAMETER[“latitude_of_origin”, 0.0], PARAMETER[“central_meridian”, 0.0], PARAMETER[“scale_factor”, 1.0], PARAMETER[“false_easting”, 0.0], PARAMETER[“false_northing”, 0.0], UNIT[“m”, 1.0], AXIS[“x”, EAST], AXIS[“y”, NORTH], AUTHORITY[“EPSG”,”900913”]]
OpenLayers. | A mixin for layers that wraps up the pieces neccesary to have a coordinate conversion for working with commercial APIs which use a spherical mercator projection. |
Functions | |
getExtent | Get the map’s extent. |
getLonLatFromViewPortPx | Get a map location from a pixel location |
getViewPortPxFromLonLat | Get a pixel location from a map location |
initMercatorParameters | Set up the mercator parameters on the layer: resolutions, projection, units. |
forwardMercator | Given a lon,lat in EPSG:4326, return a point in Spherical Mercator. |
inverseMercator | Given a x,y in Spherical Mercator, return a point in EPSG:4326. |
getLonLatFromViewPortPx: function ( viewPortPx )
Get a map location from a pixel location
viewPortPx | {OpenLayers.Pixel} |
{OpenLayers.LonLat} An OpenLayers.LonLat which is the passed-in view port OpenLayers.Pixel, translated into lon/lat by map lib If the map lib is not loaded or not centered, returns null
getViewPortPxFromLonLat: function ( lonlat )
Get a pixel location from a map location
lonlat | {OpenLayers.LonLat} |
{OpenLayers.Pixel} An OpenLayers.Pixel which is the passed-in OpenLayers.LonLat, translated into view port pixels by map lib If map lib is not loaded or not centered, returns null
Given a lon,lat in EPSG:4326, return a point in Spherical Mercator.
lon | {float} |
lat | {float} |
{OpenLayers.LonLat} The coordinates transformed to Mercator.
Given a x,y in Spherical Mercator, return a point in EPSG:4326.
x | {float} A map x in Spherical Mercator. |
y | {float} A map y in Spherical Mercator. |
{OpenLayers.LonLat} The coordinates transformed to EPSG:4326.
Get the map’s extent.
getExtent: function()
Get a map location from a pixel location
getLonLatFromViewPortPx: function ( viewPortPx )
Get a pixel location from a map location
getViewPortPxFromLonLat: function ( lonlat )
Set up the mercator parameters on the layer: resolutions, projection, units.
initMercatorParameters: function()