Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 47 additions & 2 deletions src/Objects/Map.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
//use SilverStripe\Dev\Debug;
//use SilverStripe\View\ViewableData;

class Map extends ViewableData
class Map extends \ViewableData
{
use MapPosition;
//use MapPosition;

private $Debug;
private $ID;
Expand Down Expand Up @@ -219,4 +219,49 @@ public function GetJSONReactData()
return json_encode($this->GetReactData());
}

protected $Coords;

public function SetPosition($coords)
{
$this->Coords = $coords;
return $this;
}
public function GetPosition()
{
return $this->Coords;
}
public function GetLatitude()
{
return $this->Coords->GetLatitude();
}
public function GetLongitude()
{
return $this->Coords->GetLongitude();
}
public function GetLocationVariable($ID,$Suffix)
{
return "Location_{$Suffix}_{$ID}";
}
public function HasPosition()
{
return $this->Coords != null;
}
//Might Rename to IsValidCoordinate could cause misunderstanding
public function IsValidCoordinate()
{
return $this->Coords->IsValid();
}
public function RenderLocationVariable($ID,$Suffix)
{
return "var Location_{$Suffix}_{$ID} = new Microsoft.Maps.Location({$this->GetLatitude()},{$this->GetLongitude()}); ";
}
public function RenderLocation()
{
if($this->HasPosition())
{
return "new Microsoft.Maps.Location({$this->GetLatitude()},{$this->GetLongitude()})";
}
return "";
}

}