@@ -8,7 +8,6 @@ require Exporter;
8
8
@EXPORT = qw(
9
9
new
10
10
pgx_get_web_geomap
11
- read_plot_defaults
12
11
) ;
13
12
14
13
# ####### #### #### #### #### #### #### #### #### ####
@@ -19,18 +18,24 @@ sub new {
19
18
20
19
my $class = shift ;
21
20
my $args = shift ;
22
- my $map_params = read_plot_defaults();
21
+
22
+ my $path_of_this_module = File::Basename::dirname( eval { ( caller () )[1] } );
23
+ my $defs = LoadFile($path_of_this_module .' /../config/config.yaml' );
23
24
24
25
foreach my $param (keys %{$args }) {
25
- if (grep {/ ^$param $ / } keys %{$map_params }) {
26
+ if (grep {/ ^$param $ / } keys %{ $defs -> { plot_params } }) {
26
27
my $p_v = $args -> {$param };
27
28
if ($p_v =~ / \w / ) {
28
- $map_params -> {$param } = $p_v }
29
+ $defs -> { plot_params } -> {$param } = $p_v }
29
30
}
30
31
}
31
32
33
+ foreach (keys %{$defs -> {plot_params }}) {
34
+ $defs -> {map_params }-> {$_ } = $defs -> {plot_params }-> {$_ };
35
+ }
36
+
32
37
my $self = {
33
- parameters => $map_params ,
38
+ parameters => $defs -> { map_params } ,
34
39
plotid => $map_params -> {plotid },
35
40
map => q{ } ,
36
41
};
@@ -56,10 +61,8 @@ sub _aggregate_geomarkers {
56
61
push (@{$markers -> {$m_k }-> {items }}, $label );
57
62
print Dumper($group , $label , $markers -> {$m_k }-> {size }, $markers -> {$m_k }-> {items });
58
63
}
59
- # print Dumper(%$markers);
60
64
61
65
62
- # return $markers;
63
66
return $pgx -> {geomarkers };
64
67
65
68
}
@@ -123,7 +126,7 @@ L.circle([$m->{lat}, $m->{lon}], {
123
126
$pgx -> {map } .= << "__HTML__" ;
124
127
125
128
<!-- map needs to exist before we load leaflet -->
126
- <div id="map-canvas " style="width: $pgx ->{parameters}->{canvas_w_px }px; height: $pgx ->{parameters}->{canvas_h_px }px;"></div>
129
+ <div id="$pgx ->{parameters}->{id} " style="width: $pgx ->{parameters}->{map_w_px }px; height: $pgx ->{parameters}->{map_h_px }px;"></div>
127
130
128
131
<!-- Make sure you put this AFTER Leaflet's CSS -->
129
132
<script src="https://unpkg.com/leaflet\@ 1.8.0/dist/leaflet.js"
@@ -137,7 +140,7 @@ $_markersJs
137
140
var markersGroup = L.featureGroup(markers);
138
141
139
142
// Create the map.
140
- var map = L.map('map-canvas ', { renderer: L.svg() } ).setView([$pgx ->{parameters}->{latitude}, $pgx ->{parameters}->{longitude}], $pgx ->{parameters}->{zoom});
143
+ var map = L.map('$pgx ->{parameters}->{id} ', { renderer: L.svg() } ).setView([$pgx ->{parameters}->{latitude}, $pgx ->{parameters}->{longitude}], $pgx ->{parameters}->{zoom});
141
144
142
145
L.tileLayer('$pgx ->{parameters}->{tiles_source}', {
143
146
minZoom: $pgx ->{parameters}->{zoom_min},
@@ -156,15 +159,5 @@ __HTML__
156
159
157
160
}
158
161
159
- # ###############################################################################
160
-
161
- sub read_plot_defaults {
162
-
163
- my $path_of_this_module = File::Basename::dirname( eval { ( caller () )[1] } );
164
- my $plotPars = LoadFile($path_of_this_module .' /../config/config.yaml' );
165
- return $plotPars -> {map_params };
166
-
167
- }
168
-
169
162
170
163
1;
0 commit comments