[OpenLayers-Users] NavToolbar breaks other controls?

Robert Hicks robhyx at gmail.com
Thu Nov 8 14:22:08 PST 2012


Hey all, I have a simple map with some controls, namely, an OpenLayers.Control.NavToolbar and another control which basically allows capturing of a box being drawn by holding down alt. When the pan / zoom is toggled on the map the latter of the two becomes 'broken' and no longer works. Is this a bug, or does this make sense and I'm just missing something? Thanks in advance! Below is the JavaScript and 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">
    <link rel="stylesheet" href="http://openlayers.org/dev/examples/../theme/default/style.css" type="text/css">
    <link rel="stylesheet" href="http://openlayers.org/dev/examples/style.css" type="text/css">
    <title>NavToolbar Demo</title>
    <style type='text/css'>    
        #map {
            height: 512px;
        }
    </style>    
    <script src="http://openlayers.org/dev/examples/../OpenLayers.js"></script>
    <script type="text/javascript">
        var lon = 5;
        var lat = 40;
        var zoom = 5;
        var map, layer;

        function init() {
            map = new OpenLayers.Map( 'map', { controls: [new OpenLayers.Control.PanZoom()] } );
            layer = new OpenLayers.Layer.WMS( "OpenLayers WMS", 
                    "http://vmap0.tiles.osgeo.org/wms/vmap0", {layers: 'basic'} );
            map.addLayer(layer);

            var panel = new OpenLayers.Control.NavToolbar();
            map.addControl(panel);
            
            var control = new OpenLayers.Control();
            OpenLayers.Util.extend(control, {
                draw: function () {
                    this.box = new OpenLayers.Handler.Box( control,
                        {"done": this.notice},
                        {keyMask: OpenLayers.Handler.MOD_ALT});
                    this.box.activate();
                },
                notice: function (bounds) {
                    areaSelected(bounds);
                }
            });
            map.addControl(control);

            map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
        }
    </script>
  </head>
  <body onload="init()">
    <h1 id="title">NavToolbar Demo</h1>
    <div id="tags">
        navigation toolbar, basic
    </div>
    <p id="shortdesc">
       Demo the NavToolbar, a subclass of Control.Panel which shows icons for
       navigation.
    </p> 
    <div id="map" class="smallmap"></div>
  </body>
</html>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20121108/a271d14e/attachment-0001.html>


More information about the Users mailing list