Calculate midpoint for snapping

المشرف العام

Administrator
طاقم الإدارة
How to calculate midpoint of all lines in layers, and add to it layer for midpoint snapping, using OpenLayers 2.13?

I've tried the following code, but does not work:

var features=vectors.features; var len=vectors.features.length; for (var i=0 ; i < len ; i++){ for(var j=0 ; j<features.geometry.getVertices().length ; j++){ points.push(features.geometry.getVertices()[j]); } } i=0; while(i<points.length){ xA=points.x; yA=points.y; xB=points[i+1].x; yB=points[i+1].y; xC=(xA+xB)/2; yC=(yA+yB)/2; midPoints.push(new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(xC,yC))); i++; }

أكثر...
 
أعلى