Skip to content

Instantly share code, notes, and snippets.

@pgiraud
Created September 21, 2012 09:09
Show Gist options
  • Save pgiraud/3760503 to your computer and use it in GitHub Desktop.
Save pgiraud/3760503 to your computer and use it in GitHub Desktop.
OL ClientZoom & img loading
var map;
function init() {
map = new OpenLayers.Map('map');
var wms = new OpenLayers.Layer.WMS(
"OpenLayers WMS",
"http://vmap0.tiles.osgeo.org/wms/vmap0",
{layers: 'basic'},
{serverResolutions: [1.40625,0.703125,0.3515625,0.17578125]}
);
map.addLayers([wms]);
// changing the blankImageUrl to a big orange star so that we easily see
// that the valid src url is not loaded
OpenLayers.Tile.Image.prototype.blankImageUrl = "data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAIdJREFUeNpi/D9VhwENqEDpO8iCLAyYYAKU9sGn0B6IvZHYB5EVmgGxMRT7IWlaDcSbgPgsCDMC3ZgDZExmwA9ymYDEFCCuwaMIJDeFCcppBeJ9WBTtg8oxMCEJCmFRyI/N13JA/AWIZ0H5aUCsiK6QB4i7gXg6EH+EijUBcSYQcwLxd4AAAwD5xRdUKc1DEwAAAABJRU5ErkJggg==";
map.zoomToMaxExtent();
map.zoomTo(4);
function myFunction() {
map.zoomTo(3);
}
window.setTimeout(myFunction, 400);
}
<!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>Slow Client Zoom Example</title>
<link rel="stylesheet" href="../theme/default/style.css" type="text/css"/>
<link rel="stylesheet" href="style.css" type="text/css">
<script src="http://www.openlayers.org/dev/lib/OpenLayers.js"></script>
<script src="clientzoom_slow.js"></script>
<style>
.olControlAttribution {
bottom: 5px;
}
#map {
width: 800px;
height: 600px;
}
</style>
</head>
<body onload="init();">
<h1 id="title">Client Zoom</h1>
<div id="tags">
client zoom continuous zooming
</div>
<div id="map"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment