OpenLayers 2 - 'immediate' measurement -
i trying create measurement control in openlayers, using openlayers.control.measure function, return features area in real time, when moving mouse around. have been doing lot of reading , many achieved using immediate
property of openlayers.control.measure control, can't seem work. when using immediate
property, area of feature when create new vertexes... not when moving mouse around. appreciate can't seem find doing wrong. here code using:
<!doctype html> <html> <head> <script src="scripts/jquery-213/jquery-2.1.3.min.js"></script> <script src="http://maps.google.com/maps/api/js?sensor=false&v=3.2"> </script> <script src="scripts/openlayers-2.10/openlayers.js"></script> <style type="text/css"> body { height: 100%; width: 100%; z-index: 1; } #map { height: 100%; min-height: 300px; width: 100%; position: absolute; top: 0; left: 0; margin: 0; z-index: 2; } #area{ position: absolute; top: 5px; right: 5px; width: 100px; height: 50px; color: blue; background-color: white; z-index: 3; } </style> <script type="text/javascript"> var map; var google_layer; $(document).ready(function() { map = new openlayers.map("map"); map.addcontrol(new openlayers.control.mouseposition()); google_layer = new openlayers.layer.google("google hybrid", { type: google.maps.maptypeid.hybrid }); map.addlayer(google_layer); map.setcenter(new openlayers.lonlat(2004093, 8234302), 12); var vectorlayer = new openlayers.layer.vector('vector layer'); map.addlayer(vectorlayer); var control_measurepoly = new openlayers.control.measure( openlayers.handler.polygon, { persist: true, immediate: true, eventlisteners: { "measurepartial": displayarea } }); function displayarea(event){ var geometry = event.geometry; var measure = event.measure; $("#area").html(measure); }; map.addcontrols([control_measurepoly]); control_measurepoly.activate(); }); </script> </head> <body> <div> <div id="map"></div> <div id='area'>0</div> </div> </form> </body> </html>
have great week-end! emil
this thread seems directly address problem:
http://lists.osgeo.org/pipermail/openlayers-users/2011-august/021903.html
Comments
Post a Comment