Skip to content

Commit c949c24

Browse files
committed
Separate examples into a different repository
1 parent 797122f commit c949c24

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+5456
-1
lines changed

Core/Autoloader.php

+136
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
<?php
2+
3+
/**
4+
* SplClassLoader implementation that implements the technical interoperability
5+
* standards for PHP 5.3 namespaces and class names.
6+
*
7+
* http://groups.google.com/group/php-standards/web/final-proposal
8+
*
9+
* // Example which loads classes for the Doctrine Common package in the
10+
* // Doctrine\Common namespace.
11+
* $classLoader = new SplClassLoader('Doctrine\Common', '/path/to/doctrine');
12+
* $classLoader->register();
13+
*
14+
* @author Jonathan H. Wage <[email protected]>
15+
* @author Roman S. Borschel <[email protected]>
16+
* @author Matthew Weier O'Phinney <[email protected]>
17+
* @author Kris Wallsmith <[email protected]>
18+
* @author Fabien Potencier <[email protected]>
19+
*/
20+
class SplClassLoader
21+
{
22+
private $_fileExtension = '.php';
23+
private $_namespace;
24+
private $_includePath;
25+
private $_namespaceSeparator = '\\';
26+
27+
/**
28+
* Creates a new <tt>SplClassLoader</tt> that loads classes of the
29+
* specified namespace.
30+
*
31+
* @param string $ns The namespace to use.
32+
*/
33+
public function __construct($ns = null, $includePath = null)
34+
{
35+
$this->_namespace = $ns;
36+
$this->_includePath = $includePath;
37+
}
38+
39+
/**
40+
* Sets the namespace separator used by classes in the namespace of this class loader.
41+
*
42+
* @param string $sep The separator to use.
43+
*/
44+
public function setNamespaceSeparator($sep)
45+
{
46+
$this->_namespaceSeparator = $sep;
47+
}
48+
49+
/**
50+
* Gets the namespace seperator used by classes in the namespace of this class loader.
51+
*
52+
* @return void
53+
*/
54+
public function getNamespaceSeparator()
55+
{
56+
return $this->_namespaceSeparator;
57+
}
58+
59+
/**
60+
* Sets the base include path for all class files in the namespace of this class loader.
61+
*
62+
* @param string $includePath
63+
*/
64+
public function setIncludePath($includePath)
65+
{
66+
$this->_includePath = $includePath;
67+
}
68+
69+
/**
70+
* Gets the base include path for all class files in the namespace of this class loader.
71+
*
72+
* @return string $includePath
73+
*/
74+
public function getIncludePath()
75+
{
76+
return $this->_includePath;
77+
}
78+
79+
/**
80+
* Sets the file extension of class files in the namespace of this class loader.
81+
*
82+
* @param string $fileExtension
83+
*/
84+
public function setFileExtension($fileExtension)
85+
{
86+
$this->_fileExtension = $fileExtension;
87+
}
88+
89+
/**
90+
* Gets the file extension of class files in the namespace of this class loader.
91+
*
92+
* @return string $fileExtension
93+
*/
94+
public function getFileExtension()
95+
{
96+
return $this->_fileExtension;
97+
}
98+
99+
/**
100+
* Installs this class loader on the SPL autoload stack.
101+
*/
102+
public function register()
103+
{
104+
spl_autoload_register(array($this, 'loadClass'));
105+
}
106+
107+
/**
108+
* Uninstalls this class loader from the SPL autoloader stack.
109+
*/
110+
public function unregister()
111+
{
112+
spl_autoload_unregister(array($this, 'loadClass'));
113+
}
114+
115+
/**
116+
* Loads the given class or interface.
117+
*
118+
* @param string $className The name of the class to load.
119+
* @return void
120+
*/
121+
public function loadClass($className)
122+
{
123+
if (null === $this->_namespace || $this->_namespace.$this->_namespaceSeparator === substr($className, 0, strlen($this->_namespace.$this->_namespaceSeparator))) {
124+
$fileName = '';
125+
$namespace = '';
126+
if (false !== ($lastNsPos = strripos($className, $this->_namespaceSeparator))) {
127+
$namespace = substr($className, 0, $lastNsPos);
128+
$className = substr($className, $lastNsPos + 1);
129+
$fileName = str_replace($this->_namespaceSeparator, DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
130+
}
131+
$fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . $this->_fileExtension;
132+
133+
require ($this->_includePath !== null ? $this->_includePath . DIRECTORY_SEPARATOR : '') . $fileName;
134+
}
135+
}
136+
}

Core/CustomControl.php

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
3+
namespace PHPGoogleMaps\Core;
4+
5+
/**
6+
* CustomControl Class
7+
* Adds a custom control to a map
8+
* @link http://code.google.com/apis/maps/documentation/javascript/examples/control-custom.html
9+
*/
10+
11+
class CustomControl extends \PHPGoogleMaps\Core\MapObject {
12+
13+
/**
14+
* Custom control position
15+
*
16+
* @link http://code.google.com/apis/maps/documentation/javascript/reference.html#ControlPosition
17+
*
18+
* @var string
19+
*/
20+
protected $position = 'TOP_RIGHT';
21+
22+
/**
23+
* Control listeners
24+
*
25+
* All the listeners that have been added to the control
26+
*
27+
* @var array
28+
*/
29+
protected $listeners = array();
30+
31+
/**
32+
* Constructor
33+
*
34+
* @param array $outeroptions array of control's wrapper options
35+
* @param array $inner_options array of control's inner options
36+
* @return CustomControl
37+
*/
38+
public function __construct( array $outer_options=null, array $inner_options=null, $position=null ) {
39+
$this->options['outer'] = $outer_options;
40+
$this->options['inner'] = $inner_options;
41+
if ( $position ) {
42+
$this->position = $position;
43+
}
44+
}
45+
46+
/**
47+
* Add Listener
48+
*
49+
* Add a listener to the control
50+
*
51+
* @param string $event Event to listen for (click)
52+
* @param string $function Function to call
53+
* @return void
54+
*/
55+
public function addListener( $event, $function ) {
56+
$this->listeners[] = array(
57+
'event' => $event,
58+
'function' => $function
59+
);
60+
}
61+
62+
}

Core/CustomControlDecorator.php

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
namespace PHPGoogleMaps\Core;
4+
5+
/**
6+
* CustomControl decorator class
7+
* This holds the custom control's id and map
8+
*/
9+
10+
class CustomControlDecorator extends \PHPGoogleMaps\Core\MapObjectDecorator {
11+
12+
/**
13+
* ID of the custom control in the map
14+
*
15+
* @var integer
16+
*/
17+
protected $_id;
18+
19+
/**
20+
* Map ID of the map the custom control is attached to
21+
*
22+
* @var string
23+
*/
24+
protected $_map;
25+
26+
/**
27+
* Constructor
28+
*
29+
* @param CustonControl $control Custom control to decorate
30+
* @param int $id ID of the custom control in the map
31+
* @param string $map Map ID of the map the custom control is attached to
32+
* @return CustomControl
33+
*/
34+
public function __construct( CustomControl $control, $id, $map ) {
35+
parent::__construct( $control, array( '_id' => $id, '_map' => $map ) );
36+
}
37+
38+
/**
39+
* Returns the javascript variable of the custom control
40+
*
41+
* @return string
42+
*/
43+
public function getJsVar() {
44+
return sprintf( '%s.custom_controls[%s]', $this->_map, $this->_id );
45+
}
46+
47+
}

Core/LatLng.php

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
3+
namespace PHPGoogleMaps\Core;
4+
5+
/**
6+
* LatLng class
7+
* Base class used for storing lat/lngs
8+
*/
9+
10+
class LatLng extends PositionAbstract {
11+
12+
/**
13+
* Latitude
14+
*
15+
* @var float
16+
*/
17+
public $lat;
18+
19+
/**
20+
* Longitude
21+
*
22+
* @var float
23+
*/
24+
public $lng;
25+
26+
/**
27+
* LatLng location
28+
*
29+
* @var string
30+
*/
31+
public $location;
32+
33+
/**
34+
* Constructor
35+
*
36+
* @param float $lat Latitude
37+
* @param float $lng Longitude
38+
* @return LatLng
39+
*/
40+
public function __construct( $lat, $lng, $location=null ) {
41+
$this->lat = $lat;
42+
$this->lng = $lng;
43+
$this->location = $location;
44+
}
45+
46+
public function getLatLng() {
47+
return $this;
48+
}
49+
public function getLat() {
50+
return $this->lat;
51+
}
52+
public function getLng() {
53+
return $this->lng;
54+
}
55+
56+
/**
57+
* Returns a string in the format lat,lng
58+
*
59+
* @return string
60+
*/
61+
public function __toString() {
62+
return sprintf( '%s,%s', $this->lat, $this->lng );
63+
}
64+
}

0 commit comments

Comments
 (0)