[ka-Map-users] div with lat, long, mapextent and scale code

José Manuel Cerrejón González gis at mapas-sll.com
Mon Feb 20 12:51:55 EST 2006


Take this Lorenzo and others...
Here is my spaghetti code ;)

==========
index.html
==========
...
<script type="text/javascript" src="DHTMLapi.js"></script>
<script type="text/javascript" src="xhr.js"></script>
<script type="text/javascript" src="jsExpander.js"></script>
<script type="text/javascript" src="kaMap.js"></script>
<script type="text/javascript" src="kaKeymap.js"></script>
<script type="text/javascript" src="kaLegend.js"></script>
<script type="text/javascript" src="kaTool.js"></script>
<script type="text/javascript" src="kaQuery.js"></script>
<script type="text/javascript" src="kaInfoMap.js"></script> <!--  Add by 
me! :) -->
<script type="text/javascript" src="wmsLayer.js"></script>
<script type="text/javascript" src="scalebar/scalebar.js"></script>
<script type="text/javascript" src="startUp.js"></script>
...

========
kaMap.js
========
...
kaMap_onmousemove = function( e )
{
    e = (e)?e:((event)?event:null);
    if (e.button==2)
    {
        this.kaMap.triggerEvent( KAMAP_CONTEXT_MENU );
    }
    if (this.kaMap.currentTool)
        this.kaMap.currentTool.onmousemove( e );

/*    var aLatLon = new Array();
    var aPixPos = kaTool.adjustPixPosition( e.clientX, e.clientY );    
// How the hell can I call to adjustPixPosition? maybe with 
kaTool.apply( this, [oKaMap] ); but  [oKaMap] is unknow here, I think
    aLatLon = this.kaMap.pixToGeo( aPixPos[0], aPixPos[1] );   
    this.kaMap.triggerEvent(KAMAP_INFOMAP, aLatLon);
*/
    }
...

============
kaInfoMap.js
============
...
var KAMAP_INFOMAP = gnLastEventId ++;

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

kaInfoMap.prototype.onmousemove = function(e)
{
    e = (e)?e:((event)?event:null);   
   
    var aLatLon = new Array();
    var aPixPos = this.adjustPixPosition( e.clientX, e.clientY );
    aLatLon = this.kaMap.pixToGeo( aPixPos[0], aPixPos[1] );
    window.status = "x: " + Math.round(aLatLon[0]*100)/100 + " y: " + 
Math.round(aLatLon[1]*100)/100;
    this.kaMap.triggerEvent(KAMAP_INFOMAP, aLatLon);
    return false;   
}
...

==========
startUp.js
==========
...
function myOnLoad() {
...
    myKaMap.registerForEvent( KAMAP_QUERY, null, myQuery );
    myKaMap.registerForEvent( KAMAP_INFOMAP, null, myInfoMap );    // 
Add by me! :)
...
}
function myInfoMap(eventID, coords)    //Add by me! :)
{
window.status=coords;
}


More information about the ka-Map-users mailing list