public static function create_new($searchedFor, $parentID = 0, $addGoogleMapLocationsObjectOrItsID = false) { $obj = new GoogleMapSearchRecord(); $obj->SearchedFor = $searchedFor; $obj->ParentID = $parentID; if (!$addGoogleMapLocationsObjectOrItsID) { //do nothing } elseif ($addGoogleMapLocationsObjectOrItsID === true || ($addGoogleMapLocationsObjectOrItsID = 1)) { //create object $location = new GoogleMapLocationsObject(); $location->Address = $searchedFor; $location->Manual = false; $location->write(); $obj->GoogleMapLocationsObjectID = $location->ID; } else { $obj->GoogleMapLocationsObjectID = $addGoogleMapLocationsObjectOrItsID; } $obj->write(); return $obj; }
function findnearaddress($data, $form) { $address = Convert::raw2sql($data["Address"]); $className = Convert::raw2sql($data["ClassName"]); $pointArray = GetLatLngFromGoogleUsingAddress::get_placemark_as_array($address); $this->address = $pointArray["FullAddress"]; if (!isset($pointArray["Longitude"]) || !isset($pointArray["Latitude"])) { GoogleMapSearchRecord::create_new($address, $this->owner->ID, false); $form->addErrorMessage('Address', _t("GoogleMapLocationsDOD.ADDRESSNOTFOUND", "Sorry, address could not be found..."), 'warning'); $this->redirectBack(); return; } else { GoogleMapSearchRecord::create_new(Convert::raw2sql($address), $this->owner->ID, true); } $lng = $pointArray["Longitude"]; $lat = $pointArray["Latitude"]; //$form->Fields()->fieldByName("Address")->setValue($pointArray["address"]); //does not work .... //$this->owner->addMap($action = "showsearchpoint", "Your search",$lng, $lat); $this->owner->addMap($action = "showaroundmexml", "Closests to your search", $lng, $lat, $className); return array(); }