diff options
author | Jonathan Prykop <jonathan@freeside.biz> | 2016-09-23 19:00:29 -0500 |
---|---|---|
committer | Jonathan Prykop <jonathan@freeside.biz> | 2016-09-27 12:33:12 -0500 |
commit | e7451be44db0d8244f85059169ac6239b2440687 (patch) | |
tree | e69d7b21c657342cb1425ecdc390b4f60b8585db | |
parent | 3b435e5106bd9fd278611e5b0a23cd2e7e2e07c2 (diff) |
71873: GlobalVision - directions [v3 reconcile]
-rw-r--r-- | FS/FS/Conf.pm | 6 | ||||
-rw-r--r-- | httemplate/elements/coord-links.html | 9 | ||||
-rw-r--r-- | httemplate/view/directions.html | 7 | ||||
-rw-r--r-- | httemplate/view/map.html | 5 |
4 files changed, 19 insertions, 8 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index 4738e596a..0c291666d 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -2226,10 +2226,10 @@ and customer address. Include units.', }, { - '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', }, { diff --git a/httemplate/elements/coord-links.html b/httemplate/elements/coord-links.html index 45b813201..a755791ae 100644 --- a/httemplate/elements/coord-links.html +++ b/httemplate/elements/coord-links.html @@ -1,5 +1,7 @@ <& /elements/init_overlib.html &> +% if ( $apikey ) { + <& /elements/popup_link.html, 'action' => $p. 'view/map.html?'. $query, 'label' => mt('map'), @@ -19,6 +21,8 @@ &> % } +% } # end if $apikey + <A HREF="<%$p%>view/kml.cgi?<% $query %>"><% mt('earth') |h %></A> <%init> @@ -45,10 +49,13 @@ $m->interp->apply_escapes($js_name, 'js_string'); $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> diff --git a/httemplate/view/directions.html b/httemplate/view/directions.html index f14a11a07..a07df403b 100644 --- a/httemplate/view/directions.html +++ b/httemplate/view/directions.html @@ -38,8 +38,9 @@ body { height: 100%; margin: 0px; padding: 0px } } </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"> @@ -62,6 +63,8 @@ function show_route() { 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>'); } }); } diff --git a/httemplate/view/map.html b/httemplate/view/map.html index 3122de6a0..d996a330c 100644 --- a/httemplate/view/map.html +++ b/httemplate/view/map.html @@ -22,8 +22,9 @@ body { height: 100%; margin: 0px; padding: 0px } @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"> |