public function showaroundmexml() { $lng = 0; $lat = 0; $excludeIDList = array(); if ($this->lng && $this->lat) { $lng = $this->lng; $lat = $this->lat; } elseif ($this->owner->ID) { $objects = GoogleMapLocationsObject::get()->filter(array("ParentID" => $this->owner->ID)); if ($count = $objects->count()) { foreach ($objects as $point) { $lng += $point->Longitude; $lat += $point->Latitude; $excludeIDList[] = $point->ID; } $lng = $lng / $count; $lat = $lat / $count; } } $classNameForParent = ''; if ($otherClass = $this->filter) { $classNameForParent = $otherClass; } if ($this->title) { $title = $this->title; } else { $title = "Closest to me"; } if ($lng && $lat) { $orderByRadius = GoogleMapLocationsObject::radiusDefinition($lng, $lat); $where = "(" . $orderByRadius . ") > 0 AND \"GoogleMapLocationsObject\".\"Latitude\" <> 0 AND \"GoogleMapLocationsObject\".\"Longitude\" <> 0"; if ($classNameForParent && !is_object($classNameForParent)) { $where .= " AND \"SiteTree_Live\".\"ClassName\" = '" . $classNameForParent . "'"; } if (count($excludeIDList)) { $where .= " AND \"GoogleMapLocationsObject\".\"ID\" NOT IN (" . implode(",", $excludeIDList) . ") "; } $join = "LEFT JOIN \"SiteTree_Live\" ON \"SiteTree_Live\".\"ID\" = \"GoogleMapLocationsObject\".\"ParentID\""; $objects = GoogleMapLocationsObject::get()->where($where)->sort($orderByRadius)->leftJoin("SiteTree_Live", "SiteTree_Live.ID = GoogleMapLocationsObject.ParentID")->limit(GoogleMap::get_number_shown_in_around_me()); if ($objects->count()) { return $this->makeXMLData(null, $objects, $title, Config::inst()->get("GoogleMap", "number_shown_in_around_me") . " closest points"); } else { return "no data 1"; //return false; } } return "no lng and lat"; }