[mapguide-users] Re: Measure Tool distance in Feet not Miles

Nickthetemp nickthetemp at gmail.com
Wed Dec 15 09:07:29 EST 2010


in your www\viewerfiles\measureui.templ change these lines to what you need. 

function SetMeasureResults(partial, total) 
{ 
//modify partial*1000 to convert yout miles to feet 
    document.getElementById("partial").innerHTML =
FormatLocalizedDecimal(partial*1000, 2); 
    document.getElementById("total").innerHTML =
FormatLocalizedDecimal(total*1000, 2); 
} 

function ShowUnits() 
{ 
    var units = GetParent().GetMapFrame().IsEnglishUnits()? "__#MILES#__":
"__#KILOMETERS#__"; 
    document.getElementById("units1").innerHTML = "Meters"; //change to feet 
    document.getElementById("units2").innerHTML = "Meters"; //change to feet 
} 
 

Just a few notes on the above code:

1.to convert miles to feet you do not want to mutiply by 1000. There are
5280 feet in a mile so you would multiply by 5280

2. If you do it this way you are going to run into problems if someone
changes the map units to metric.
   It will be multiplying meters by 5280 which is incorrect.


The best way to show feet instead of miles is to make changes in the
measure.php file

it can be done like so:(line ~93)

if(!$us)
             //$distance *= 0.001;        //get kilometers
                $distance *= 1;             //get meters
else
            //$distance *= 0.000621371192;    //get miles
               $distance *= 3.28084;              //get feet

as you can see I commented out the miles formula and entered the feet
formula. I did the same for kilometers to meters

also in your measureui.templ file change the following:

**FROM**
function ShowUnits() 
{ 
    var units = GetParent().GetMapFrame().IsEnglishUnits()? "__#MILES#__":
"__#KILOMETERS#__"; 
    document.getElementById("units1").innerHTML = units
    document.getElementById("units2").innerHTML = units
} 

**TO**

function ShowUnits() 
{ 
    var units = GetParent().GetMapFrame().IsEnglishUnits()? "Feet":
"Meters"; 
    document.getElementById("units1").innerHTML = units
    document.getElementById("units2").innerHTML = units
} 


Hope this helps
-- 
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Measure-Tool-distance-in-Feet-not-Miles-tp5580857p5837935.html
Sent from the MapGuide Users mailing list archive at Nabble.com.


More information about the mapguide-users mailing list