Measure two point in flex
I recorded the coordinate of two point , and retrieve them to the Location value.
var loc:Location = NeoMap.map.pointLocation(new Point(NeoMap.mouseX, NeoMap.mouseY), NeoMap)
Distance.approxDictance Return value is always the same location! Where I am wrong?
var dic:Number = Distance.approxDistance(_localPointsArray.pop(), _localPointsArray.pop(), Distance.R_MILES);
var loc:Location = NeoMap.map.pointLocation(new Point(NeoMap.mouseX, NeoMap.mouseY), NeoMap)
Distance.approxDictance Return value is always the same location! Where I am wrong?
var dic:Number = Distance.approxDistance(_localPointsArray.pop(), _localPointsArray.pop(), Distance.R_MILES);
1
person has this question
I have this question, too!
Tell me when someone answers.
The more people who ask this question, the more it gets noticed.
The more people who ask this question, the more it gets noticed.
Create a customer community for your own organization
Plans starting at $19/month
-
Inappropriate?Yes, that sounds right.
You can check at http://www.movable-type.co.uk/scripts... using locations from http://getlatlon.com -
Inappropriate?Yeah, But I trace the return value is always the same.
Even more surprising is that I can use this location to put Markers correctly.
trace("location:" + loc);
trace("e.localX, e.localY:" + e.localX, e.localY);
location:37.75760,-122.45657
e.localX, e.localY:613 218
location:37.69514,-122.43871
e.localX, e.localY:639 333
I’m confused
-
Inappropriate?This is whole codes.
private function NeoMapClickHandler(e:MouseEvent):void{
var loc:Location = NeoMap.map.pointLocation(new Point(e.localX, e.localY), NeoMap.map);
/* Stored in an array */
_localPointsArray.push(loc);
var m:Marker = new Marker(loc, "Marker" + _localPointsArray.length);
NeoMap.map.putMarker(loc, m);
if( _localPointsArray.length == 2 ){
_distance = Distance.approxDistance(_localPointsArray.pop (),_localPointsArray.pop(), Distance.R_MILES);}
I’m anxious
-
Inappropriate?By a value I need it?
What is the unit of the return value? kilometre?? -
Inappropriate?This code looks right, I don't understand what the issue is.
What values are you passing into Distance.approxDistance? What answer are you getting? What answer do you expect?
The unit will be miles if you use Distance.R_MILES - the final argument is the approximate radius of the earth used in the calculation. -
Inappropriate?I feel the reture value is too small. It isn't seem a real value.
private function clickhandler(e:mouseevent):void{
var point:Point = new Point(e.localX, e.localY);
/* save twice value of clicking position */
_localPoinsArray.push(new Point( e.localX, e.localY));
}
var dis:number = Distance.approxDistance(_locationPointsArray.pop(), _locationPointsArray.pop(), Distance.R_MILES);
trace( dis ); /* too small */
I’m anxious
-
Inappropriate?How small is too small? The distance between two points in San Francisco is likely to be less than 10 miles, for example.
Can you let us know what *precise* values are you using, and what *precise* answer you get?
Have you checked against a different source and got a different answer? What is the correct answer?
Loading Profile...



EMPLOYEE