EmbedGoogleMapEmbedAPIHtmlBuilder

The Embed Google Map EmbedGoogleMapEmbedAPIHtmlBuilder class.

Defined (1)

The class is defined in the following location(s).

/embed_google_map.php  
  1. class EmbedGoogleMapEmbedAPIHtmlBuilder extends EmbedGoogleMapHtmlBuilder { 
  2.  
  3. private $baseUrl = "https://www.google.com/maps/embed/v1/search"; 
  4.  
  5. public function buildHtml(&$params) { 
  6. $url = parent::getUrl($params, $this->baseUrl); 
  7.  
  8. $html = parent::getIFrameBegin($params); 
  9.  
  10. if($params->isLink() == 0) { 
  11. $url .= "?key=".$params->getEmbedAPIKey(); 
  12. $url .= "&q=".urlencode($params->getAddress()); 
  13. $url .= "&zoom=".$params->getZoomLevel(); 
  14. $url .= "&maptype=".$this->getMapType($params->getMapType()); 
  15. if(strcmp($params->getLanguage(), '-') != 0) { 
  16. $url .= "&language=".$params->getLanguage(); 
  17. if($params->isLink() == 1 && $params->isGoogleMapsEngine() == 0) { 
  18. $html .= "src='$url&output=embed'></iframe>\n"; 
  19. } else { 
  20. $html .= "src='$url'></iframe>\n"; 
  21.  
  22. if($params->getAddLink() == 1) { 
  23. if($params->isGoogleMapsEngine() == 1) { 
  24. $url = str_replace('/embed', '/viewer', $url); 
  25. $html .= parent::getLinkHtml($url, $params->getLinkLabel()); 
  26. } else if($params->isLink() == 1) { 
  27. $html .= parent::getLinkHtml($url, $params->getLinkLabel()); 
  28. }  
  29. return $html; 
  30.  
  31. private function getMapType($mapType) { 
  32. if(strcmp(strtolower($mapType), 'm') == 0) { 
  33. return 'roadmap'; 
  34. } else if(strcmp(strtolower($mapType), 'k') == 0) { 
  35. return 'satellite'; 
  36. } else { 
  37. return 'roadmap';