Measure widget display lenght in Map

924
5
06-29-2012 01:33 AM
JanJeske
New Contributor III
Hey I want to display the lenght from each squence of the measure in the map.

thats works all fine but when I display the first measure of area in the map i got only wrong values displayed.

That is my code i insertet in measurement.js ....

        var _17;
 if(this._map.snappingManager)
 {
  _17=this._map.snappingManager._snappingPoint;
 }
 var _18=_17||evt.mapPoint;
 
 //###############################
 var xmuss = _18.x - ((_18.x - this.inputPoints[0].x)/2);
 var ymuss = _18.y - ((_18.y - this.inputPoints[0].y)/2);
 var winkelmuss = (Math.atan2((this.inputPoints[0].y - _18.y), (this.inputPoints[0].x - _18.x))*180)/Math.PI;
                                         
 var pt = new esri.geometry.Point(xmuss, ymuss, this._map.spatialReference);

 var textSymbol = new esri.symbol.TextSymbol();
 textSymbol.setColor(new dojo.Color([0,0,0])).setFont(new esri.symbol.Font("12pt").setWeight(esri.symbol.Font.WEIGHT_BOLD));  
 var gemessen = this._geodesicDistance(this.inputPoints[0],_18)*1609.34; 
 textSymbol.text = dojo.number.format(gemessen.toFixed(1), {pattern: this.numberPattern}) + "m";
 if(winkelmuss < 0 && winkelmuss > -90)
 {
  winkelmuss = winkelmuss*-1; 
  textSymbol.yoffset = -10;
         textSymbol.xoffset = -10;                                                     
 }else if(winkelmuss <= -90)
 {
  winkelmuss = (winkelmuss +180)*-1; 
  textSymbol.yoffset = 10;
 textSymbol.xoffset = 10;                                                            
 }else if(winkelmuss > 0 && winkelmuss < 90)
 {
  winkelmuss = winkelmuss*-1;
  textSymbol.yoffset = -10;
 textSymbol.xoffset = -10;
                                                               
 }else if(winkelmuss >= 90)
 {
  winkelmuss = (winkelmuss - 180)*-1; 
  textSymbol.yoffset = 10;
 textSymbol.xoffset = 10;                                                            
 }
 
 textSymbol.angle = winkelmuss;
 
 
 this.textGraphic=new esri.Graphic();
 this.textGraphic.setSymbol(textSymbol);
 this.textGraphic.setGeometry(pt);
 this._map.graphics.add(this.textGraphic);
 this.measureGraphics.push(this.textGraphic);


Hope anyone can help me
0 Kudos
5 Replies
ReneRubalcava
Frequent Contributor
Where exactly are you adding this?
The measurement.js tool has a field called result.
So you can grab measurement.result.toFixed(2) and apply it to the tooltip or some other feature.
I actually just use jQuery to grab the results and display them in a "history list". After some trial and error, it was just the simplest route.

If you wanted to modify the measurement.js, you may just want to use dojo.extend.
0 Kudos
JanJeske
New Contributor III
Thanks for the tip with dojo extent i will try it 🙂

I added the code to the _measureAreaMouseClickHandler function in the measurement.js of the jsapi.

Instead of the area i want to have the length of each path. Like this.


[ATTACH=CONFIG]15689[/ATTACH]

I fixed this but my Problem now ist that when i print with the print task there is no more text rotation and some text graphics are gone
0 Kudos
JanJeske
New Contributor III
Thanks for the tip with dojo extent i will try it 🙂

I added the code to the _measureAreaDblClickHandler function in the measurement.js of the jsapi.

and

 //Bema�?ung Area hinzugefügt 28.06.2012
   var xmuss = mapPoint.x - ((mapPoint.x - this.inputPoints[this.inputPoints.length-2].x)/2);
   var ymuss = mapPoint.y - ((mapPoint.y - this.inputPoints[this.inputPoints.length-2].y)/2);
   var winkelmuss = (Math.atan2((this.inputPoints[this.inputPoints.length-2].y - mapPoint.y), (this.inputPoints[this.inputPoints.length-2].x - mapPoint.x))*180)/Math.PI;
                                          
   var pt = new esri.geometry.Point(xmuss, ymuss, this._map.spatialReference);
   
   var textSymbol = new esri.symbol.TextSymbol();
   textSymbol.setColor(new dojo.Color([0,0,0])).setFont(new esri.symbol.Font("12pt").setWeight(esri.symbol.Font.WEIGHT_BOLD));
  // alert(this._geodesicDistance(this.inputPoints[this.inputPoints.length-2],mapPoint));
  // alert(this._geodesicDistance(this.inputPoints[this.inputPoints.length-2],mapPoint)*0.0150605384943241495948941483426);
   var gemessen = this._geodesicDistance(this.inputPoints[this.inputPoints.length-2],mapPoint)*1609.34;
                                                                                                                     
   //textSymbol.text = gemessen.toFixed(1) + "m";
   textSymbol.text = dojo.number.format(gemessen.toFixed(1), {pattern: this.numberPattern}) + "m";
  

   if(winkelmuss < 0 && winkelmuss > -90)
   {
    winkelmuss = winkelmuss*-1; 
    textSymbol.yoffset = -10;
    textSymbol.xoffset = -10;                                                     
   }else if(winkelmuss <= -90)
   {
    winkelmuss = (winkelmuss +180)*-1; 
    textSymbol.yoffset = 10;
    textSymbol.xoffset = 10;                                                            
   }else if(winkelmuss > 0 && winkelmuss < 90)
   {
    winkelmuss = winkelmuss*-1;
    textSymbol.yoffset = -10;
    textSymbol.xoffset = -10;                                                                                                                          
   }else if(winkelmuss >= 90)
   {
    winkelmuss = (winkelmuss - 180)*-1; 
    textSymbol.yoffset = 10;
    textSymbol.xoffset = 10;                                                            
   }                                                            
   textSymbol.angle = winkelmuss;                                                     
   
   this.textGraphic=new esri.Graphic();
   this.textGraphic.setSymbol(textSymbol);
   this.textGraphic.setGeometry(pt);
   this._map.graphics.add(this.textGraphic);
   this.measureGraphics.push(this.textGraphic);  



to the _measureAreaMouseClickHandler.

Instead of the area i want to have the length of each path. Like this.

[ATTACH=CONFIG]15690[/ATTACH]
0 Kudos
IgorKaruza
New Contributor
Hi!

Is it possible to to achieve the same functionality as in Silverlight API - show measured length while dragging mouse?

Example: Silverligth API - Utility Actions - Polygon Measure

http://resources.arcgis.com/en/help/silverlight-api/samples/start.htm#UtilityActions

Br!

Igor
0 Kudos