BxDolLocationMapLeaflet.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup UnaCore UNA Core
  7. * @{
  8. */
  9. class BxDolLocationMapLeaflet extends BxDolLocationMap
  10. {
  11. /**
  12. * Get location map for single address
  13. * @param $aLocation location array with the following indexes:
  14. * lat, lng, country, state, city, zip, street, street_number
  15. * @param $sLocationHtml formatted address string
  16. * @param $aParams some specific params
  17. */
  18. public function getMapSingle($aLocation, $sLocationHtml = '', $aParams = array())
  19. {
  20. $sZoom = (int)getParam('sys_location_map_zoom_default');
  21. if (!$sZoom)
  22. $sZoom = '7';
  23. if (!empty($aParams['location_leaflet_zoom']))
  24. $sZoom = $aParams['location_leaflet_zoom'];
  25. $sProvider = getParam('sys_location_leaflet_provider');
  26. if (!empty($aParams['location_leaflet_provider']))
  27. $sProvider = $aParams['location_leaflet_provider'];
  28. $this->addCssJs();
  29. return $this->_oTemplate->parseHtmlByName('location_map_leaflet.html', array_merge($aLocation, array(
  30. 'id' => time().rand(0, PHP_INT_MAX),
  31. 'zoom' => $sZoom,
  32. 'provider' => $sProvider,
  33. 'location_string' => $sLocationHtml,
  34. )));
  35. }
  36. public function addCssJs()
  37. {
  38. parent::addCssJs();
  39. $this->_oTemplate->addCss(array(
  40. 'location_map_leaflet.css',
  41. BX_DIRECTORY_PATH_PLUGINS_PUBLIC . 'leaflet/|leaflet.css',
  42. ));
  43. $this->_oTemplate->addJs(array(
  44. 'leaflet/leaflet.js',
  45. 'leaflet-providers/leaflet-providers.js',
  46. ));
  47. }
  48. static public function getProviders()
  49. {
  50. $a = array(
  51. 'OpenStreetMap.Mapnik',
  52. 'OpenStreetMap.DE',
  53. 'OpenStreetMap.CH',
  54. 'OpenStreetMap.France',
  55. 'OpenStreetMap.HOT',
  56. 'OpenStreetMap.BZH',
  57. 'OpenTopoMap',
  58. 'Stadia.AlidadeSmooth',
  59. 'Stadia.AlidadeSmoothDark',
  60. 'Stadia.OSMBright',
  61. 'Stadia.Outdoors',
  62. 'CyclOSM',
  63. 'Stamen.Toner',
  64. 'Stamen.TonerBackground',
  65. 'Stamen.TonerLite',
  66. 'Stamen.Watercolor',
  67. 'Stamen.Terrain',
  68. 'Stamen.TerrainBackground',
  69. 'Esri.WorldStreetMap',
  70. 'Esri.DeLorme',
  71. 'Esri.WorldTopoMap',
  72. 'Esri.WorldImagery',
  73. 'Esri.WorldTerrain',
  74. 'Esri.WorldShadedRelief',
  75. 'Esri.WorldPhysical',
  76. 'Esri.OceanBasemap',
  77. 'Esri.NatGeoWorldMap',
  78. 'Esri.WorldGrayCanvas',
  79. 'MtbMap',
  80. 'CartoDB.Positron',
  81. 'CartoDB.PositronNoLabels',
  82. 'CartoDB.DarkMatter',
  83. 'CartoDB.DarkMatterNoLabels',
  84. 'CartoDB.Voyager',
  85. 'CartoDB.VoyagerNoLabels',
  86. 'CartoDB.VoyagerLabelsUnder',
  87. 'HikeBike.HikeBike',
  88. 'HikeBike.HillShading',
  89. 'USGS.USTopo',
  90. 'USGS.USImagery',
  91. 'USGS.USImageryTopo',
  92. );
  93. return array_combine($a, $a);
  94. }
  95. }
  96. /** @} */