1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Using maxResolution to control overlays</title> <link rel="stylesheet" href="../theme/default/style.css" type="text/css" /> <link rel="stylesheet" href="style.css" type="text/css" /> <style> #map { height: 350px; } </style> <!-- this gmaps key generated for http://openlayers.org/dev/ --> <script src='http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhR_wWLPFku8Ix9i2SXYRVK3e45q1BQUd_beF8dtzKET_EteAjPdGDwqpQ'></script> <!-- Localhost key --> <!-- <script src='http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhT2yXp_ZAY8_ufC3CFXhHIE1NvwkxTS6gjckBmeABOGXIUiOiZObZESPg'></script>--> <script src="../lib/OpenLayers.js"></script> <script type="text/javascript"> var map; function init(){ // Variables map = new OpenLayers.Map('map', { controls: [ new OpenLayers.Control.PanZoomBar(), new OpenLayers.Control.LayerSwitcher({'ascending':false}), new OpenLayers.Control.MousePosition(), new OpenLayers.Control.Navigation() ] }); var lon = 35; var lat = -6; var zoom = 6; // Map Layers var GMapsSat = new OpenLayers.Layer.Google( "Google Satellite" , {type: G_SATELLITE_MAP, 'maxZoomLevel':18} ); var GMapsHybr = new OpenLayers.Layer.Google( "Google Hybrid" , {type: G_HYBRID_TYPE, 'maxZoomLevel':18} ); var GMapsStreets = new OpenLayers.Layer.Google( "Google Steets" , {type: G_NORMAL_MAP, 'maxZoomLevel':18} ); var MarkersLayer2 = new OpenLayers.Layer.Text( "Region info", {location: "outOfRangeMarkers.txt", maxResolution: 0.02}); // Add Layers map.addLayers([GMapsHybr, GMapsStreets, GMapsSat, MarkersLayer2]); // Visual map.setCenter(new OpenLayers.LonLat(lon, lat), zoom); if (!map.getCenter()) map.zoomToMaxExtent(); } </script> </head> <body onload="init()"> <h3 id="title">Using maxResolution to control overlays</h3> <p id="shortdesc"> See how to control the maximum resolution for a markers layer, causing it to not be displayed beyond a certain point. </p> <div id="map" class="smallmap"></div> </body> </html> |