Hi Yus, I think now it works.
You can see the solution I propose in https://github.com/jorix/OL-DynamicMeasure Problems: -------- * Labels do not remain at the end of measure. * Using the freehand the map is dirtied by the labels. * Layer of the labels (`vlayer`) should be on top of the drawing layer. * Allow the use of immediate measure (new in 2.11) Try: http://jorix.github.com/OL-DynamicMeasure/examples/measure-dynamic.html Xavier Mamano Yus wrote > > Hi. > > Ran into a small problem when change to OpenLayers 2.11 with showing the > length of each segment on the measuring line. > > Previously after placing points A --> B, B --> C. The length of segment A > to B would show up between those points, likewise with B to C and after > ending the line the total would be displayed. > > My script worked fine with OpenLayers 2.10, but after changing to > OpenLayers 2.11 as soon as I end the line only the segment values > disappear from the vector layer. > > I understand the problem, but am having trouble working out the logic... > > Below is the script I am using: > line: new OpenLayers.Control.Measure(OpenLayers.Handler.Path, { > persist: true, > handlerOptions: { > layerOptions: { > renderers: renderer, > styleMap: styleMap > } > }, > textNodes: null, > callbacks:{ > create: > function(){ > this.textNodes = []; > vlayer.destroyFeatures(vlayer.features); *<-- Believe the > problem is here* > mouseMovements = 0; > }, > modify: > function(point, line){ > if(mouseMovements++ < 5){ > return; > } > var len = line.geometry.components.length; > var from = line.geometry.components[len -2]; > var to = line.geometry.components[len -1]; > var ls = new OpenLayers.Geometry.LineString([from, to]); > var dist = this.getBestLength(ls); > if(!dist[0]){ > return; > } > var total = this.getBestLength(line.geometry); > var label = dist[0].toFixed(3) + " " + dist[1]; > var textNode = this.textNodes[len -2] || null; > if(textNode && !textNode.layer){ > this.textNodes.pop(); > textNode = null; > } > if(!textNode){ > var c = ls.getCentroid(); > textNode = new OpenLayers.Feature.Vector( > new OpenLayers.Geometry.Point(c.x, c.y), {}, { > label: "", > fontColor: "#800517", > fontSize: "12px", > fontFamily: "Tahoma", > fontWeight: "bold", > labelAlign: "cm" > }); > this.textNodes.push(textNode); > vlayer.addFeatures([textNode]); > } > textNode.geometry.x = (from.x + to.x) / 2; > textNode.geometry.y = (from.y + to.y) / 2; > textNode.style.label = label; > textNode.layer.drawFeature(textNode); > this.events.triggerEvent("measuredynamic", { > measure: dist[0], > total: total[0], > units: dist[1], > order: 1, > geometry: ls > }); > } > } > }), > > Any advice is very appreciated. Thanks in advance > -- View this message in context: http://osgeo-org.1803224.n2.nabble.com/Adding-Segment-Length-to-Path-tp7029815p7081881.html Sent from the OpenLayers Dev mailing list archive at Nabble.com. _______________________________________________ Dev mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/openlayers-dev
