leaflet_more_maps_cartodb-2.1.3.patch 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. diff --git a/leaflet_more_maps.module b/leaflet_more_maps.module
  2. index cce4c86..33e9a60 100644
  3. --- a/leaflet_more_maps.module
  4. +++ b/leaflet_more_maps.module
  5. @@ -556,6 +556,38 @@ function _leaflet_more_maps_assemble_default_map_info(array &$map_info, array $d
  6. ],
  7. ];
  8. +
  9. + // cartodb
  10. + $attr_cartodb = '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors &copy; <a href="https://carto.com/attributions">CARTO</a>';
  11. + $cartodb_names = [
  12. + 'light_all',
  13. + 'light_nolabels',
  14. + 'light_only_labels',
  15. + 'dark_all',
  16. + 'dark_nolabels',
  17. + 'dark_only_labels',
  18. + 'rastertiles/voyager',
  19. + 'rastertiles/voyager_nolabels',
  20. + 'rastertiles/voyager_only_labels',
  21. + 'rastertiles/voyager_labels_under'
  22. + ];
  23. + foreach ($cartodb_names as $cartodb_name) {
  24. + $code = mb_strtolower($cartodb_name);
  25. + $label = t('Cartodb @name', ['@name' => $cartodb_name]);
  26. + $url_template = "https://{s}.basemaps.cartocdn.com/$code/{z}/{x}/{y}{r}.png";
  27. + $map_info["cartodb-$code"] = [
  28. + 'label' => $label,
  29. + 'description' => $label,
  30. + 'settings' => $default_settings,
  31. + 'layers' => [
  32. + '' => [
  33. + 'urlTemplate' => $url_template,
  34. + 'options' => ['attribution' => $attr_cartodb],
  35. + ]
  36. + ]
  37. + ];
  38. + }
  39. +
  40. // Add hook to change default list of maps.
  41. // Let other modules alter the default map info.
  42. \Drupal::moduleHandler()->invokeAll('leaflet_more_maps_list_alter', array(&$map_info));