I'm working on a Silverstripe project which contains geographical areas as part of the ModelAdmin/CMS interface.
Each area has the following information:
- North-east corner latitude
- North-east corner longitude
- South-west corner latitude
- South-west corner longitude
- Centre point latitude
- Centre point longitude
I'd like to be able to embed a simple Google Map showing the bounds so admin users have a visual reference. If I used an iframe and focussed on the centre point (Lat/Lng) it would be very easy using a Literalfield:
public function getCMSFields(){
$fields = parent::getCMSFields();
$fields->addFieldToTab(
'Root.Main',
LiteralField::Create('DisplayMap', '<iframe width="600" height="450"
src="https://www.google.com/maps/embed/v1/view?zoom=11&
center=-'.$this->Lat.','.$this->Lng.'&key=123456"></iframe>')
);
return $fields;
}
However I'd like the map to show the bound - something that I don't think is possible without Javascript.
What would be the best approach to embed a map in ModelAdmin that shows the bounds of the area?