예제 #1
0
 /**
  * @param mixed $uri
  *
  * @return array
  */
 protected function parsePolygon($uri)
 {
     if (!is_array($uri)) {
         $uri = array($uri);
     }
     $result = array();
     $limit = self::PATH_LIMIT;
     foreach ($uri as $path) {
         $poly = new Polygon();
         $tmp = explode('|', $path);
         foreach ($tmp as $val) {
             if (strpos($val, ':') !== false) {
                 $pairs = explode(':', $val);
                 if (!isset($pairs[1])) {
                     continue;
                 }
                 switch (strtolower($pairs[0])) {
                     case 'label':
                         $poly->label = trim($pairs[1]);
                         break;
                     case 'color':
                         $fc = $this->parseColor($pairs[1]);
                         if ($fc !== false) {
                             $poly->color = $fc;
                         }
                         break;
                     case 'fillcolor':
                         $fc = $this->parseColor($pairs[1]);
                         if ($fc !== false) {
                             $poly->fillcolor = $fc;
                         }
                         break;
                     case 'weight':
                         // limit weight to 1 to 20
                         $poly->weight = max(1, min((int) $pairs[1], 20));
                         break;
                 }
             } else {
                 $xy = $this->parseLocation($val);
                 if ($xy !== false) {
                     $poly->addPoint($xy);
                 }
             }
             $limit--;
             if ($limit < 0) {
                 break;
             }
         }
         $result[] = $poly;
         if ($limit < 0) {
             break;
         }
     }
     return $result;
 }
예제 #2
0
 /**
  * @param Polygon $p
  */
 public function addPolygon(Polygon $p)
 {
     foreach ($p->xy as $pos) {
         $this->extend($pos);
     }
     $p->setMap($this);
     $this->polys[] = $p;
 }