var centerPt=null; //description:get distance between ptB and centerPt //return: number function getDistance(ptB){ if(centerPt==null||centerPt.mapPoint==null){ console.log("unexpected para,function getDistance()"); return ""; } var ptA=centerPt.mapPoint; return Math.sqrt(Math.pow(ptA.x-ptB.x,2)+Math.pow(ptA.y-ptB.y,2)); } //onDragStart, record the centerPt dojo.connect(mapAppObj.map,"onMouseDragStart",function(evt){ console.log("dragStart triggered"); centerPt=evt; }); } //onDrag, calculate distance between currentPoint and centerPt dojo.connect(mapAppObj.map,"onMouseDrag",function(evt){ var radius=getDistance(evt.mapPoint); console.log("radius is:"+radius); }
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.