function addCustomMap($pagesOrGoogleMapLocationsObjects, $retainOldSessionData = false, $title = '') { $this->initiateMap(); $sessionTitle = preg_replace('/[^a-zA-Z0-9]/', '', $title); $isGoogleMapLocationsObject = true; $addCustomGoogleMapArray = GoogleMapDataResponse::get_custom_google_map_session_data(); if ($pagesOrGoogleMapLocationsObjects) { if (!$retainOldSessionData) { $this->clearCustomMaps(); } else { if (is_array($addCustomGoogleMapArray)) { $customMapCount = count($addCustomGoogleMapArray); } } foreach ($pagesOrGoogleMapLocationsObjects as $obj) { if ($obj instanceof SiteTree) { $isGoogleMapLocationsObject = false; } if (!$obj->ID) { user_error("Page provided to addCustomMap that does not have an ID", E_USER_ERROR); } if (!isset($addCustomGoogleMapArray[$title])) { $addCustomGoogleMapArray[$title] = array(); } $addCustomGoogleMapArray[$title][] = $obj->ID; } } GoogleMapDataResponse::set_custom_google_map_session_data($addCustomGoogleMapArray); Session::save(); if ($isGoogleMapLocationsObject) { $fn = "showcustomdosmapxml"; } else { $fn = "showcustompagesmapxml"; } $this->addMap($fn, $title); return array(); }
public function showcustomdosmapxml() { $array = array(-1); $addCustomGoogleMapArray = GoogleMapDataResponse::get_custom_google_map_session_data(); if (isset($addCustomGoogleMapArray[$this->title])) { $array = $addCustomGoogleMapArray[$this->title]; } //print_r($array); if (is_array($array) && count($array)) { $where = array("GoogleMapLocationsObject.ID" => $array); } else { //3.0TODO check this $where = array("GoogleMapLocationsObject.ID:LessThan" => 0); //$where = " \"GoogleMapLocationsObject\".\"ID\" < 0"; } $googleMapLocationsObjects = GoogleMapLocationsObject::get()->filter($where); return $this->makeXMLData(null, $googleMapLocationsObjects, $this->title, $this->title); }