OpenLayers OpenLayers

Ticket #1400: panels.2.patch

File panels.2.patch, 14.0 kB (added by tschaub, 3 months ago)

more control

  • theme/default/style.css

    old new  
    228228    filter: alpha(opacity=50); 
    229229}    
    230230 
    231 /*  
    232  * Due to current limitations in the OpenLayers code, you can only 
    233  * replace this image with another image which is 17px x 17px.  
    234  */    
     231.olControlPanPanel { 
     232    top: 10px; 
     233    left: 5px; 
     234}   
     235 
     236.olControlPanPanel div { 
     237    height: 18px; 
     238    width: 18px; 
     239    cursor: pointer; 
     240    position: absolute; 
     241
     242 
     243.olControlPanPanel .olControlPanButtonNorthItemInactive { 
     244    top: 0px; 
     245    left: 9px; 
     246    background-image: url(img/north-mini.png); 
     247
     248.olControlPanPanel .olControlPanButtonSouthItemInactive { 
     249    top: 36px; 
     250    left: 9px; 
     251    background-image: url(img/south-mini.png); 
     252
     253.olControlPanPanel .olControlPanButtonWestItemInactive { 
     254    position: absolute; 
     255    top: 18px; 
     256    left: 0px; 
     257    background-image: url(img/west-mini.png); 
     258
     259.olControlPanPanel .olControlPanButtonEastItemInactive { 
     260    top: 18px; 
     261    left: 18px; 
     262    background-image: url(img/east-mini.png); 
     263
     264 
     265.olControlZoomPanel { 
     266    top: 71px; 
     267    left: 14px; 
     268}  
     269 
     270.olControlZoomPanel div { 
     271    position: absolute; 
     272    height: 18px; 
     273    width: 18px; 
     274    cursor: pointer; 
     275
     276 
     277.olControlZoomPanel .olControlZoomInButtonItemInactive { 
     278    top: 0px; 
     279    left: 0px; 
     280    background-image: url(img/zoom-plus-mini.png); 
     281
     282 
     283.olControlZoomPanel .olControlZoomToMaxExtentItemInactive { 
     284    top: 18px; 
     285    left: 0px; 
     286    background-image: url(img/zoom-world-mini.png); 
     287
     288 
     289.olControlZoomPanel .olControlZoomOutButtonItemInactive { 
     290    top: 36px; 
     291    left: 0px; 
     292    background-image: url(img/zoom-minus-mini.png); 
     293
     294 
    235295.olPopupCloseBox { 
    236296  background: url("img/close.gif") no-repeat; 
    237297  cursor: pointer; 
  • lib/OpenLayers/Control/ZoomPanel.js

    old new  
     1/** 
     2 * @requires OpenLayers/Control/Panel.js 
     3 * @requires OpenLayers/Control/ZoomInButton.js 
     4 * @requires OpenLayers/Control/ZoomOutButton.js 
     5 * @requires OpenLayers/Control/ZoomToMaxExtent.js 
     6 */ 
     7 
     8/** 
     9 * Class: OpenLayers.Control.ZoomPanel 
     10 */ 
     11OpenLayers.Control.ZoomPanel = OpenLayers.Class(OpenLayers.Control.Panel, { 
     12 
     13    /** 
     14     * Constructor: OpenLayers.Control.ZoomPanel  
     15     * Add our two mousedefaults controls. 
     16     * 
     17     * Parameters: 
     18     * options - {Object} An optional object whose properties will be used 
     19     *     to extend the control. 
     20     */ 
     21    initialize: function(options) { 
     22        OpenLayers.Control.Panel.prototype.initialize.apply(this, [options]); 
     23        this.addControls([ 
     24          new OpenLayers.Control.ZoomInButton(), 
     25          new OpenLayers.Control.ZoomToMaxExtent(), 
     26          new OpenLayers.Control.ZoomOutButton() 
     27        ]); 
     28    }, 
     29 
     30    /** 
     31     * Method: draw  
     32     * calls the default draw, and then activates mouse defaults. 
     33     */ 
     34    draw: function() { 
     35        var div = OpenLayers.Control.Panel.prototype.draw.apply(this, arguments); 
     36        return div; 
     37    }, 
     38 
     39    CLASS_NAME: "OpenLayers.Control.ZoomPanel" 
     40}); 
  • lib/OpenLayers/Control/ZoomInButton.js

    old new  
     1/** 
     2 *  
     3 * @requires OpenLayers/Control/Control.js 
     4 */ 
     5 
     6/** 
     7 * Class: OpenLayers.Control.ZoomInButton 
     8 */ 
     9OpenLayers.Control.ZoomInButton = OpenLayers.Class(OpenLayers.Control, { 
     10 
     11    /* Property: type 
     12     * The type of OpenLayers.Control -- When are added to a Control.Panel 
     13     * the panel uses this to determine how to handle our events 
     14     * {String} 
     15     */ 
     16    type: OpenLayers.Control.TYPE_BUTTON, 
     17     
     18    /** 
     19     * Method: trigger 
     20     */ 
     21    trigger: function(){ 
     22        this.map.zoomIn(); 
     23    }, 
     24 
     25    CLASS_NAME: "OpenLayers.Control.ZoomInButton" 
     26}); 
  • lib/OpenLayers/Control/ZoomOutButton.js

    old new  
     1/** 
     2 *  
     3 * @requires OpenLayers/Control/Control.js 
     4 */ 
     5 
     6/** 
     7 * Class: OpenLayers.Control.ZoomInButton 
     8 */ 
     9OpenLayers.Control.ZoomOutButton = OpenLayers.Class(OpenLayers.Control, { 
     10 
     11    /* Property: type 
     12     * The type of OpenLayers.Control -- When are added to a Control.Panel 
     13     * the panel uses this to determine how to handle our events 
     14     * {String} 
     15     */ 
     16    type: OpenLayers.Control.TYPE_BUTTON, 
     17     
     18    /** 
     19     * Method: trigger 
     20     */ 
     21    trigger: function(){ 
     22        this.map.zoomOut(); 
     23    }, 
     24 
     25    CLASS_NAME: "OpenLayers.Control.ZoomOutButton" 
     26}); 
  • lib/OpenLayers/Control/PanButton.js

    old new  
     1/** 
     2 *  
     3 * @requires OpenLayers/Control/Control.js 
     4 */ 
     5 
     6/** 
     7 * Class: OpenLayers.Control.PanButton 
     8 */ 
     9OpenLayers.Control.PanButton = OpenLayers.Class(OpenLayers.Control, { 
     10 
     11    /**  
     12     * APIProperty: slideFactor 
     13     * {Integer} Number of pixels by which we'll pan the map in any direction  
     14     *     on clicking the arrow buttons.  
     15     */ 
     16    slideFactor: 50, 
     17 
     18    /**  
     19     * Property: direction 
     20     * {String} in {'NORTH', 'SOUTH', 'EAST', 'WEST'} 
     21     */ 
     22    direction: null, 
     23 
     24    /* Property: type 
     25     * The type of OpenLayers.Control -- When are added to a Control.Panel 
     26     * the panel uses this to determine how to handle our events 
     27     * {String} 
     28     */ 
     29    type: OpenLayers.Control.TYPE_BUTTON, 
     30 
     31    /** 
     32     * Constructor: OpenLayers.Control.PanButton  
     33     * Add our two mousedefaults controls. 
     34     * 
     35     * Parameters: 
     36     * direction - {String} The direction this button should pan 
     37     * options - {Object} An optional object whose properties will be used 
     38     *     to extend the control. 
     39     */ 
     40    initialize: function(dir, options) { 
     41     
     42        this.direction = dir; 
     43         
     44        switch(this.direction){ 
     45            case OpenLayers.Control.PanButton.NORTH: 
     46                this.CLASS_NAME += "North"; 
     47                break; 
     48            case OpenLayers.Control.PanButton.SOUTH: 
     49                this.CLASS_NAME += "South"; 
     50                break; 
     51            case OpenLayers.Control.PanButton.EAST: 
     52                this.CLASS_NAME += "East"; 
     53                break; 
     54            case OpenLayers.Control.PanButton.WEST: 
     55                this.CLASS_NAME += "West"; 
     56                break; 
     57        } 
     58         
     59        OpenLayers.Control.prototype.initialize.apply(this, [options]); 
     60         
     61        if(options && options.displayClass){ 
     62            this.displayClass = options.displayClass; 
     63        } 
     64    }, 
     65     
     66    /** 
     67     * Method: trigger 
     68     */ 
     69    trigger: function(){ 
     70     
     71        switch (this.direction) { 
     72            case OpenLayers.Control.PanButton.NORTH:  
     73                this.map.pan(0, -this.slideFactor); 
     74                break; 
     75            case OpenLayers.Control.PanButton.SOUTH:  
     76                this.map.pan(0, this.slideFactor); 
     77                break; 
     78            case OpenLayers.Control.PanButton.WEST:  
     79                this.map.pan(-this.slideFactor, 0); 
     80                break; 
     81            case OpenLayers.Control.PanButton.EAST:  
     82                this.map.pan(this.slideFactor, 0); 
     83                break; 
     84        } 
     85    }, 
     86 
     87    CLASS_NAME: "OpenLayers.Control.PanButton" 
     88}); 
     89 
     90OpenLayers.Control.PanButton.NORTH = "NORTH"; 
     91OpenLayers.Control.PanButton.SOUTH = "SOUTH"; 
     92OpenLayers.Control.PanButton.EAST = "EAST"; 
     93OpenLayers.Control.PanButton.WEST = "WEST"; 
  • lib/OpenLayers/Control/PanPanel.js

    old new  
     1/** 
     2 * @requires OpenLayers/Control/Panel.js 
     3 * @requires OpenLayers/Control/PanButton.js 
     4 */ 
     5 
     6/** 
     7 * Class: OpenLayers.Control.PanPanel 
     8 */ 
     9OpenLayers.Control.PanPanel = OpenLayers.Class(OpenLayers.Control.Panel, { 
     10 
     11    /** 
     12     * Constructor: OpenLayers.Control.PanPanel  
     13     * Add our two mousedefaults controls. 
     14     * 
     15     * Parameters: 
     16     * options - {Object} An optional object whose properties will be used 
     17     *     to extend the control. 
     18     */ 
     19    initialize: function(options) { 
     20        OpenLayers.Control.Panel.prototype.initialize.apply(this, [options]); 
     21        this.addControls([ 
     22          new OpenLayers.Control.PanButton(OpenLayers.Control.PanButton.NORTH), 
     23          new OpenLayers.Control.PanButton(OpenLayers.Control.PanButton.SOUTH), 
     24          new OpenLayers.Control.PanButton(OpenLayers.Control.PanButton.EAST), 
     25          new OpenLayers.Control.PanButton(OpenLayers.Control.PanButton.WEST) 
     26        ]); 
     27    }, 
     28 
     29    /** 
     30     * Method: draw  
     31     * calls the default draw, and then activates mouse defaults. 
     32     */ 
     33    draw: function() { 
     34        var div = OpenLayers.Control.Panel.prototype.draw.apply(this, arguments); 
     35        return div; 
     36    }, 
     37 
     38    CLASS_NAME: "OpenLayers.Control.PanPanel" 
     39}); 
  • lib/OpenLayers.js

    old new  
    208208            "OpenLayers/Layer/WFS.js", 
    209209            "OpenLayers/Control/MouseToolbar.js", 
    210210            "OpenLayers/Control/NavToolbar.js", 
     211            "OpenLayers/Control/PanPanel.js", 
     212            "OpenLayers/Control/PanButton.js", 
     213            "OpenLayers/Control/ZoomInButton.js", 
     214            "OpenLayers/Control/ZoomOutButton.js", 
     215            "OpenLayers/Control/ZoomPanel.js", 
    211216            "OpenLayers/Control/EditingToolbar.js", 
    212217            "OpenLayers/Lang.js", 
    213218            "OpenLayers/Lang/en.js" 
  • examples/pan-zoom-panels.html

    old new  
     1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
     2    "http://www.w3.org/TR/html4/loose.dtd"> 
     3<html> 
     4<head> 
     5    <title>Pan and Zoom Panels</title> 
     6    <style> 
     7    #mapDiv { 
     8        height: 256px; 
     9        width: 512px; 
     10    } 
     11    </style> 
     12    <script type="text/javascript" src="../lib/OpenLayers.js"></script> 
     13    <script> 
     14    var map; 
     15    var lon = 5; 
     16    var lat = 40; 
     17    var zoom = 5; 
     18    function init(){ 
     19        map = new OpenLayers.Map( 'mapDiv', {controls: []} ); 
     20         
     21        var wms = new OpenLayers.Layer.WMS( "OpenLayers WMS", 
     22                  "http://labs.metacarta.com/wms/vmap0", 
     23                  {layers: 'basic'} ); 
     24        map.addLayers([wms]); 
     25         
     26        map.setCenter(new OpenLayers.LonLat(lon, lat), zoom); 
     27        map.addControl( new OpenLayers.Control.PanPanel() ); 
     28        map.addControl( new OpenLayers.Control.ZoomPanel() ); 
     29    } 
     30    </script> 
     31</head> 
     32<body onload='init();'> 
     33<h1>Pan and Zoom Panels</h1> 
     34<div id="mapDiv"></div> 
     35<p>The pan and zoom panels allow you to use CSS styling to change the 
     36   look and feel of the panels, including changing their position 
     37   and their icons without needing to change any code. 
     38</p>    
     39</body> 
     40</html>