[OpenLayers-Users] Re: measure segment length
tvnc
tvnc1979 at gmail.com
Fri Aug 19 14:34:36 EDT 2011
tvnc <tvnc1979 at ...> writes:
>
> how could i using measure control (immediat set to true) get measure segments
> length set in array so i can grab and show each one
>
i get it work with setImmediate set to false, but i want to store all measure
segment lenght in array with setImmediate set to true
crta = new OpenLayers.Control.Measure(OpenLayers.Handler.Path,
{persist: true, geodesic: true});
crta.events.on({
"measure": handleFinalMeasurement,
"measurepartial": handlePartialMeasurement
});
map.addControl(crta);
crta.activate();
crta.setImmediate(true);
unction handleFinalMeasurement(event) {
var units = event.units;
var geometry = event.geometry;
var measure = event.measure;
var element = document.getElementById('au');
var br = tocke[1].components.length;
var out = "udaljenost: " + (measure*0.5399).toFixed(2) + " NM";
out += " zadnji segment: " + duz.toFixed(2) + " NM";
element.innerHTML = out;
}
var zd =[];
function handlePartialMeasurement(event) {
tocke.length = 0;
var geometry = event.geometry;
var units = event.units;
var measure = event.measure;
var element = document.getElementById('au');
var geo = geometry.clone().transform(new OpenLayers.Projection
("EPSG:900913"), new OpenLayers.Projection("EPSG:4326"));
tocke.push(geo);
var bt = tocke.length;
var br = tocke[bt-1].components.length;
var od = tocke[bt-1].components[br-2];
var ddo = tocke[bt-1].components[br-1];
var ls = new OpenLayers.Geometry.LineString([od, ddo]);
duz = ls.getGeodesicLength()*0.5399/1000;
var out = "udaljenost: " + (measure*0.5399).toFixed(2) + " NM";
out += " zadnji segment: " + duz.toFixed(2) + " NM";
zd.push(duz);
element.innerHTML = out;
}
More information about the Users
mailing list