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