-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathmarkers_custom_icons.php
82 lines (63 loc) · 2.31 KB
/
markers_custom_icons.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
// This is just for my examples
require( '_system/config.php' );
$relevant_code = array(
'\PHPGoogleMaps\Overlay\Marker',
'\PHPGoogleMaps\Overlay\MarkerDecorator',
'\PHPGoogleMaps\Overlay\MarkerIcon'
);
// Autoloader stuff
require( '_system/autoload.php' );
$map = new \PHPGoogleMaps\Map;
// Create a marker
$marker1_options = array(
'title' => 'Custom marker icon',
'content' => 'This marker uses a custom icon'
);
$marker1 = \PHPGoogleMaps\Overlay\Marker::createFromLocation( 'New York, NY', $marker1_options );
// Create a marker icon or the icon and shadow
$icon1 = new \PHPGoogleMaps\Overlay\MarkerIcon( '_images/yellow_marker.png' );
$shadow1 = new \PHPGoogleMaps\Overlay\MarkerIcon( '_images/yellow_marker_shadow.png' );
// Set the x anchor point to 11
// y anchor point defaults to image height
$shadow1->setAnchor( 11 );
// Attach the icon and shadow to the marker
$marker1->setIcon( $icon1 )->setShadow( $shadow1 );
// Create another marker
$marker2_options = array(
'title' => 'Custom marker icon',
'content' => 'This marker uses a custom icon with a sprite to limit http connections'
);
$marker2 = \PHPGoogleMaps\Overlay\Marker::createFromLocation( 'New Haven, CT', $marker2_options );
// This one will use a sprite for the icon and shadow
$icon2 = \PHPGoogleMaps\Overlay\MarkerIcon::create( '_images/purple_marker_sprite.png', array( 'height' => 34 ) );
// Height and width default to size of the image
$shadow2_options = array(
'height' => 24,
'origin_x' => 0,
'origin_y' => 34,
'anchor_x' => 11,
'anchor_y' => 24
);
// Create another icon from the same image
$shadow2 = new \PHPGoogleMaps\Overlay\MarkerIcon( '_images/purple_marker_sprite.png', $shadow2_options );
// Attach the icon and shadow to the second marker
$marker2->setIcon( $icon2 )->setShadow( $shadow2 );
// Add the markers to the map
$map->addObjects( array( $marker1, $marker2 ) );
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Custom Marker Icons - <?php echo PAGE_TITLE ?></title>
<link rel="stylesheet" type="text/css" href="_css/style.css">
<?php $map->printHeaderJS() ?>
<?php $map->printMapJS() ?>
</head>
<body>
<h1>Custom Marker Icons</h1>
<?php require( '_system/nav.php' ) ?>
<?php $map->printMap() ?>
</body>
</html>