[OpenLayers-Users] RE : Measure Control - get distance on mouse move

James Leveille James_Leveille at dmr.ca
Thu Mar 19 11:48:04 EDT 2009


Try this :
 
                                 var oMeasrLinearCtrlOptions =
                                 {
                                    title: 'bla bla bla',
                                    displayUnits: 'km',
                                    eventListeners:
                                    {
                                        'measure': handleMeasr,
                                        'measurepartial': handleMeasr
                                    },
                                    handlerOptions:
                                    {
                                        persist: true
                                    }
                                };
                                var oMeasrLinearCtrl = new OpenLayers.Control.Measure ( OpenLayers.Handler.Path, oMeasrLinearCtrlOptions );
                                oToolbar.addControl ( oMeasrLinearCtrl, { iconCls: 'measrlinear', toggleGroup: 'map' } );

 
function handleMeasr(event)
{
    if(event.order==1) // LINEAR
        displayMeasr (event.measure.toFixed(3) + " " + event.units, "");
    else // POLYGON
    {
        var area = event.measure.toFixed(3) + " " + event.units;
        var a = oMap.getControlsByClass('OpenLayers.Control.Measure');
        var ctrl = a[0];
        var length = (ctrl.getBestLength(event.geometry)[0]).toFixed(3) + " " + ctrl.getBestLength(event.geometry)[1];
        //displayMeasr (length, area);
    }
}

 
 
James 
 

________________________________

De: users-bounces at openlayers.org de la part de RFeagin
Date: jeu. 19-03-09 11:38
À: users at openlayers.org
Objet : [OpenLayers-Users] Measure Control - get distance on mouse move




Has anyone made the measure control get the distance on mouse move?  After
the first point has been added it would be nice to see a 'real-time'
distance using the current mouse position as the final point.

Just thought I'd check to see if someone had already done it and was willing
to share.

Thanks
--
View this message in context: http://n2.nabble.com/Measure-Control---get-distance-on-mouse-move-tp2503580p2503580.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.

_______________________________________________
Users mailing list
Users at openlayers.org
http://openlayers.org/mailman/listinfo/users


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20090319/7bdd376c/attachment.html


More information about the Users mailing list