[ka-Map-users] div with lat, long, mapextent and scale work perfectly!

José Manuel Cerrejón González gis at mapas-sll.com
Wed Feb 22 10:09:35 EST 2006


Finally My status bar work perfectly! Here is my code 4 all the world :D
Changes, improvements to this list or gis _.at._ mapas-sll.com.

//START
==========
index.html
==========
...
<script type="text/javascript" src="kaQuery.js"></script>
<script type="text/javascript" src="kaStatusBar.js"></script> <!-- 
Created by J M Cerrejon -->
<script type="text/javascript" src="wmsLayer.js"></script>
...
==========
screen.css
==========
/* StatusBar | All code below created by J M Cerrejon | 22/02/06*/
#refStatusBar {
    position:absolute;
    bottom: 20px;
    left: 3px;
    z-index: 2;
    width: 14px;
    height: 14px;
    background-image: url(images/arrow_down.png);
    background-repeat: no-repeat;
    cursor: pointer;
}

#StatusBar {
    position: absolute;
    margin:0;
    bottom:0px;
    padding:0px;
    width: 100%;
    height: 15px;
    z-index:2;
    cursor: auto;   
    -moz-box-sizing: border-box;
    box-sizing: border-box;
    border-top: 1px solid #999;
}

#StatusBarBackground {
    width: 100%;
    height: 15px;
}

div .transparentStatusBar {
    position:absolute;
    top:0px;
    left:0px;
    background-color: #eee;
    filter:alpha(opacity=75);
    -moz-opacity:0.75;
    opacity:0.75;
    z-index: -1;
}

#Status {
    font-family: Verdana, sans-serif;
    font-size: 10px;
}
==========
startUp.js
==========
...
var myKaMap = myKaNavigator = mykaStatusBar = myScalebar = null;    // 
Modified by J M Cerrejon | 22/02/06
...
myKaMap.registerForEvent( KAMAP_STATUSBAR, null, myStatusBar );    // 
Created by J M Cerrejon | 21/02/06
...
function toggleStatusBar(obj)        // Created by J M Cerrejon | 21/02/06
{
    if (obj.style.backgroundImage == '')
        obj.isOpen = true;
        
    if (obj.isOpen)
    {
        obj.title = 'Show status bar.';
        obj.style.backgroundImage = 'url(images/arrow_up.png)';
        var bValue = getObjectTop(obj);;
        var d = getObject('StatusBar');
        d.display = "none";
        obj.isOpen = false;
        obj.style.bottom = "3px";
    }
    else
    {
        obj.title = 'Hide status bar.';
        obj.style.backgroundImage = 'url(images/arrow_down.png)';
        var d = getObject('StatusBar');
        d.display="block";
        obj.isOpen = true;
        var h = getObjectHeight('StatusBar');
        obj.style.bottom = (h + 3) + "px";
    }
}
...
function myStatusBar( eventID, e )    // Created by J M Cerrejon | 22/02/06
{
    if (getObject('StatusBar').display != "none"){    
        var extent = myKaMap.getGeoExtents();
        var scale = myKaMap.getCurrentScale();
    
        var aPixPos = mykaStatusBar.adjustPixPosition( e.clientX, 
e.clientY );
        var aLatLon = myKaMap.pixToGeo( aPixPos[0], aPixPos[1] );
        var StatusInfo = "lat: " + Math.round(aLatLon[0]*100)/100 + " 
lon: " + Math.round(aLatLon[1]*100)/100 + " | scale 1:" + scale + " | 
extent: " + Math.round(extent[0]*100)/100 + "," + 
Math.round(extent[1]*100)/100 + "," + Math.round(extent[2]*100)/100 + 
"," + Math.round(extent[3]*100)/100;
        getRawObject('Status').innerHTML = StatusInfo;
    }
}
========
kaMap.js
========
kaMap_onmousemove = function( e )
{
 ...
    this.kaMap.triggerEvent(KAMAP_STATUSBAR, e);    // Created by J M 
Cerrejon | 22/02/06
}
==============
kaStatusBar.js
==============
/**********************************************************************
 *
 * $Id: kaStatusBar.js,v 1.00 2006/02/17 12:42:46 jmcerrejon Exp $
 *
 * purpose: StatusBar to show info about the map: lat, lon, scale, mapextent
 *
 * author: Jose M. Cerrejon (gis _.at._ mapas-sll.com) nickname: uLySeSS
 *
 **********************************************************************
 *
 * Copyright (c) 2005, DM Solutions Group Inc.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the 
"Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 
OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 *
 **********************************************************************/
var KAMAP_STATUSBAR = gnLastEventId ++;

function kaStatusBar( oKaMap )
{
    kaTool.apply( this, [oKaMap] );
    this.kaMap = oKaMap;
    this.name = 'kaStatusBar';
    this.bMouseDown = false;
    
    for (var p in kaTool.prototype)
    {
        if (!kaStatusBar.prototype[p])
            kaStatusBar.prototype[p]= kaTool.prototype[p];
    }
}

kaStatusBar.prototype.onmousemove = function(e)
{
    return false;
}
//END


More information about the ka-Map-users mailing list