Ejemplo n.º 1
0
 /**
  * @param mixed $markers
  *
  * @return Marker[]
  */
 protected function parseMarker($markers)
 {
     if (!is_array($markers)) {
         $markers = array($markers);
     }
     $result = array();
     $limit = self::MARKER_LIMIT;
     foreach ($markers as $line) {
         $marker = new Marker();
         $tmp = explode('|', $line);
         foreach ($tmp as $val) {
             if (strpos($val, ':') !== false) {
                 $pairs = explode(':', $val);
                 if (!isset($pairs[1])) {
                     continue;
                 }
                 switch (strtolower($pairs[0])) {
                     case 'color':
                         $marker->setColor($this->parseColor($pairs[1]));
                         break;
                     case 'label':
                         $marker->setLabel(trim($pairs[1]));
                         break;
                     case 'label_size':
                         $marker->setFontSize(max(3, min((int) $pairs[1], 20)));
                         break;
                     case 'label_color':
                         $fc = $this->parseColor(trim($pairs[1]));
                         if ($fc !== false) {
                             $marker->setFontColor($fc);
                         }
                         break;
                     case 'label_outline':
                         $fc = $this->parseColor(trim($pairs[1]));
                         if ($fc !== false) {
                             $marker->setFontOutline($fc);
                         }
                         break;
                     case 'icon':
                         // following icons are supported by icon generator
                         $allowed = array('building', 'camp', 'dig', 'lm_marker', 'npc', 'op_townhall', 'mektoub', 'portal', 'spawn', 'tp_kami', 'tp_karavan', 'none');
                         $pairs[1] = trim($pairs[1]);
                         if (in_array($pairs[1], $allowed)) {
                             $marker->setIcon($pairs[1]);
                         }
                         break;
                     case 'circle':
                         $ellipse = explode(',', $pairs[1]);
                         if (!isset($ellipse[1])) {
                             $ellipse[1] = $ellipse[0];
                         }
                         $marker->circleRadius($ellipse[0], $ellipse[1]);
                         break;
                     case 'fillcolor':
                         $fc = $this->parseColor($pairs[1]);
                         if ($fc !== false) {
                             $marker->setCircleFillColor($fc);
                         }
                         break;
                     case 'weight':
                         $marker->setCircleStrokeWeight($pairs[1]);
                         break;
                 }
             } else {
                 $xy = $this->parseLocation($val);
                 if ($xy !== false) {
                     $marker->addPoint($xy);
                 }
             }
             $limit--;
             if ($limit < 0) {
                 break;
             }
         }
         $result[] = $marker;
         if ($limit < 0) {
             break;
         }
     }
     return $result;
 }
Ejemplo n.º 2
0
 /**
  * @param Marker $m
  */
 public function addMarker(Marker $m)
 {
     // use ingame coords here
     foreach ($m->xy as $pos) {
         $this->extend($pos);
     }
     $m->setMap($this);
     $this->markers[] = $m;
 }