OpenLayers OpenLayers

Changeset 847

Show
Ignore:
Timestamp:
06/30/06 22:41:21 (2 years ago)
Author:
crschmidt
Message:

Add support to Permalink control to automatically create Permalink inside map div if no element is given. This isn't pretty, but it's a good way to quickly/easily add a permalink to your map.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openlayers/examples/controls.html

    r846 r847  
    3535            map.addControl(new OpenLayers.Control.MouseToolbar()); 
    3636            map.addControl(new OpenLayers.Control.LayerSwitcher()); 
     37            map.addControl(new OpenLayers.Control.Permalink()); 
    3738            map.addControl(new OpenLayers.Control.Permalink($('permalink'))); 
    38             // map.setCenter(new OpenLayers.LonLat(0, 0), 0); 
    3939            if (!map.getCenter()) map.zoomToMaxExtent(); 
    4040        } 
     
    4444  <body onload="init()"> 
    4545    <h1>OpenLayers Example</h1> 
    46     <a href="" id="permalink">Permalink</a><br /
     46    <a style="float:right" href="" id="permalink">Permalink</a
    4747    <div id="map"></div> 
    4848  </body> 
  • trunk/openlayers/lib/OpenLayers/Control/Permalink.js

    r846 r847  
    1818     
    1919    draw: function() { 
    20         this.map.events.register( 'moveend', this, this.updateLink); 
     20        OpenLayers.Control.prototype.draw.apply(this, arguments); 
    2121        var args = this.getArgs(); 
    2222        if (args.lat && args.lon) { 
     
    2828            this.map.zoomTo(parseInt(args.zoom)); 
    2929        } 
     30        if (!this.element) { 
     31            this.element = document.createElement("a"); 
     32            this.div.style.right = "3px"; 
     33            this.div.style.bottom = "3px"; 
     34            this.div.style.left = ""; 
     35            this.div.style.top = ""; 
     36            this.div.style.display = "block"; 
     37            this.div.style.position = "absolute"; 
     38            this.element.style.fontSize="smaller"; 
     39            this.element.innerHTML = "Permalink"; 
     40            this.element.href=""; 
     41            this.div.appendChild(this.element); 
     42        } 
     43        this.map.events.register( 'moveend', this, this.updateLink); 
     44        return this.div; 
    3045    }, 
    3146    
  • trunk/openlayers/tests/test_Control_Permalink.html

    r846 r847  
    3737        t.eq($('permalink').href, $('edit_permalink').href, "Panning sets permalink with base"); 
    3838  } 
     39  function test_03_Control_Permalink_noElement (t) { 
     40        t.plan( 2 ); 
     41        control = new OpenLayers.Control.Permalink( ); 
     42        t.ok( control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object" ); 
     43        map = new OpenLayers.Map($('map')); 
     44        map.addControl(control); 
     45        t.eq(map.controls[2].div.firstChild.nodeName, "A", "Permalink control creates div with 'a' inside." ); 
     46  } 
    3947  // --> 
    4048  </script>