Source of file Here.php
Size: 1,767 Bytes - Last Modified: 2021-12-24T06:46:37+00:00
/var/www/docs.ssmods.com/process/src/src/Provider/Here.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 | <?php namespace EdgarIndustries\ElementalMap\Provider; use SilverStripe\Control\Director; use SilverStripe\Core\Injector\Injectable; use SilverStripe\SiteConfig\SiteConfig; class Here implements MapProviderInterface { use Injectable; protected $title = 'HERE'; protected $variant = 'normal.day'; public function getTitle() { return $this->title; } private function getBaseUrl() { $subdomain = mt_rand(1, 4); $type = $this->variant == 'hybrid.day' ? 'aerial' : 'base'; return Director::isLive() ? 'https://' . $subdomain . '.' . $type . '.maps.api.here.com/maptile/2.1/' : 'https://' . $subdomain . '.' . $type . '.maps.cit.api.here.com/maptile/2.1/'; } public function getLeafletParams() { $siteconfig = SiteConfig::current_site_config(); return (object) [ 'attribution' => '<a href="https://developer.here.com/">HERE</a>', 'app_id' => $siteconfig->ElementalMapHereId, 'app_code' => $siteconfig->ElementalMapHereToken, 'maxZoom' => 20, ]; } public function getTileUrl() { $url = $this->getBaseUrl() . implode('/', [ 'maptile', 'newest', $this->variant, '{z}', '{x}', '{y}', '256', $this->variant == 'hybrid.day' ? 'png' : 'png8', ]); return $url . '?app_id={app_id}&app_code={app_code}&lg=eng'; } public function requiresAuth() { return ['ElementalMapHereId', 'ElementalMapHereToken']; } public function requireCss() { return false; } public function requireJs() { return false; } } |