location.br.inc 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. // This file contributed by Avi Alkalay <avi unix sh> to the
  3. // Location Drupal module, based on other files on same folder.
  4. //
  5. // - Fixed Unicode chars and accents
  6. // - Added support for Google Maps on location_map_link_*_providers()
  7. //
  8. // March, 2010
  9. // São Paulo, Brazil
  10. // Brazil
  11. function location_province_list_br() {
  12. return array(
  13. 'AC' => "Acre",
  14. 'AL' => "Alagoas",
  15. 'AM' => "Amazonas",
  16. 'AP' => "Amapá",
  17. 'BA' => "Bahia",
  18. 'CE' => "Ceara",
  19. 'DF' => "Distrito Federal",
  20. 'ES' => "Espírito Santo",
  21. 'GO' => "Goias",
  22. 'MA' => "Maranhão",
  23. 'MG' => "Minas Gerais",
  24. 'MS' => "Mato Grosso do Sul",
  25. 'MT' => "Mato Grosso",
  26. 'PA' => "Pará",
  27. 'PB' => "Paraíba",
  28. 'PE' => "Pernambuco",
  29. 'PI' => "Piaui",
  30. 'PR' => "Paraná",
  31. 'RJ' => "Rio de Janeiro",
  32. 'RN' => "Rio Grande do Norte",
  33. 'RO' => "Rondônia",
  34. 'RR' => "Roraima",
  35. 'RS' => "Rio Grande do Sul",
  36. 'SC' => "Santa Catarina",
  37. 'SE' => "Sergipe",
  38. 'SP' => "São Paulo",
  39. 'TO' => "Tocantins");
  40. }
  41. function location_map_link_br_providers() {
  42. return array(
  43. 'google' => array(
  44. 'name' => 'Google Maps',
  45. 'url' => 'http://maps.google.com.br',
  46. 'tos' => 'http://maps.google.com/intl/pt-BR/help/terms_maps.html',
  47. ),
  48. );
  49. }
  50. function location_map_link_br_default_providers() {
  51. return array('google');
  52. }
  53. function location_map_link_br_google($location = array()) {
  54. $query_params = array();
  55. $q = NULL;
  56. foreach (array('street', 'city', 'province', 'postal_code', 'country') as $field) {
  57. if (isset($location[$field])) {
  58. $query_params[] = $location[$field];
  59. }
  60. }
  61. if (location_has_coordinates($location)) {
  62. $q = $location['latitude'] . ' ' . $location['longitude'];
  63. if ($location[name] != "") {
  64. $q .= " ($location[name]," . implode(', ', $query_params) . ")";
  65. } else {
  66. $q .= ' (' . implode(', ', $query_params) . ')';
  67. }
  68. } else if (count($query_params) > 0) {
  69. $q = implode(", ", $query_params);
  70. if ($location[name] != "") {
  71. $q .= " ($location[name])";
  72. }
  73. }
  74. $q = urlencode($q);
  75. if ($q != NULL) {
  76. return ('http://maps.google.com.br?q='.$q );
  77. }
  78. else {
  79. return NULL;
  80. }
  81. }
  82. /**
  83. * Returns minimum and maximum latitude and longitude needed to create a bounding box.
  84. */
  85. function location_bounds_br() {
  86. return array(
  87. 'minlng' => -73.97965,
  88. 'minlat' => -33.8089,
  89. 'maxlng' => -28.8133,
  90. 'maxlat' => 5.259233,
  91. );
  92. }