RT# 82949 - changes section name from fees to pricing, better opiton
[freeside.git] / httemplate / view / map.html
1 %# the actual page
2 <& /elements/header-popup.html, {
3      title => '',#$name,
4      head  => include('.head'),
5      etc   => 'onload="initialize()"',
6      nobr  => 1,
7    }
8 &>
9
10 <div id="map_canvas"></div>
11
12 <%def .head>
13 <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
14
15 <style type="text/css">
16 html { height: 100% }
17
18 body { height: 100%; margin: 0px; padding: 0px }
19
20 #map_canvas { height: 100%; }
21
22 @media print { #map_canvas { height: 500px; margin: 0; } }
23 </style>
24
25 <script type="text/javascript" src="https://maps.google.com/maps/api/js?v=3<% $apikey ? '&key='.$apikey : '' %>">
26 </script>
27
28 <script type="text/javascript">
29 var lengthLine=0;
30 var map;
31
32 // function name specified by google maps api, special hook for auth errors
33 function gm_authFailure () {
34   document.body.innerHTML = 
35 <% include('/elements/google_maps_api_key.html', autherror => $apikey ) |js_string%>;
36 }
37
38
39 function initialize() {
40   var latlng = new google.maps.LatLng(<%$lat%>, <%$lon%>);
41   var myOptions = {
42     center: latlng,
43     zoom: 14,
44     rotateControl: true,
45     mapTypeId: google.maps.MapTypeId.ROADMAP
46   };
47
48   map = new google.maps.Map(
49     document.getElementById("map_canvas"),
50     myOptions
51   );
52   map.setOptions( {rotateControl : true });
53
54   var markerOptions = {
55     map: map,
56     position: latlng,
57     title: <%$name |js_string%>
58   };
59   var marker = new google.maps.Marker(markerOptions);
60 }
61 </script>
62 </%def>
63 <%shared>
64 my ($lat, $lon, $name);
65 my $conf = new FS::Conf;
66 my $apikey = $conf->config('google_maps_api_key');
67 </%shared>
68 <%init>
69
70 $name = $cgi->param('name');
71
72 $lat = $cgi->param('lat');
73 $lon = $cgi->param('lon');
74 $lat =~ /^-?\d+(\.\d+)?$/ or die "bad latitude: $lat";
75 $lon =~ /^-?\d+(\.\d+)?$/ or die "bad longitude: $lat";
76
77 </%init>