[OpenLayers-Users] RE : measure control

James Leveille James_Leveille at dmr.ca
Thu Feb 26 15:03:04 EST 2009


Great ! Thanks a lot Bart.
 
________________________________________________________________________
James Léveillé
DMR, une division de Fujitsu Conseil (Canada) inc.


________________________________

De: Bart van den Eijnden (OSGIS) [mailto:bartvde at osgis.nl]
Date: mer. 25-02-09 12:53
À: James Leveille
Cc: users at openlayers.org
Objet : Re: [OpenLayers-Users] measure control



Hi James,

the first syntax is OL 2.6, the second is OL 2.7.

I assume you are using a Polygon handler and want to retrieve both the
area and the length?

The event thrown by the Measure control only contains the area in the
evt.measure property in this case, so you have to calculate the length
using something like (untested):

var a = map.getControlsByClass('OpenLayers.Control.Measure');
var ctrl = a[0];
var length = ctrl.getBestLength(evt.geometry)[0];

Hope this helps.

Best regards,
Bart

James Leveille wrote:
> Hi,
> I'm using the OpenLayers.Control.Measure control.
> From the many examples found, the handler declaration can either be :
> 1) function handleMeasr(geometry, length, area, units) {}
> 2) function handleMeasr(event) {}
> Since I need the area & the perimeter, the first one should be the one
> to use. BUT, it's not working : I get a "length is undefined" error
> when I try to access the length value (or the area) with that definition.
> On the other hand, if I use the second declaration, the
> "event.measure.toFixed(3)" works fine but I can't get the area (there
> is no event.area.xxx) ...
> Anything special to do to make sure the first declaration gets called
> so I can get the area ?
> Thanks a lot.
> *________________________________________________________________________*
> *James Léveillé
> DMR, une division de Fujitsu Conseil (Canada) inc.*
> Bureau : 418.653.6882 #6911
> Cellulaire : 418.265.5005
> James_Leveille at dmr.ca <mailto:James_Leveille at dmr.ca>
> Ce courriel et ses pièces jointes peuvent contenir des renseignements
> confidentiels ouprivilégiés à l'intention du destinataire seulement.
> Toute revue, utilisation, distribution ou divulgation de ces
> renseignements par d'autres personnes est strictement interdite. Si
> vous n'êtes pas le destinataire de ce courriel, ou si vous n'êtes pas
> autorisé à recevoir ce courriel en son nom, vous n'avez pas le droit
> de l'examiner, de le copier ou de le distribuer. Veuillez communiquer
> avec l'expéditeur en lui répondant et supprimez toutes les copies de
> son message.
> P *Devez-vous vraiment imprimer ce courriel ? Pensons à l'environnement !*
> ------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>  


--
Bart van den Eijnden
OSGIS, Open Source GIS
bartvde at osgis.nl
http://www.osgis.nl <http://www.osgis.nl/> 



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


More information about the Users mailing list