10446 Posts in 2223 Topics by 1719 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 2008 Views |
-
Google Maps without Forum

28 January 2009 at 11:31am
Hi, I have extended the Maps module with some simple classes that let you put simple maps on a page without the need to have the forum module installed. I want to submit the classes for use by the wider silverstripe community but am not sure how to do this. Need point of contact.
Cheers,
Dan -
Re: Google Maps without Forum

9 February 2009 at 3:33am
I was going to the do the same to use GMaps without the forum. I would love to try out your code and provide some feedback on it. Maybe you can attach it to this thread? Thanks!
-
Re: Google Maps without Forum

9 February 2009 at 9:47am Last edited: 9 February 2009 9:48am
class MapPage extends Page {
static $db = array(
// 'apiKey' => 'Varchar(255)',
'centLat' => 'Float',
'centLong' => 'Float',
'zoom' => 'Int',
'width' => 'Int',
'height' => 'Int'
);
static $has_one = array(
);
static $has_many = array(
);
static $many_many = array(
'Points' => 'Point'
);
function getCMSFields() {
$fields = parent::getCMSFields();
$tablefield = new ManyManyComplexTableField(
$this,
'Points',
'Point',
array(
'Name' => 'Name'/*,
'Lat' => 'Latitude',
'Long' => 'Longitude'*/
),
'getCMSFields_forPopup'/**/
);
//$tablefield->setAddTitle( 'A Point' );
//$tablefield->setParentClass('MapPage');
//$fields->addFieldToTab('Root.Content.GoogleMap', new TextField('apiKey'));
$fields->addFieldToTab( 'Root.Content.GoogleMap', new HeaderField( 'Google Maps Settings' ) );
$fields->addFieldsToTab('Root.Content.GoogleMap', array(
new TextField('centLat'),
new TextField('centLong'),
new TextField('zoom'),
new TextField('width'),
new TextField('height')//,
//$tablefield
)
);/**/
//$fields->addFieldToTab('Root.Content.GoogleMapPoints');
$fields->addFieldToTab( 'Root.Content.Points', new HeaderField( 'Points on Map' ) );
$fields->addFieldToTab( 'Root.Content.Points', $tablefield);
// $fields->addFieldToTab('Root.Content.MapPoints', $tablefield);
return $fields;
}}
class MapPage_Controller extends Page_Controller {
function Content() {
global $GMaps_API_Key;
ContentNegotiator::disable();
Requirements::css("maps/css/Maps.css");
Requirements::javascript("http://maps.google.com/maps?file=api&v=2&key=".$GMaps_API_Key);
$dbData = DataObject::get("Point", "`MapPageID` = '{$this->ID}'","",
" LEFT JOIN `MapPage_Points` ON `PointID` = `Point`.ID");
$map = new GMap('MyMap', $dbData , new GMapPoint($this->centLat ,$this->centLong), $this->zoom, $this->width, $this->height);
return $this->Content.$map->display();
}/**/}
class Point extends DataObject {
static $db = array(
'Name' => 'Varchar',
'Lat' => 'Float',
'Long' => 'Float'
);
static $belongs_many_many = array(
'MapPages' => 'MapPage'
);function getCMSFields_forPopup() {
$fields = new FieldSet();
$fields->push( new TextField( 'Name' ) );
$fields->push( new TextField( 'Lat' ) );
$fields->push( new TextField( 'Long' ) );
return $fields;
}public function toString() {
return $this->Lat.','.$this->Long;
}
} -
Re: Google Maps without Forum

9 February 2009 at 9:51am
These class provide a page type that doesn't require the forum to work. they extend the initial body of work without changing existing code.
enjoy
-
Re: Google Maps without Forum

15 February 2009 at 12:29am
hey danqxx, this looks like a really useful script!
unfortunately, I can't seem to get it to function using ss 2.2.3. this is the error output I get
Building Database
Creating database tables
# Newsletter
# Newsletter_SentRecipient
# Newsletter_Recipient
# NewsletterType
# PageComment
# CalendarDateTime
# RecurringDayOfMonth
# RecurringDayOfWeek
# RecurringException
# GMap
# GMapPoint
# PointFATAL ERROR: Bad class to singleton() - Point
At line 85 in /var/www/test_loc/htdocs/sapphire/core/Core.phpuser_error(Bad class to singleton() - Point,256)
line 85 of Core.phpsingleton(Point)
line 175 of DatabaseAdmin.phpDatabaseAdmin->doBuild()
line 90 of DatabaseAdmin.phpDatabaseAdmin->build(Array)
line 261 of Controller.phpController->run(Array)
line 104 of Director.phpDirector::direct(db/build)
line 158 of main.php
Context
Debug (Debug::showError() in line 180 of Debug.php)* className =
Point
* _SINGLETONS =
o Member =
Database record: Member
+ ID :0
o Newsletter =
Database record: Newsletter
+ ID :0
o Newsletter_SentRecipient =
Database record: Newsletter_SentRecipient
+ ID :0
o Newsletter_Recipient =
Database record: Newsletter_Recipient
+ ID :0
o NewsletterType =
Database record: NewsletterType
+ ID :0
o PageComment =
Database record: PageComment
+ ID :0
o CalendarDateTime =
Database record: CalendarDateTime
+ ID :0
o RecurringDayOfMonth =
Database record: RecurringDayOfMonth
+ ID :0
o RecurringDayOfWeek =
Database record: RecurringDayOfWeek
+ ID :0
o RecurringException =
Database record: RecurringException
+ ID :0
o GMap =
Database record: GMap
+ ID :0
o GMapPoint =
Database record: GMapPoint
+ ID :0
it's having trouble with the Point class? not sure how to resolve the issue.
thanks a lot foryour effort in putting this out there, really hope it's a simple fault at my end..
| 2008 Views | ||
|
Page:
1
|
Go to Top |


