},
{
- 'key' => 'safe-part_bill_event',
+ 'key' => 'google_maps_api_key',
'section' => 'UI',
- 'description' => 'Validates invoice event expressions against a preset list. Useful for webdemos, annoying to powerusers.',
- 'type' => 'checkbox',
+ 'description' => 'API key for google maps. This must be set for map and directions links to appear on customer pages. See <a href="https://developers.google.com/maps/documentation/javascript/get-api-key">Getting a Google Maps API Key</a>',
+ 'type' => 'text',
},
{
<& /elements/init_overlib.html &>
+% if ( $apikey ) {
+
<& /elements/popup_link.html,
'action' => $p. 'view/map.html?'. $query,
'label' => mt('map'),
&>
% }
+% } # end if $apikey
+
<A HREF="<%$p%>view/kml.cgi?<% $query %>"><% mt('earth') |h %></A>
<%init>
$js_name =~ s/^'//;
$js_name =~ s/'$//;
+my $conf = new FS::Conf;
+my $apikey = $conf->config('google_maps_api_key');
+
#for directions link
my @origin = $opt{company_address}
? @{ $opt{company_address} }
- : FS::Conf->new->config('company_address', $agentnum);
+ : $conf->config('company_address', $agentnum);
my $origin = uri_escape(join(',', @origin));
</%init>
}
</style>
-<script type="text/javascript"
-src="https://maps.google.com/maps/api/js?v=3.4&sensor=false">
+% my $conf = new FS::Conf;
+% my $apikey = $conf->config('google_maps_api_key');
+<script type="text/javascript" src="https://maps.google.com/maps/api/js?v=3&key=<% $apikey %>">
</script>
<script type="text/javascript">
directionsService.route(directionsRequest, function(result, status) {
if ( status == google.maps.DirectionsStatus.OK ) {
directionsDisplay.setDirections(result);
+ } else {
+ document.body.innerHTML = ('<P STYLE="color: red;">Directions lookup failed with the following error: '+status+'</P>');
}
});
}
@media print { #map_canvas { height: 500px; margin: 0; } }
</style>
-<script type="text/javascript"
-src="https://maps.google.com/maps/api/js?v=3.4&sensor=false">
+% my $conf = new FS::Conf;
+% my $apikey = $conf->config('google_maps_api_key');
+<script type="text/javascript" src="https://maps.google.com/maps/api/js?v=3&key=<% $apikey %>">
</script>
<script type="text/javascript">