KAMAP MOUSE STOPPED

From Ka-Map Wiki

Jump to: navigation, search

[edit] Using the KAMAP_MOUSE_STOPPED event

  • This event allow you to call a function if the mouse stops over the viewport during a certain delay. It's usefull to make a query and get informations of what's under the mouse , like points of interest for example.


The KAMAP_MOUSE_STOPPED event works as the other events of kaQuery :

   <script type="text/javascript" src="kaQuery.js"></script>
  • Create a new kaQuery object in your startup.js :
   myKaQuery = new kaQuery( myKaMap, KAMAP_MOUSE_STOPPED, 300);
   myKaQuery.activate();
  • Here 300 is the delay (in ms) after which a function will be executed. If you don't enter the delay, default will be 500. It's active all the time, you don't have to switch with other tools. Of course you can deactivate it on the fly temporarily.
  • So you have to listen to the event and assign it a function in startUp.js :
   myKaMap.registerForEvent( KAMAP_MOUSE_STOPPED, null, myMouseStopped);
  • your function could be :
   function myMouseStopped(eventID, queryType, coords){
       alert("x : " + coords[0] + ", y : " + coords[1]);
   }
Personal tools