Create polyline

[Open in new Window]

include_once('../../GoogleMapsPHP/Classes/Core/Bootstrap.php');

$map = \AdGrafik\GoogleMapsPHP\Utility\ClassUtility::makeInstance('AdGrafik\\GoogleMapsPHP\\MapBuilder');
$map->setCenter('48.608202, 16.373749');

$map->add('Polyline', array(
	'path' => array(
		'48.0, 16.0', '48.6, 16.6',
		'49.2, 16.0', '48.6, 15.4',
	),
	'strokeColor' => 'maroon',
	'strokeOpacity' => .5,
	'infoWindow' => array(
		'position' => 2,
		'content' => '<strong>Hello</strong> World!',
		'closeOnClickAgain' => TRUE,
	),
));

echo $map;

There are three ways to attach info windows to a shape

  1. You can attach an info window to the shape by using the property infoWindow. In this example you see the position variable has the value 2, which means, that the info window will be attached to the second angle of the shape.
  2. The second option to set a position for the info window is to define an explicit LatLng-position like '48.0, 16.0'.
  3. If you don't set any position, like in the example below, the info window will be attached to the center of the shape by default.

Create polygon

[Open in new Window]

include_once('../../GoogleMapsPHP/Classes/Core/Bootstrap.php');

$map = \AdGrafik\GoogleMapsPHP\Utility\ClassUtility::makeInstance('AdGrafik\\GoogleMapsPHP\\MapBuilder');
$map->setCenter('48.608202, 16.373749');

$map->add('Polygon', array(
	'paths' => array(
		'48.0, 16.0', '48.6, 16.6',
		'49.2, 16.0', '48.6, 15.4',
	),
	'strokeColor' => 'maroon',
	'strokeOpacity' => .5,
	'fillColor' => 'maroon',
	'fillOpacity' => .15,
	'infoWindow' => array(
		'content' => '<strong>Hello</strong> World!',
		'closeOnClickAgain' => TRUE,
	),
));

echo $map;

Polyline with markers

[Open in new Window]

include_once('../../GoogleMapsPHP/Classes/Core/Bootstrap.php');

$map = \AdGrafik\GoogleMapsPHP\Utility\ClassUtility::makeInstance('AdGrafik\\GoogleMapsPHP\\MapBuilder');
$map->setCenter('48.608202, 16.373749');

$map->add('Polyline', array(
	'path' => array(
		'48.0, 16.0', '48.2, 16.2', '48.4, 16.4', '48.6, 16.6',
		'48.8, 16.4', '49.0, 16.2', '49.2, 16.0', '49.0, 15.8',
		'48.8, 15.6', '48.6, 15.4', '48.4, 15.6', '48.2, 15.8',
	),
	'strokeColor' => 'maroon',
	'strokeOpacity' => .5,
	'marker' => array(
		array(
			'title' => 'Hello World 1!',
			'icon' => '../GoogleMapsPHP/Ressources/Public/Icons/Marker/airport.png',
			'shadow' => array(
				'url' => '../GoogleMapsPHP/Ressources/Public/Icons/Shadow/shadow.png',
				'anchor' => array(15, 30),
			),
		),
		array(
			'title' => 'Hello World 2!',
			'icon' => '../GoogleMapsPHP/Ressources/Public/Icons/Marker/golf.png',
			'shadow' => array(
				'url' => '../GoogleMapsPHP/Ressources/Public/Icons/Shadow/shadow.png',
				'anchor' => array(15, 30),
			),
		),
	),
	'markerOptionSplit' => '0 |*| 1 |*| 0',
));

echo $map;

Polygon with markers and info windows

[Open in new Window]

include_once('../../GoogleMapsPHP/Classes/Core/Bootstrap.php');

$map = \AdGrafik\GoogleMapsPHP\Utility\ClassUtility::makeInstance('AdGrafik\\GoogleMapsPHP\\MapBuilder', array(
	'closeAllInfoWindowsOnMapClick' => TRUE,
	'center' => '48.608202, 16.373749',
));

$map->add('Polygon', array(
	'paths' => array(
		'48.0, 16.0', '48.2, 16.2', '48.4, 16.4', '48.6, 16.6',
		'48.8, 16.4', '49.0, 16.2', '49.2, 16.0', '49.0, 15.8',
		'48.8, 15.6', '48.6, 15.4', '48.4, 15.6', '48.2, 15.8',
	),
	'strokeColor' => 'maroon',
	'strokeOpacity' => .5,
	'fillColor' => 'maroon',
	'fillOpacity' => .15,
	'marker' => array(
		array(
			'title' => 'Hello World 1!',
			'infoWindow' => array(
				'content' => '<strong>Hello</strong> World 1!',
				'closeOnClickAgain' => TRUE,
			),
		),
		array(
			'title' => 'Hello World 2!',
			'infoWindow' => array(
				'content' => '<strong>Hello</strong> World 2!',
				'closeOnClickAgain' => TRUE,
			),
		),
		array(
			'title' => 'Hello World 3!',
			'infoWindow' => array(
				'content' => '<strong>Hello</strong> World 3!',
				'closeOnClickAgain' => TRUE,
			),
		),
	),
	'markerOptionSplit' => '0 || 1 |*| 2 || 0 || 2 |*| 1 || 0',
));

echo $map;

It's also possible to define info windows to each marker using the option infoWindow within the option marker