[OpenLayers-Users] Measure control problem

Kwong Hu Kiu kwonghu at hotmail.com
Mon Aug 3 10:47:52 EDT 2009



I think you are looking for the Vincenty distance formula.
It's included in the examples as well.

To: users at openlayers.org
From: Steve.Toutant at inspq.qc.ca
Date: Mon, 3 Aug 2009 10:44:10 -0400
Subject: [OpenLayers-Users] Measure control problem



Hello,

I created a measure control based on
the measure.js example

My measure control doesn't display the
good distance. The distance is longer than expected.

I tried with these coordinates

# : lat, long

Point 1 : 46.81509864093307, -71.22436522446064

Point 2 :  45.54483148742626, -73.63037108350094

The control gives 336.824 km

It should be around 233 km



Do you have an idea on what could be
the cause of this error?



Here is my code

//the mapOptions of OL are

projection: "EPSG:900913",

displayProjection: new OpenLayers.Projection("EPSG:4326"),
//Pour afficher les coord lat long

units: "m",



var mesureControl = new OpenLayers.Control.Measure(

           
               OpenLayers.Handler.Path,


         
               
              {

           
                   persist:
true,

         
      geodesic: false,

           
                   handlerOptions:


         
               
               
      {

           
            //        
  layerOptions: {styleMap: styleMap}

           
                   }

           
               }

           
                 
 );

mesureControl.events.on

({

    "measure": handleMeasurements,

        "measurepartial":
handleMeasurements

});

map.addControl(mesureControl);

        

function handleMeasurements(event) 

{

        var
geometry = event.geometry;

        var
units = event.units;

        var
measure = event.measure;

        

        alert(
measure.toFixed(3) + " " + units, "" );

}



//geoExt toolbar

action = new GeoExt.Action({

        control:
mesureControl,

    map: map,

    toggleGroup: "map",

        iconCls:
'measure',

        tooltip:
'Mesure linéaire'

    });

    toolbar.push(action);
               



Thanks for your help,

Steve



Steve Toutant, M. Sc.

Analyste en géomatique

Secteur environnement

Direction des risques biologiques, environnementaux et occupationnels

Institut national de santé publique du Québec

945, avenue Wolfe

Québec, Qc G1V 5B3 
Tél.: (418) 650-5115 #5281

Fax.: (418) 654-3144

steve.toutant at inspq.qc.ca

http://www.inspq.qc.ca

  


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20090803/c9db9c3c/attachment.html


More information about the Users mailing list