-
Notifications
You must be signed in to change notification settings - Fork 9
/
map_custom_styles.php
45 lines (32 loc) · 1.31 KB
/
map_custom_styles.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
<?php
// This is for my examples
require( '_system/config.php' );
$relevant_code = array(
'\PHPGoogleMaps\Overlay\MapStyle'
);
// Autoload stuff
require( '_system/autoload.php' );
$custom_style_json = '[ { featureType: "water", elementType: "all", stylers: [ { hue: "#ff0008" }, { saturation: 71 }, { lightness: -43 }, { gamma: 0.83 } ] },{ featureType: "road", elementType: "all", stylers: [ { saturation: -24 }, { hue: "#1100ff" } ] },{ featureType: "landscape", elementType: "all", stylers: [ { hue: "#11ff00" }, { saturation: 100 }, { lightness: -34 } ] } ]';
$custom_style = new \PHPGoogleMaps\Overlay\MapStyle( 'Custom', $custom_style_json );
$map = new \PHPGoogleMaps\Map;
$map->addObject( $custom_style );
// You must explicitly set the map types and include the custom style
$map->setMapTypes( array( 'roadmap', 'terrain', $custom_style ) );
$map->setCenter( 'San Diego, CA' );
$map->setZoom( 14 );
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Custom Map Styles - <?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 Map Styles</h1>
<?php require( '_system/nav.php' ) ?>
<?php $map->printMap() ?>
</body>
</html>