my $lon = -999.0;
my $lat = -999.0;
my $zoom = -1;
+my $baselayer = undef;
if (defined(param('lon'))) {
$lon = param('lon');
unless ($lon =~ m/^-{0,1}\d+\.\d+$/) { $lon = -999.0; }
unless ($zoom =~ m/^\d+$/) { $zoom = -1; }
if (($zoom < 0) || ($zoom > 30)) { $lat = -1; }
}
+if (defined(param('layers'))) {
+ my @layerlist = ('osmde', 'osmorg');
+ my $layers = param('layers');
+ my $i;
+ for ($i = 0; $i < int(@layerlist); $i++) {
+ if (substr($layers, $i, 1) eq 'B') { # This is our baselayer
+ $baselayer = $layerlist[$i];
+ }
+ }
+}
my $OLF;
unless (open($OLF, '<' . $openlayerstemplate)) {
print("Sorry, failed to read my map template.\n"); exit(0);
$ll =~ s/var\s+zoom\s*=\s*\d+;/var zoom = $zoom;/;
}
if (($lon >= -180.0) && ($lat >= -180.0) && ($zoom >= 0)) { # All values required in that case
- $ll =~ s!<img src="(.*?)/staticmaplite\?.*?size=([^"&]+).*?"!<img src="$1/staticmaplite?center=$lat,$lon&zoom=$zoom&size=$2"!;
+ my $rest = '';
+ if (defined($baselayer)) {
+ $rest .= '&maptype=' . $baselayer;
+ }
+ $ll =~ s!<img src="(.*?)/staticmaplite\?.*?size=([^"&]+).*?"!<img src="$1/staticmaplite?center=$lat,$lon&zoom=$zoom&size=$2$rest"!;
}
print($ll);
}