JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<title>Basic Google Tiles with a Subset of Resolutions Example</title>
<link rel="stylesheet" href="http://dev.openlayers.org/releases/OpenLayers-2.11/theme/default/style.css" type="text/css"/>
<link rel="stylesheet" href="http://dev.openlayers.org/releases/OpenLayers-2.11/theme/default/google.css" type="text/css"/>
<link rel="stylesheet" href="http://dev.openlayers.org/releases/OpenLayers-2.11/examples/style.css" type="text/css"/>
<style type="text/css">
.olControlAttribution {
left: 2px;
right: inherit;
bottom: 3px;
line-height: 11px;
}
</style>
</head>
<body>
<h1 id="title">Google Tiles with a Subset of Resolutions Example</h1>
<div id="tags">
google tiles restrictedMinZoom numZoomLevels
</div>
<div id="shortdesc">Use Google with direct tile access</div>
<div id="map" class="smallmap" style="height: 350px;"></div>
<div id="docs">
<p>
This example shows how to use the <code>maxResolution</code> and
<code>numZoomLevels</code> layer properties to restrict
the number of zoom levels displayed on the Google layer.
</p>
</div>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?v=3.5&sensor=false"></script>
<script type="text/javascript" src="http://dev.openlayers.org/releases/OpenLayers-2.11/lib/OpenLayers.js"></script>
</body>
</html>
JavaScript
function googleTilesWithASubsetOfResolutionsExample()
{
var proj900913 = new OpenLayers.Projection( "EPSG:900913" ); //Spherical mercator used for google maps
var vegasAirport = new OpenLayers.Bounds ( -12821203.157925, 4310035.6046593, -12815126.414177, 4314851.1374406 );
var options = {
maxExtent: vegasAirport.clone(),
restrictedExtent : vegasAirport.clone (),
projection : proj900913,
displayProjection: proj900913,
units : "m",
controls: [new OpenLayers.Control.PanZoomBar(), new OpenLayers.Control.Navigation()]
};
var map = new OpenLayers.Map( 'map', options );
var gmap = new OpenLayers.Layer.Google("gmap", { MIN_ZOOM_LEVEL: 15, MAX_ZOOM_LEVEL: 18 } );
gmap.RESOLUTIONS = gmap.RESOLUTIONS.slice( gmap.MIN_ZOOM_LEVEL, gmap.MAX_ZOOM_LEVEL );
gmap.maxExtent = vegasAirport.clone();
map.addLayers( [gmap] );
gmap.resolutions = gmap.RESOLUTIONS;
map.zoomToExtent( vegasAirport.clone() );
window.olMap = map;
}
googleTilesWithASubsetOfResolutionsExample();