javascript - How to set text in center of curve shape with jCanvas? -


i'm drawing "map" jcanvas using drawline method , need put house number in center of curve shape (it can has random number of angles).

also please note, objects draggable , text must draggable it.

or how can calculate center of object, can has random number of angles?

i wrote function solved problem. var points must send svg polygon points.

function getcenter(points, index)  {      if (typeof points!="undefined")       {          var pairs = [];          pairs = points.split(" ");                                var first = true;          var min; var max;                    for(var i=0;i<pairs.length;i++)          {              var list = pairs[i].split(',');                            if(first===true)              {                  first = false;                  min = max = list[index];              }              else              {                  if(list[index]<min) min = list[index];                  if(list[index]>max) max = list[index];              }          }                      min = parseint(min);          max = parseint(max);            var result = (min+max)/2;            return result;      }      else return false;  };


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -