webcam.html 1.29 KB
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <style type="text/css">
        p {
            width: 512px;
        }
        #map {
            width: 640px;
            height: 480px;
            border: 1px solid gray;
        }
    </style>
    <script src="../lib/OpenLayers.js"></script>
    <script type="text/javascript">
        <!--
        var map;
        function init(){
            map = new OpenLayers.Map('map',
                {maxExtent: new OpenLayers.Bounds(0, 0, 640, 480)});

            var options = {maxResolution: 'auto', numZoomLevels: 3};
            
            var webcam = new OpenLayers.Layer.Image(
                                'OL Webcam',
                                'http://crschmidt.net/~crschmidt/openlayers.jpg',
                                new OpenLayers.Bounds(0, 0, 640, 480),
                                new OpenLayers.Size(640, 480),
                                options);

            map.addLayers([webcam]);
            map.zoomToMaxExtent();
            window.setInterval(refresh, 10000, webcam);
        }
        function refresh(layer) {
            layer.moveTo(layer.map.getExtent(), true);
        }
        // -->
    </script>
  </head>
  <body onload="init()">
    <h1>OpenLayers Webcam</h1>
    <div id="map"></div>
  </body>
</html>