Source of file StaticGoogleMapSmarter.php
Size: 1,388 Bytes - Last Modified: 2021-12-23T10:41:56+00:00
/var/www/docs.ssmods.com/process/src/code/api/StaticGoogleMapSmarter.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445 | <?php class StaticGoogleMapSmarter extends Object { /** * Array is Formatted Like This: * LocationOfIcon, LinkOfMapPin * Locations can be: 12 Main Street, bla bla OR -45,180 (lat, lng) * Icon can be something like: /themes/mysite/images/MyIcon.png (max 64 x 64) * * * @param int $width * @param int $height * @param array $locationsAndIcons * * @return string */ public static function create_map($width = 640, $height = 640, $locationsAndIcons = array()) { $link = 'https://maps.googleapis.com/maps/api/staticmap?'. 'autoscale=2'. '&size='.$width.'x'.$height. '&type=roadmap'. '&format=png'. '&visual_refresh=true'; $key = Config::inst()->get('GoogleMapSmarter', 'api_key'); if ($key) { $link .= '&key='.$key; } foreach ($locationsAndIcons as $locationAndIcon) { $location = $locationAndIcon[0]; $iconLink = isset($locationAndIcon[1]) ? urlencode(Director::absoluteURL($locationAndIcon[1])) : ''; if ($iconLink) { $link .= '&markers=icon:'.$iconLink.'%7Cshadow:true%7C'.$location; } else { $link .= '&markers=size:mid%7Ccolor:0xff0000%7Clabel:%7C'.$location; } } return $link; } } |