[OpenLayers-Users] how to best extend drawing tools to include
measure
Mike Quentel
mikequentel at yahoo.com
Tue May 15 15:56:08 EDT 2007
I created a measure control (OpenLayers.Control.Measure) that uses a div (like the mouse position control) to display distance.
So far, I have an example where the user can select a drawn line, and get back the total distance of the line. It employs the OpenLayers.Util.distVincenty function to calculate the distances of the components of the geometry, adding up the results. It also handles situations like the user attempting to measure the entire globe (handles situation if the pixel clicks exceed what they should for a hemisphere). This is still in its raw state, so if you see bugs, please let me know. The attached example seems to work well.
Please, need advice...I would like to add this functionality to the drawing tools, such that when the user draws a line, the total distance is displayed in the measure control. I am not sure how to go about doing this. Would it be best to include this control in the OpenLayers.Handler.Path handler class?
Attached is Measure.js, which represents OpenLayers.Control.Measure, as well as measure.html, to show an example.
If you want to add this control to your OL directory tree.....
The style.css would include the following:
div.olControlMeasure {
background-color: #FFFFFF;
top: 30px;
left: 400px;
display: block;
position: absolute;
font-family: Arial;
font-size: smaller;
font-weight: bold;
}
The base OpenLayers class would need to include the Measure.js in its JS files array:
var jsfiles=new Array(
...
"OpenLayers/Control/Measure.js"
);
___________________________________________________________
Yahoo! Mail is the world's favourite email. Don't settle for less, sign up for
your free account today http://uk.rd.yahoo.com/evt=44106/*http://uk.docs.yahoo.com/mail/winter07.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: =?utf-8?q?Measure.js?=
Type: application/x-javascript
Size: 3143 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/openlayers-users/attachments/20070515/ecb837b8/utf-8qMeasure.js
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20070515/ecb837b8/utf-8qmeasure.html
More information about the Users
mailing list