Просмотр файла news/libraries/web/google/staticmap.php

Размер файла: 1.22Kb
  1. <?php
  2.  
  3. /*
  4. Copyright (c) 2009-2014 F3::Factory/Bong Cosca, All rights reserved.
  5.  
  6. This file is part of the Fat-Free Framework (http://fatfree.sf.net).
  7.  
  8. THE SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF
  9. ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  10. IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  11. PURPOSE.
  12.  
  13. Please see the license.txt file for more information.
  14. */
  15.  
  16. namespace Web\Google;
  17.  
  18. //! Google Static Maps API v2 plug-in
  19. class StaticMap {
  20.  
  21. const
  22. //! API URL
  23. URL_Static='http://maps.googleapis.com/maps/api/staticmap';
  24.  
  25. protected
  26. //! Query arguments
  27. $query=array();
  28.  
  29. /**
  30. * Specify API key-value pair via magic call
  31. * @return object
  32. * @param $func string
  33. * @param $args array
  34. **/
  35. function __call($func,array $args) {
  36. $this->query[]=array($func,$args[0]);
  37. return $this;
  38. }
  39.  
  40. /**
  41. * Generate map
  42. * @return string
  43. **/
  44. function dump() {
  45. $fw=\Base::instance();
  46. $web=\Web::instance();
  47. $out='';
  48. return ($req=$web->request(
  49. self::URL_Static.'?'.array_reduce(
  50. $this->query,
  51. function($out,$item) {
  52. return ($out.=($out?'&':'').
  53. urlencode($item[0]).'='.urlencode($item[1]));
  54. }
  55. ))) && $req['body']?$req['body']:FALSE;
  56. }
  57.  
  58. }