summaryrefslogtreecommitdiff
path: root/httemplate/view/map.html
blob: 01ffc6db73dc799e9603b1b0f92d455cd9d5edd7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
%# the actual page
<& /elements/header-popup.html, {
     title => '',#$name,
     head  => include('.head'),
     etc   => 'onload="initialize()"',
     nobr  => 1,
   }
&>

<div id="map_canvas"></div>

<%def .head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />

<style type="text/css">
html { height: 100% }

body { height: 100%; margin: 0px; padding: 0px }

#map_canvas { height: 100%; }

@media print { #map_canvas { height: 500px; margin: 0; } }
</style>

<script type="text/javascript" src="https://maps.google.com/maps/api/js?v=3<% $apikey ? '&key='.$apikey : '' %>">
</script>

<script type="text/javascript">
var lengthLine=0;
var map;

// function name specified by google maps api, special hook for auth errors
function gm_authFailure () {
  document.body.innerHTML = 
<% include('/elements/google_maps_api_key.html', autherror => $apikey ) |js_string%>;
}


function initialize() {
  var latlng = new google.maps.LatLng(<%$lat%>, <%$lon%>);
  var myOptions = {
    center: latlng,
    zoom: 14,
    rotateControl: true,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  };

  map = new google.maps.Map(
    document.getElementById("map_canvas"),
    myOptions
  );
  map.setOptions( {rotateControl : true });

  var markerOptions = {
    map: map,
    position: latlng,
    title: <%$name |js_string%>
  };
  var marker = new google.maps.Marker(markerOptions);
}
</script>
</%def>
<%shared>
my ($lat, $lon, $name);
my $conf = new FS::Conf;
my $apikey = $conf->config('google_maps_api_key');
</%shared>
<%init>

$name = $cgi->param('name');

$lat = $cgi->param('lat');
$lon = $cgi->param('lon');
$lat =~ /^-?\d+(\.\d+)?$/ or die "bad latitude: $lat";
$lon =~ /^-?\d+(\.\d+)?$/ or die "bad longitude: $lat";

</%init>