|
From: Edwin C. <com...@gm...> - 2009-08-27 22:53:57
|
Hi Michel,
At first sight this looks like formatOutput, but an important difference is
that handleMeasurements is not a function on the Measure control and you
have to do all the work for the output.
First up: In my opinion, the handleMeasurement function should not return
output (it also doesn't in the OpenLayers examples), because it's a
callback. You never know when people stop measuring and therefore when
measure will fire.
Looking at it my first impression is that you would want to make it easy to
set a handler for the onMeasure and onMeasurePartial events. The
SelectFeature control has something like this, using interfaces defined on
the class. For Measure this would be something like:
public interface MeasureListener(){
void onMeasure(String measurements); // assuming that measurements are
passed as a String, which is a guess
}
The Measure control could have a setMeasureListener(MeasureListener
listener) method, that registers the listener. To see how that works, look
at the setFeatureControl
A user would then do:
Measure m = new Measure( args here );//instantiate control
m.setMeasureListener(new MeasureListener(){
void onMeasure(String Measurements){
// get place to write output the GWT way
// do formatting and write to output place (e.g. a DOM element)
// OR
// call some other function to write output, that can also be called by
onMeasurePartially
}
})
Greetings and I hope this is useful to you,
Edwin
2009/8/27 Michel vitor <mic...@gm...>
> Dear Edwin,
>
> I would like to further your explanation, my problem and I implemented the
> following function Measure of OpenLayers so that now I want to display the
> screen output in any format (ft, m etc.). And this is possible in java
> ecript.
> I'm trying to recreate in the java gwt-openlayers the following function
>
> var control;
> control = new
> OpenLayers.Control.Measure(OpenLayers.Handler.Path);
> control.events.on({"measure":
> handleMeasurements,"measurepartial": handleMeasurements});
> map.addControl(control);
> map.setCenter(new OpenLayers.LonLat(0, 0), 3);
> }
>
> function handleMeasurements(x) {//this
> var geometry = x.geometry;
> var units = x.units;
> var order = x.order;
> var measure = x.measure;
> var element = document.getElementById('output');
> var out = "";
> if(order == 1) {
> out += "measure: " + measure.toFixed(3) + " " + units;
> } else {
> out += "measure: " + measure.toFixed(3) + " " + units +
> "<sup>2</" + "sup>";
> }
> return out;//return this value for component
> }
>
> that looks a bit like formatOutput, but want to get the value and display
> in a component can you give me a help and my doubts as to the role that this
> prominent.
> --
> Michel Vitor A Rodrigues
> 6° Periodo de Computação
> Grupo Intec,Viçosa MG
>
>
|