1 | |
---|
2 | var viewportInitialized = { |
---|
3 | icon:false, |
---|
4 | meta:false |
---|
5 | }; |
---|
6 | |
---|
7 | function applyMap(properties) |
---|
8 | { |
---|
9 | var latlng=new google.maps.LatLng(gmaps.coords.latitude, gmaps.coords.longitude); |
---|
10 | |
---|
11 | var map = new google.maps.Map($("#"+properties.id).get(0), |
---|
12 | { |
---|
13 | mapTypeId: properties.mapType, |
---|
14 | zoom: properties.zoomLevel, |
---|
15 | center:latlng, |
---|
16 | navigationControl: (properties.navigationControl==-1)?false:true, |
---|
17 | scrollwheel: (properties.navigationControl==-1)?false:true, |
---|
18 | scaleControl: (properties.scaleControl=='n')?false:true, |
---|
19 | mapTypeControl:(properties.mapTypeControl==-1)?false:true, |
---|
20 | mapTypeControlOptions: |
---|
21 | { |
---|
22 | style:properties.mapTypeControl |
---|
23 | }, |
---|
24 | markerTitle:'', |
---|
25 | } |
---|
26 | ); |
---|
27 | |
---|
28 | if(properties.marker) |
---|
29 | { |
---|
30 | var marker = new google.maps.Marker( |
---|
31 | { |
---|
32 | position:latlng, |
---|
33 | map: map, |
---|
34 | title:properties.markerTitle |
---|
35 | } |
---|
36 | ); |
---|
37 | } |
---|
38 | |
---|
39 | if(properties.kmlFileUrl!='') |
---|
40 | { |
---|
41 | kmlFile = new google.maps.KmlLayer(properties.kmlFileUrl, |
---|
42 | { |
---|
43 | preserveViewport:true |
---|
44 | } |
---|
45 | ); |
---|
46 | } |
---|
47 | else |
---|
48 | { |
---|
49 | kmlFile=null; |
---|
50 | } |
---|
51 | |
---|
52 | map.kmlFile=kmlFile; |
---|
53 | |
---|
54 | |
---|
55 | properties.gMap=map; |
---|
56 | properties.gMapCenter=latlng; |
---|
57 | } |
---|
58 | |
---|
59 | $(window).load(function () |
---|
60 | { |
---|
61 | gmaps.currentMapLoadIndex=-1; |
---|
62 | |
---|
63 | for(i=0;i<gmaps.maps.length;i++) |
---|
64 | { |
---|
65 | applyMap(gmaps.maps[i]); |
---|
66 | gmaps.maps[i].gMap.setCenter(gmaps.maps[i].gMapCenter); |
---|
67 | $('#'+gmaps.maps[i].id+' span, #'+gmaps.maps[i].id+' a').css('font-size', '55.0%'); |
---|
68 | |
---|
69 | if(gmaps.maps[i].gMap.kmlFile!=null) |
---|
70 | gmaps.maps[i].gMap.kmlFile.setMap(gmaps.maps[i].gMap); |
---|
71 | |
---|
72 | if(gmaps.maps[i].displayType=='IP') |
---|
73 | { |
---|
74 | gmaps.currentMapLoadIndex=i; |
---|
75 | if(gmaps.maps[i].sizeMode=='A') |
---|
76 | { |
---|
77 | $('#iGMapsIcon').css( |
---|
78 | { |
---|
79 | width: ($(window).width()*0.8)+'px', |
---|
80 | height:($(window).height()*0.8)+'px' |
---|
81 | } |
---|
82 | ); |
---|
83 | } |
---|
84 | } |
---|
85 | } |
---|
86 | |
---|
87 | /* |
---|
88 | * this trick is needed for the gally template, because the map initialisation |
---|
89 | * don't works if the container is not visible |
---|
90 | * |
---|
91 | * for the classic default template, this code is ignored |
---|
92 | * |
---|
93 | * >>> |
---|
94 | */ |
---|
95 | if($('#iGMapContent').length>0) |
---|
96 | { |
---|
97 | tabId=$('#iGMapContent').get(0).parentNode.parentNode.id; |
---|
98 | tabId='tab'+tabId.toUpperCase().substring(0,1)+tabId.substr(1); |
---|
99 | $("#"+tabId+" a").bind('click', function () |
---|
100 | { |
---|
101 | if(viewportInitialized.meta==false) |
---|
102 | { |
---|
103 | for(i=0;i<gmaps.maps.length;i++) |
---|
104 | { |
---|
105 | if(gmaps.maps[i].displayType=='MP') |
---|
106 | { |
---|
107 | google.maps.event.trigger(gmaps.maps[i].gMap, 'resize'); |
---|
108 | gmaps.maps[i].gMap.setCenter(gmaps.maps[1].gMapCenter); |
---|
109 | $('#'+gmaps.maps[i].id+' span, #'+gmaps.maps[i].id+' a').css('font-size', '55.0%'); |
---|
110 | } |
---|
111 | } |
---|
112 | viewportInitialized.meta=true; |
---|
113 | } |
---|
114 | } |
---|
115 | ); |
---|
116 | } |
---|
117 | /* |
---|
118 | * <<< |
---|
119 | */ |
---|
120 | |
---|
121 | |
---|
122 | /* |
---|
123 | * manage the popup map |
---|
124 | */ |
---|
125 | if($('#iGMapsIconContent').length>0) |
---|
126 | { |
---|
127 | $('#iGMapsIconContent').dialog( |
---|
128 | { |
---|
129 | autoOpen:false, |
---|
130 | width:'auto', |
---|
131 | height:'auto', |
---|
132 | modal: true, |
---|
133 | closeText:'X', |
---|
134 | dialogClass: 'gmapsPopup', |
---|
135 | title: gmaps.maps[gmaps.currentMapLoadIndex].title, |
---|
136 | open: function () |
---|
137 | { |
---|
138 | if(viewportInitialized.icon==false && gmaps.currentMapLoadIndex!=-1) |
---|
139 | { |
---|
140 | google.maps.event.trigger(gmaps.maps[gmaps.currentMapLoadIndex].gMap, 'resize'); |
---|
141 | gmaps.maps[gmaps.currentMapLoadIndex].gMap.setCenter(gmaps.maps[gmaps.currentMapLoadIndex].gMapCenter); |
---|
142 | $('#iGMapsIcon span, #iGMapsIcon a').css('font-size', '55.0%'); |
---|
143 | if(gmaps.maps[gmaps.currentMapLoadIndex].gMap.kmlFile!=null) |
---|
144 | gmaps.maps[gmaps.currentMapLoadIndex].gMap.kmlFile.setMap(gmaps.maps[gmaps.currentMapLoadIndex].gMap); |
---|
145 | viewportInitialized.icon=true; |
---|
146 | } |
---|
147 | |
---|
148 | google.maps.event.addListener( |
---|
149 | gmaps.maps[gmaps.currentMapLoadIndex].gMap, |
---|
150 | 'dragend', |
---|
151 | function() |
---|
152 | { |
---|
153 | $('#gmapsCenterMap').css('display', 'inline'); |
---|
154 | $('#gmapsBoundKml').css('display', 'inline'); |
---|
155 | } |
---|
156 | ); |
---|
157 | |
---|
158 | google.maps.event.addListener( |
---|
159 | gmaps.maps[gmaps.currentMapLoadIndex].gMap, |
---|
160 | 'zoom_changed', |
---|
161 | function() |
---|
162 | { |
---|
163 | $('#gmapsCenterMap').css('display', 'inline'); |
---|
164 | $('#gmapsBoundKml').css('display', 'inline'); |
---|
165 | } |
---|
166 | ); |
---|
167 | } |
---|
168 | } |
---|
169 | ); |
---|
170 | |
---|
171 | $('div.gmapsPopup div.ui-dialog-titlebar') |
---|
172 | .append('<a href="" id="gmapsCenterMap" style="display:none;" onclick="gmaps.maps[gmaps.currentMapLoadIndex].gMap.setCenter(gmaps.maps[gmaps.currentMapLoadIndex].gMapCenter); $(this).css(\'display\', \'none\').blur(); return(false);">'+ |
---|
173 | '<span>•</span></a>'); |
---|
174 | $('#gmapsCenterMap').attr('title', gmaps.lang.centermap); |
---|
175 | |
---|
176 | if(gmaps.maps[gmaps.currentMapLoadIndex].gMap.kmlFile!=null) |
---|
177 | { |
---|
178 | $('div.gmapsPopup div.ui-dialog-titlebar') |
---|
179 | .append('<a href="" id="gmapsBoundKml" onclick="gmaps.maps[gmaps.currentMapLoadIndex].gMap.fitBounds(gmaps.maps[gmaps.currentMapLoadIndex].gMap.kmlFile.getDefaultViewport()); $(this).css(\'display\', \'none\').blur(); return(false);">'+ |
---|
180 | '<span>∼</span></a>'); |
---|
181 | $('#gmapsBoundKml').attr('title', gmaps.lang.boundkml); |
---|
182 | } |
---|
183 | |
---|
184 | |
---|
185 | } |
---|
186 | |
---|
187 | |
---|
188 | } |
---|
189 | ); |
---|
190 | |
---|
191 | |
---|