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); }
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.