Jump to:

10929 Posts in 2613 Topics by 1809 members

All other Modules

SilverStripe Forums » All other Modules » Mappable problem on dataobjectdecorator

Discuss all other Modules here.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 248 Views
  • cumquat
    Avatar
    Community Member
    190 Posts

    Mappable problem on dataobjectdecorator Link to this post

    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

  • cumquat
    Avatar
    Community Member
    190 Posts

    Re: Mappable problem on dataobjectdecorator Link to this post

    *bump*

    248 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.