Skip to content

Commit

Permalink
let subdomains be comma-separated; resolves bozdoz#147
Browse files Browse the repository at this point in the history
  • Loading branch information
bozdoz committed Sep 13, 2022
1 parent eeb4b18 commit a8cb116
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion class.plugin-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ private function __construct()
'type' => 'text',
'helptext' => sprintf(
'%1$s %2$s <br/> <code>[leaflet-map subdomains="1234"]</code>',
__('Some maps get tiles from multiple servers with subdomains such as a,b,c,d or 1,2,3,4', 'leaflet-map'),
__('Some maps get tiles from multiple servers with subdomains such as a,b,c or 1,2,3 or cache1,cache2; pass a string where each char is its own subdomain, or pass comma-separated string', 'leaflet-map'),
$foreachmap
)
),
Expand Down
5 changes: 5 additions & 0 deletions shortcodes/class.map-shortcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,11 @@ protected function getAtts($atts='')
$tile_layer_options = $this->LM->filter_empty_string($tile_layer_options);
$tile_layer_options = $this->LM->filter_null($tile_layer_options);

if (strpos($tile_layer_options['subdomains'], ',') !== false) {
// subdomains can be comma-separated
$tile_layer_options['subdomains'] = explode(',', $tile_layer_options['subdomains']);
}

$atts['tile_layer_options'] = json_encode($tile_layer_options, JSON_NUMERIC_CHECK | JSON_UNESCAPED_SLASHES);

// TODO: find a better way to do this
Expand Down
2 changes: 1 addition & 1 deletion templates/shortcode-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
'[leaflet-map zoom=10 lat=48.855 lng=2.35 zoomcontrol !detect-retina]',
),
__("Alternate Map Tiles w/scrollwheel", 'leaflet-map') => array(
'[leaflet-map zoom=2 scrollwheel lat=-2.507 lng=32.902 tileurl=https://stamen-tiles-{s}.a.ssl.fastly.net/watercolor/{z}/{x}/{y}.jpg subdomains=abcd attribution="Map tiles by Stamen Design, under CC BY 3.0."]',
'[leaflet-map zoom=2 scrollwheel lat=-2.507 lng=32.902 tileurl=https://stamen-tiles-{s}.a.ssl.fastly.net/watercolor/{z}/{x}/{y}.jpg subdomains=a,b,c,d attribution="Map tiles by Stamen Design, under CC BY 3.0."]',
),
__("Marker Popup Messages (on click)", 'leaflet-map') => array(
'[leaflet-map lat=59.913 lng=10.739 zoom=12]',
Expand Down

0 comments on commit a8cb116

Please sign in to comment.