I have a polygon in my map and I would like the map to only display the bounds that contains the polygon. I believe I have to code correct, but it is showing more than the bounds. I have tried setting the second parameter in zoomToExtent to both true and false. True cuts off the polygon, false shows too much map. Any help would be appreciated.
Example Code: <html> <head> <title>Test Map</title> <script type="text/javascript" src="OpenLayers.js"></script> <script type="text/javascript"> function doLoad() { var bounds = new OpenLayers.Bounds(); bounds.extend(new OpenLayers.LonLat(32.55191235791802, 30.161444708470064)); bounds.extend(new OpenLayers.LonLat(32.56959347974419, 30.132691427830416)); var map = new OpenLayers.Map('theMap', {maxExtent: bounds, minExtent: bounds, restrictedExtent: bounds}); map.addLayer(new OpenLayers.Layer.WMS("NASA Global Mosaic", "http://t1.hypercube.telascience.org/cgi-bin/landsat7", {layers: "landsat7"})); map.zoomToExtent(bounds, false); var vectorLayer = new OpenLayers.Layer.Vector("Vector Layer"); map.addLayer(vectorLayer); loadPolygon(vectorLayer); } function loadPolygon(theLayer) { var wkt = new OpenLayers.Format.WKT(); var wktFormat = "POLYGON((" wktFormat += "32.56873517285943 30.161444708470064,"; wktFormat += "32.56959347974419 30.132777258518892,"; wktFormat += "32.56667523633599 30.132691427830416,"; wktFormat += "32.55723386060357 30.14479355490561,"; wktFormat += "32.556804707161184 30.15054421103354,"; wktFormat += "32.55191235791802 30.158955618504244,"; wktFormat += "32.56873517285943 30.161444708470064"; wktFormat += "))"; theLayer.addFeatures(wkt.read(wktFormat)); } </script> </head> <body onload="doLoad();"> <div id="theMap" style="width: 500px; height: 600px; border: solid black 1px;"></div> </body> </html> -- View this message in context: http://www.nabble.com/Show-Limited-Area-of-Map-tp20629419p20629419.html Sent from the OpenLayers Users mailing list archive at Nabble.com. _______________________________________________ Users mailing list Users@openlayers.org http://openlayers.org/mailman/listinfo/users