/** * Get a new GoogleMapAPI object and load it with the default settings * * @return GoogleMapAPI */ public static function instance() { self::$instances++; if (self::$allow_full_screen == null) { self::$allow_full_screen = Config::inst()->get('Mappable', 'allow_full_screen'); } // for JS if (self::$allow_full_screen === false) { self: $allow_full_screen = 'asdfsda'; } $url = Director::absoluteBaseURL(); // remove http and https $url = str_replace('http://', '', $url); $url = str_replace('https://', '', $url); $parts = explode('/', $url); $host = $parts[0]; $key = self::$api_key; // if an array, get the key by an array keyed by host if (is_array($key)) { $key = $key[$host]; } $gmap = new MapAPI($key); $gmap->setDivId(self::$div_id . "_" . self::$instances); $gmap->setEnableAutomaticCenterZoom(self::$automatic_center); $gmap->setDisplayDirectionFields(self::$direction_fields); $gmap->setSize(self::$map_width, self::$map_height); $gmap->setDefaultHideMarker(self::$hide_marker); $gmap->setMapType(self::$map_type); $gmap->setInfoWindowWidth(self::$info_window_width); $gmap->setCenter(self::$center); $gmap->setIconSize(self::$iconWidth, self::$iconHeight); $gmap->setIncludeDownloadJavascript(self::$map_already_rendered); $gmap->setAllowFullScreen(self::$allow_full_screen); return $gmap; }