[ka-Map-users] customizing ka-map

Alessio Di Lorenzo alessio.dilorenzo at gmail.com
Wed Aug 8 16:51:52 EDT 2007


Hi,
I'm going on with my ka-Map customization (at least I'm trying to do...).

I noticed that when I load the page described by the code below, it 
works but it gives an error reported by the firefox javascript console 
as the following:

Error: oMap has no properties  (row 181 of kaLegend.js)

Without fixing this error I can't add new functionalities...
For example, I added the kaMouseTracker.js (that shows the coordinates 
when the mouse moves over the map).

When I comment the rows related to the kaLegend, the kaMouseTracker 
works, but if not, probably, the parsing of javascript code stops on the 
error (oMap has no properties) and the display of coordinates doesn't 
work anymore!

The only way that I found is to put the kaLegend rows at the end of the 
myOnLoad function... but I don't like this "solution" and I'm sure that 
there's a more effective way to avoid the error!

To clarify, the code I'm talking about is the following (only a little 
bit more complex than yesterday):

<html>
    <head>
        <title>Customizing Ka-Map!</title>
       
        <script type="text/javascript" src="DHTMLapi.js"></script>
        <script type="text/javascript" src="xhr.js"></script>
        <script type="text/javascript" src="kaMap.js"></script>
        <script type="text/javascript" src="kaTool.js"></script>
        <script type="text/javascript" src="kaLegend.js"></script>
        <script type="text/javascript" src="kaMouseTracker.js"></script>
         
       
        <script type="text/javascript">
                var myKaMap;
                var myKaNav;
       
                            
        function myOnLoad() {

        initDHTMLAPI();            

        myKaMap = new kaMap( 'mapDiv' );
        myKaMap.server = 'http://localhost/luoghidabruzzo/ka-map/htdocs/';
        myKaMap.initialize();

        myNav = new kaNavigator ( myKaMap );
        myNav.activate ();

        myTracker = new kaMouseTracker( myKaMap );
        myTracker.activate();

        myKaMap.registerForEvent( KAMAP_MOUSE_TRACKER, null, myMouseMoved );

        var legendOptions = {};
        legendOptions.visibility = typeof gbLegendVisibilityControl != 
'undefined' ? gbLegendVisibilityControl : true;
        legendOptions.opacity = typeof gbLegendOpacityControl != 
'undefined' ? gbLegendOpacityControl : true;
        legendOptions.order = typeof gbLegendOrderControl != 'undefined' 
? gbLegendOrderControl : true;
        legendOptions.query = typeof gbLegendQueryControl != 'undefined' 
? gbLegendQueryControl : true;
                 
        var myKaLegend = new kaLegend(myKaMap, 'legend' , false, 
legendOptions);
        myKaLegend.draw();
              
                 
        }


        function roundIt(number,decimals){
        var base10 = 10;
        for(var i=0;i<decimals-1;i++)
        base10 = base10 *10;
     
        return Math.round(number * base10)/base10;
        }

        function myMouseMoved( eventID, position) {
            var geopos = document.getElementById('geoPosition');
            if(geopos) geopos.innerHTML = 'x: ' + roundIt(position.x,2) 
+ '<BR>y: ' + roundIt(position.y,2);
        }


        </script>
     
    </head>

If you want, try to modify the myOnLoad function by moving


myTracker = new kaMouseTracker( myKaMap );
myTracker.activate();

below

var myKaLegend = new kaLegend(myKaMap, 'legend' , false, legendOptions);
myKaLegend.draw();

...as I explaned it fails...


Alessio


PS
sorry for my english... this evening it is really awful!!!





Samuel Hiatt ha scritto:
> I am very glad I could help out.  I'm excited to see what you come up 
> with!
>
> Sam
>
>
> On 8/7/07, *Alessio Di Lorenzo* < alessio.dilorenzo at gmail.com 
> <mailto:alessio.dilorenzo at gmail.com>> wrote:
>
>     YES!!!!!
>     Sam, you're right! It works!
>
>     In the next days I'll try to add all the other tools :)
>
>     At the moment the good working code is this:
>
>     <html>
>         <head>
>             <title>Customizing Ka-Map!</title>
>
>             <script type="text/javascript" src="DHTMLapi.js"></script>
>             <script type="text/javascript" src="xhr.js"></script>
>           <script type="text/javascript" src=" kaMap.js"></script>
>             <script type="text/javascript" src=" kaTool.js"></script>
>             <script type="text/javascript" src="kaLegend.js"></script>
>
>             <script type="text/javascript">
>                     var myKaMap;
>                     var myKaNav;
>
>                     function myOnLoad() {
>                         myKaMap = new kaMap( 'mapDiv' );
>                         myKaMap.server =
>     ' http://localhost/luoghidabruzzo/ka-map/htdocs/';
>                         myKaMap.initialize();
>
>                             myNav = new kaNavigator ( myKaMap );
>                       myNav.activate ();
>
>                       myKaLegend = new kaLegend( 'legend' );
>
>                     }
>
>                     </script>
>
>         </head>
>         <body onload="myOnLoad();">
>
>                         <div id="mapDiv">
>                         </div>
>
>                         <div id="legend">legenda
>                         </div>
>
>         </body>
>     </html>
>
>     <style type="text/css">
>         #mapDiv {
>             position: relative;
>             width: 640px;
>             height: 480px;
>             background-color:  white;
>             border: 1px solid black;
>         }
>     </style>
>
>
>     It's very very simple but I hope this could be helpful for someone who
>     want to start the creation of his own ka-map interface.
>
>     Samuel, if you want you can put it in your wiki tutorial as a
>     basic example.
>
>     Thanks a lot for your precious help!
>
>     Alessio
>
>
>
>     Samuel Hiatt ha scritto:
>     > Ok... I got your code working...
>     >
>     > All you need to do is add your kaMap object to the parameters of
>     the
>     > kaLegend call... so it should be:
>     >  myKaLegend = new kaLegend( myKaMap, 'legend' );
>     >
>     > kaLegend.js does say that all you need to do is add the name of the
>     > div, but apparently it is wrong.  You gotta make sure to reference
>     > which map the legend is for.
>     >
>     > Take a look at the kaExplorer startUp.js (probably located at
>     > /tools/kaExplorer/startUp.js)... it adds a legend with some
>     additional
>     > parameters that set the legend options.
>     >
>     > Hope it works!
>     >
>     > Sam
>     >
>     >
>     > On 8/7/07, *Alessio Di Lorenzo* <alessio.dilorenzo at gmail.com
>     <mailto:alessio.dilorenzo at gmail.com>
>     > <mailto: alessio.dilorenzo at gmail.com
>     <mailto:alessio.dilorenzo at gmail.com>>> wrote:
>     >
>     >
>     >     my code now is the following:
>     >
>     >     <html>
>     >         <head>
>     >             <title>Customizing Ka-Map!</title>
>     >
>     >             <script type="text/javascript"
>     src="DHTMLapi.js"></script>
>     >             <script type="text/javascript" src="xhr.js"></script>
>     >           <script type="text/javascript" src="kaMap.js"></script>
>     >             <script type="text/javascript" src="
>     kaTool.js"></script>
>     >             <script type="text/javascript" src="
>     kaLegend.js"></script>
>     >
>     >             <script type="text/javascript">
>     >                     var myKaMap;
>     >                     var myKaNav;
>     >
>     >                     function myOnLoad() {
>     >                         myKaMap = new kaMap( 'mapDiv' );
>     >                         myKaMap.server =
>     >     ' http://localhost/luoghidabruzzo/ka-map/htdocs/
>     <http://localhost/luoghidabruzzo/ka-map/htdocs/>';
>     >                         myKaMap.initialize();
>     >
>     >                             myNav = new kaNavigator ( myKaMap );
>     >                       myNav.activate ();
>     >
>     >                       myKaLegend = new kaLegend( 'legend' );
>     >
>     >                     }
>     >
>     >                     </script>
>     >
>     >         </head>
>     >         <body onload="myOnLoad();">
>     >
>     >                         <div id="mapDiv">
>     >                         </div>
>     >
>     >                         <div id="legend">legenda
>     >                         </div>
>     >
>     >         </body>
>     >     </html>
>     >
>     >     <style type="text/css">
>     >         #mapDiv {
>     >             position: relative;
>     >             width: 640px;
>     >             height: 480px;
>     >             background-color:  white;
>     >             border: 1px solid black;
>     >         }
>     >     </style>
>     >
>     >
>     >
>     >     If you try to use it, you get something working? (including the
>     >     legend...)
>     >
>     >
>     >     Alessio
>     >
>     >
>
>     _______________________________________________
>     ka-Map-users mailing list
>     ka-Map-users at lists.maptools.org
>     <mailto:ka-Map-users at lists.maptools.org>
>     http://lists.maptools.org/mailman/listinfo/ka-map-users
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> ka-Map-users mailing list
> ka-Map-users at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/ka-map-users
>   



More information about the ka-Map-users mailing list