[OpenLayers-Users] Measure control problem

Steve.Toutant at inspq.qc.ca Steve.Toutant at inspq.qc.ca
Mon Aug 3 10:44:10 EDT 2009


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/41764730/attachment.html


More information about the Users mailing list