function openlayers_get_resolutions in Openlayers 6.2
Same name and namespace in other branches
- 7.2 openlayers.module \openlayers_get_resolutions()
Get resolution given projection
Returns a default set of resolutions for standard TMS, WMS, etc servers serving up common projections. Layers supporting less common projections and resolutions can easily define custom resolutions arrays.
Parameters
$projection: String specifying which projection this should take, like 900913.
$zoom_start: Integer of first zoom level, default 0.
$zoom_end: Integer of last zoom level, default FALSE.
Return value
Array of resolutions.
10 calls to openlayers_get_resolutions()
- openlayers_layer_type_google::options_init in includes/
layer_types/ google.inc - Provide initial values for options.
- openlayers_layer_type_maptiler::options_form in includes/
layer_types/ maptiler.inc - Options form which generates layers
- openlayers_layer_type_maptiler::options_init in includes/
layer_types/ maptiler.inc - Provide initial values for options.
- openlayers_layer_type_osm::options_form in includes/
layer_types/ osm.inc - Options form which generates layers
- openlayers_layer_type_osm::options_init in includes/
layer_types/ osm.inc - Provide initial values for options.
File
- ./
openlayers.module, line 794 - Main OpenLayers API File
Code
function openlayers_get_resolutions($projection, $zoom_start = 0, $zoom_end = FALSE) {
switch ($projection) {
case '900913':
// 16 zoom levels, taken from
// openlayers.org TMS map
$res = array(
156543.0339,
78271.51695,
39135.758475,
19567.8792375,
9783.939618750001,
4891.969809375,
2445.9849046875,
1222.99245234375,
611.496226171875,
305.7481130859375,
152.87405654296876,
76.43702827148438,
38.21851413574219,
19.109257067871095,
9.554628533935547,
4.777314266967774,
2.388657133483887,
1.1943285667419434,
0.5971642833709717,
);
break;
case '4326':
// 16 zoom levels, taken from
// openlayers.org default WMS map
$res = array(
0.703125,
0.3515625,
0.17578125,
0.087890625,
0.0439453125,
0.02197265625,
0.010986328125,
0.0054931640625,
0.00274658203125,
0.001373291015625,
0.0006866455078125,
0.00034332275390625,
0.000171661376953125,
8.58306884765625E-5,
4.291534423828125E-5,
2.1457672119140625E-5,
);
break;
default:
$res = array();
break;
}
$length = $zoom_end == FALSE ? NULL : $zoom_end - $zoom_start;
// By default this will not actually clip the array
$resolutions = array_slice($res, $zoom_start, $length);
return $resolutions;
}