/** * Catch all method calls and check if they are a call to the JavaScript API. * * This method recognizes calls in the format (add|remove)[itemType]. This allows to execute addMarker, addCircle, * removeRectangle and removeInfoWindow. * * @param string $name Name of method called. * @param array $arguments Arguments passed when calling the method. * @return mixed */ public function __call($name, $arguments) { if (preg_match('/([^A-Z]*)(.*)/', $name, $matches)) { list(, $method, $type) = $matches; if (in_array($method, array('add', 'remove'))) { $args = $this->_parseJsArguments($arguments); return $this->_outputScript("window.map.{$method}('{$type}', {$args});"); } } parent::__call($name, $arguments); }