/*** TODO: surpress all other events from the layer*/functioncaptureMapCoordinates(e,callback){e.preventDefault();// changing icon to crosshair$("#map").css({cursor:"crosshair"});// using jQuery to capture click event$("#map").click(function(e){$GP.utils.getInMapCrs({x:e.offsetX,y:e.offsetY},callback);// unregister click event$("#map").off("click");$("#map").css({cursor:""});// icon automatically changes to default one on map click event});}functiondoSomethingWithCoords(e){captureMapCoordinates(e,function(coords){letmsg=`Coords: ${coords.x}, ${coords.y}`;gsp.ui.info(msg);});}gsp.ui.toolbar.add({id:"new-toolbar-item",title:"New toolbar item",style:"background-position: 0px 0px;"/* CHANGE_ICON */},function(ret){ret.div.onclick=doSomethingWithCoords;});
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.