Beispiel #1
0
 /**
  * @param string $map_js_name 
  * @return string Javascript code to create the rectangle
  * @author Antonio Ramirez        
  */
 public function toJs($map_js_name = 'map')
 {
     $this->options['map'] = $map_js_name;
     $return = '';
     if (null !== $this->info_window) {
         if ($this->info_window_shared) {
             $info_window_name = $map_js_name . '_info_window';
             $this->addEvent(new EGMapEvent('click', 'if (' . $info_window_name . ') ' . $info_window_name . '.close();' . PHP_EOL . $info_window_name . ' = ' . $this->info_window->getJsName() . ';' . PHP_EOL . $info_window_name . ".setPosition(" . $this->getCenterOfBounds()->toJs() . ");" . PHP_EOL . $info_window_name . ".open(" . $map_js_name . ");" . PHP_EOL));
         } else {
             $this->addEvent(new EGMapEvent('click', $this->info_window->getJsName() . ".setPosition(" . $this->getCenterOfBounds()->toJs() . ");" . PHP_EOL . $this->info_window->getJsName() . ".open(" . $map_js_name . ");" . PHP_EOL));
         }
         $return .= $this->info_window->toJs();
     }
     $return .= 'var ' . $this->getJsName() . ' = new ' . $this->rectangle_object . '(' . EGMap::encode($this->options) . ');' . PHP_EOL;
     foreach ($this->events as $event) {
         $return .= $event->getEventJs($this->getJsName()) . PHP_EOL;
     }
     return $return;
 }
Beispiel #2
0
 public function getEncodedOptions()
 {
     return EGMap::encode(parent::getOptions());
 }