Hi there,
Still having some problems trying to implement the mappable module on the members table. If i put my code directly onto the members.php file in sapphire i get it to work but if i try to use the same code but as an extension to the dataobject decorator the module fails to work. It would appear from firebug that the code fails to pick up the records in the members table. as i get a syntax error for the
map.setCenter(new GlatLng(,),90;
so it looks like it falls over because it has no data to return even though the lat and long fields on the table have data in. Again if i just move this code to the member.php page it works fine. below is the code for the extension page.
class MemberLocExtension extends DataObjectDecorator implements Mappable {
public function extraStatics() {
return array (
'db' => array (
'Lat' => 'Varchar',
'Lon' => 'Varchar',
),
);
}
public function getLatitude() {
return $this->Lat;
}
public function getLongitude() {
return $this->Lon;
}
public function getMapContent() {
return GoogleMapUtil::sanitize($this->renderWith('MapBubble'));
}
public function getGridRef() {
$ll2 = new LatLng($this->Lat, $this->Lon);
$os2 = $ll2->toOSRef();
//return $os2->toSixFigureString();
$tobebroken = $os2->toSixFigureString();
return substr($tobebroken,0,2) . " " .substr($tobebroken,2,5) . " " . substr($tobebroken,7,5);
}
public function getMapCategory() {
return $this->Type;
}
public function getMapPin() {
return "GIS/images/map1.png";
}
public function updateCMSFields( FieldSet &$fields )
{
$fields->removeByName('Lat');
$fields->removeByName('Lon');
$fields->addFieldToTab("Root.Location", new LatLongField(array(
new TextField('Lat','Latitude'),
new TextField('Lon','Longitude')
),
array('Postcode')
));
}
}
Cheers
Mick