[OpenLayers-Users] measure immediate problem
tvnc
tvnc1979 at gmail.com
Wed Aug 17 06:08:48 EDT 2011
i want to show measured distance on mouse move, but can't get to work. maybe
someone can see mistake
var bot = new OpenLayers.Control.Button({
displayClass: 'olIkonaUdalj',
eventListeners: {
'activate': klikLivo,
'deactivate': brisMarkera},
type: 2
});
var kontr = new OpenLayers.Control.Panel
({
div: document.getElementById("bp"),
//defaultControl: bot
});
kontr.addControls([bot]);
map.addControl(kontr);
function klikLivo(event) {
var crta = new OpenLayers.Control.Measure(OpenLayers.Handler.Path, {persist:
true, immediate: true});
crta.events.on({
"measure": handleMeasurements,
"measurepartial": handleMeasurements
});
map.addControl(crta);
crta.activate();
}
}
function handleMeasurements(event) {
var geometry = event.geometry;
var units = event.units;
var order = event.order;
var measure = event.measure;
var element = document.getElementById('au');
var out = "";
if(order == 1) {
out += "measure: " + measure.toFixed(3) + " " + units;
} else {
out += "measure: " + measure.toFixed(3) + " " + units +
"<sup>2</" + "sup>";
}
element.innerHTML = out;
}
function brisMarkera(){alert("Brišemo markere");}
More information about the Users
mailing list