Update copyright date for 2020
[civicrm-core.git] / templates / CRM / Contact / Form / Task / Map / Google.tpl
CommitLineData
6a488035
TO
1{*
2 +--------------------------------------------------------------------+
fee14197 3 | CiviCRM version 5 |
6a488035 4 +--------------------------------------------------------------------+
f299f7db 5 | Copyright CiviCRM LLC (c) 2004-2020 |
6a488035
TO
6 +--------------------------------------------------------------------+
7 | This file is a part of CiviCRM. |
8 | |
9 | CiviCRM is free software; you can copy, modify, and distribute it |
10 | under the terms of the GNU Affero General Public License |
11 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
12 | |
13 | CiviCRM is distributed in the hope that it will be useful, but |
14 | WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
16 | See the GNU Affero General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU Affero General Public |
19 | License and the CiviCRM Licensing Exception along |
20 | with this program; if not, contact CiviCRM LLC |
21 | at info[AT]civicrm[DOT]org. If you have questions about the |
22 | GNU Affero General Public License or the licensing of CiviCRM, |
23 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
24 +--------------------------------------------------------------------+
25*}
26{if $showDirectly}
27 {assign var=height value="350px"}
28 {assign var=width value="425px"}
29{else}
30 {assign var=height value="600px"}
31 {assign var=width value="100%"}
32{/if}
33{assign var=defaultZoom value=16}
34{literal}
a4da0993 35<script src="//maps.googleapis.com/maps/api/js?{/literal}{if $mapKey}key={$mapKey}{/if}{literal}&sensor=false&callback=initMap" type="text/javascript" defer="defer"></script>
6a488035
TO
36<script type="text/javascript">
37 function initMap() {
38 var latlng = new google.maps.LatLng({/literal}{$center.lat},{$center.lng}{literal});
39 var map = new google.maps.Map(document.getElementById("google_map"));
40 map.setCenter(latlng);
41 map.setMapTypeId(google.maps.MapTypeId.ROADMAP);
42 setMapOptions(map);
43 }
44
45 function setMapOptions(map) {
46 bounds = new google.maps.LatLngBounds( );
47 {/literal}
48 {foreach from=$locations item=location}
49 {if $location.url and ! $profileGID}
50 {literal}
b7054e52 51 var data = "{/literal}<a href='{$location.url}'>{$location.displayName}</a><br />{if !$skipLocationType}{$location.location_type}<br />{/if}{$location.address}<br /><br />{ts}Get Directions FROM:{/ts}&nbsp;<input type=hidden id=to value='{$location.displayAddress}'><input type=text id=from size=20>&nbsp;<a href=\"#\" onclick=\"gpopUp(); return false;\">&raquo; Go</a>";
6a488035
TO
52 {else}
53 {capture assign="profileURL"}{crmURL p='civicrm/profile/view' q="reset=1&id=`$location.contactID`&gid=$profileGID"}{/capture}
54 {literal}
b7054e52 55 var data = "{/literal}<a href='{$profileURL}'>{$location.displayName}</a><br />{if !$skipLocationType}{$location.location_type}<br />{/if}{$location.address}<br /><br />{ts}Get Directions FROM:{/ts}&nbsp;<input type=hidden id=to value='{$location.displayAddress}'><input type=text id=from size=20>&nbsp;<a href=\"#\" onclick=\"gpopUp(); return false;\">&raquo; Go</a>";
6a488035
TO
56 {/if}
57 {literal}
58 var address = "{/literal}{$location.address}{literal}";
59 {/literal}
60 {if $location.lat}
61 var point = new google.maps.LatLng({$location.lat},{$location.lng});
62 var image = null;
63 {if $location.image && ( $location.marker_class neq 'Event' ) }
64 image = '{$location.image}';
65 {else}
66 {if $location.marker_class eq 'Individual'}
67 image = "{$config->resourceBase}i/contact_ind.gif";
68 {/if}
69 {if $location.marker_class eq 'Household'}
70 image = "{$config->resourceBase}i/contact_house.png";
71 {/if}
72 {if $location.marker_class eq 'Organization'}
73 image = "{$config->resourceBase}i/contact_org.gif";
74 {/if}
75 {/if}
76 {literal}
77 createMarker(map, point, data, image);
78 bounds.extend(point);
79 {/literal}
80 {/if}
81 {/foreach}
82 map.setCenter(bounds.getCenter());
83 {if count($locations) gt 1}
84 map.fitBounds(bounds);
85 map.setMapTypeId(google.maps.MapTypeId.TERRAIN);
86 {elseif $location.marker_class eq 'Event' || $location.marker_class eq 'Individual'|| $location.marker_class eq 'Household' || $location.marker_class eq 'Organization' }
87 map.setZoom({$defaultZoom});
88 {else}
89 map.setZoom({$defaultZoom});
90 {/if}
91 {literal}
92 }
93
94 function createMarker(map, point, data, image) {
95 var marker = new google.maps.Marker({ position: point,
96 map: map,
97 icon: image
98 });
99 var infowindow = new google.maps.InfoWindow();
100 google.maps.event.addListener(marker, 'click', function() { infowindow.setContent(data);
101 infowindow.open(map,marker);
102 });
103 }
104
105 function gpopUp() {
106 var from = document.getElementById('from').value;
107 var to = document.getElementById('to').value;
108 var URL = "http://maps.google.com/maps?saddr=" + from + "&daddr=" + to;
109 day = new Date();
110 id = day.getTime();
111 eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=780,height=640,left = 202,top = 100');");
112 }
6a488035
TO
113</script>
114{/literal}
115<div id="google_map" style="width: {$width}; height: {$height}"></div>