Select to view content in your preferred language

Reg: Displaying measurement value as we digitize

2667
2
01-30-2014 07:56 PM
VikramS
Frequent Contributor
Hello all ,

Is it possible to display the values as we digitize line or polygon . Has any one done like this before in Javascript ..

Any ideas how to achieve it ?

Thanks
0 Kudos
2 Replies
ShaunWeston
Frequent Contributor
You mean displaying the distance of the line / area of the polygon as you move it?

Yeah this can be done. I've done it in Flex and Silverlight before anyway. Have a look at this one in Flex - http://test1.ecan.govt.nz/ViewerDemonstrations/index.html?config=config-drawing.xml

When start digitising a line it says how long it is. Maybe look at the code for that to get some ideas. You just need to listen to mouse movements and query the geometry service to update dynamic text.
0 Kudos
ManishkumarPatel
Deactivated User
Hi Vikram,

I have implemented similar functionality where in I calculate the measurement progressively while drawing graphics.

You will have to combine Map Click and Mouse Move evnt to get the X Y co-ordinates and you can use the geometry service to calculate the Distance as required.

Below code for reference:

clickedPointsArr = [];
        draw_mapOnClick = map.on("click", getmappoints);
 totalsegmentlength = 0;
linelenMouseEvt = dojo.connect(map, "onMouseMove", function (evt) {
 if (clickedPointsArr.length > 0) {
                var distParams = new esri.tasks.DistanceParameters();
                distParams.distanceUnit = esri.tasks.GeometryService[dojo.byId("draw_PerimeterUnitDrpDwn").value];

                distParams.geometry1 = clickedPointsArr[clickedPointsArr.length - 1];
                distParams.geometry2 = mp;
                distParams.geodesic = true;

               
                gsvc.distance(distParams, function (distance) {
                    dojo.byId("draw_AreaTxtBx").value = parseFloat(distance).toFixed(2);  //last drawn segment length
                    lastdrawnsegmentlength = distance;
                    totalsegmentlength = previousSegmentLength;
                    totalsegmentlength = totalsegmentlength + lastdrawnsegmentlength;
                    dojo.byId("draw_PerimeterTxtBx").value = parseFloat(totalsegmentlength).toFixed(2);  //total segment length
                }); 

function getmappoints(evt) {
    try { 
        clickedPointsArr.push(evt.mapPoint);
        if (clickedPointsArr.length > 1) {
            previousSegmentLength = totalsegmentlength;   }
    } catch (e) {
        var err = e;
    }
}


Regards,
Manish Patel
0 Kudos