I have tried to add a HomeButton dijit to my page. However, it won't work if I specify any event listeners on the map object. In other words, if I want to add BOTH a HomeButton, AND a task that specifies event listeners on the map object, like this:
// for home button<BR /> var objHome = new HomeButton({map: divMap}, "HomeButton"); <BR /> objHome.startup();<BR /> // this is how you call 'on' style events in the API<BR /> objMap.on("load", function() <BR /> { <BR /> // for coordinates display - event listeners<BR /> objMap.on("mouse-move", showCoordinates);<BR /> objMap.on("mouse-drag", showCoordinates); <BR /> // for home button - when home event is fired, execute home() method - currently doesn't work<BR /> objHome.on("home",objHome.home()); <BR /> }); <BR /> // for coordinates display<BR /> function showCoordinates(evt)<BR /> {<BR /> //the map is in web mercator but display coordinates in geographic (lat, long) <BR /> var mp = webMercatorUtils.webMercatorToGeographic(evt.mapPoint); <BR /> //display mouse coordinates<BR /> dom.byId("spanCoordinates").innerHTML = mp.x.toFixed(3) + ", " + mp.y.toFixed(3);<BR /> }
...It won't work.
What do I need to modify here, to get the HomeButton to work with the showCoordinates code? Again, before you post the code on the HomeButton class definition page as a solution - that code WILL NOT WORK if you specify an 'on' function on the map object.
Thanx.