forked from TYPO3-svn-archive/rggooglemap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
templateJS.js
233 lines (173 loc) · 6.08 KB
/
templateJS.js
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
<!-- ###ALL### -->
/*<![CDATA[*/
var gicons=[];
###GICONS###
function makeMap() {
if (GBrowserIsCompatible()) {
###SELECTED_CAT###
//map = new GMap2(document.getElementById("###MAP_DIV###"));
map = new GMap2(document.getElementById("map") ###MAP_TYPES###);
gdir=new GDirections(map, document.getElementById('getdirections'));
gdir2=new GDirections(map, document.getElementById('getdirections2'));
geocoder = new GClientGeocoder();
new GKeyboardHandler(map);
boundsgeneral = new GLatLngBounds();
if (###MAP_CLUSTER###==1) {
clusterer = new Clusterer(map);
}
map.setCenter(new GLatLng(###MAP_LAT###, ###MAP_LNG###), ###MAP_ZOOM###);
userLocation("###USE_USER_LOCATION###", ###USE_USER_LOCATION_ZOOMLEVEL###);
###SETTINGS###
if (###MAP_TYPE_MAPNIK### == 1) { loadMap_mapnik("###MAP_TYPE_MAPNIK_TITLE###"); }
if (###MAP_TYPE_TAH### == 1) { loadMap_tah("###MAP_TYPE_TAH_TITLE###"); }
//###__MAKEMAP###
getXMLData(1);
cat = document.getElementById("mapcatlist").innerHTML;
GEvent.addListener(map, 'moveend', function() {
myXmlVar="###URL###&tx_rggooglemap_pi1[cat]="+cat+"&tx_rggooglemap_pi1[area]=" + getBound() + "&tx_rggooglemap_pi1[zoom]="+map.getZoom()+"&r=" + Math.random();
if(!stopReload) {
getXMLData(123);
}
stopReload=false;
});
###HIDECONTROLSMOUSEOUT###
###POI_ON_START###
}
}
function getXMLData(clearOverlay) {
if (clearOverlay != 123) {
show('rggooglemapload');
}
// getCategories
cat = document.getElementById("mapcatlist").innerHTML;
myXmlVar="###URL###&tx_rggooglemap_pi1[cat]="+cat+"&tx_rggooglemap_pi1[area]=" + getBound() + "&tx_rggooglemap_pi1[zoom]="+map.getZoom()+"&r=" + Math.random();
###DEBUG###GLog.writeUrl(myXmlVar);
// clear clusters
for (var i = 0; i < rggmclustermarkers.length; i++) {
map.removeOverlay(rggmclustermarkers[i]);
}
//rggmclustermarkers = [];
var markersList = [];
var request = GXmlHttp.create();
request.open("GET", myXmlVar, true);
request.onreadystatechange = function() {
if (request.readyState == 4) {
// obtain the array of markers and loop through it
var xmlDoc = request.responseXML;
var markers = xmlDoc.documentElement.getElementsByTagName("marker");
if (clearOverlay == 12) {
map.clearOverlays();gmarkers.length = 0;
setTimeout('getXMLData(11)', 100000);
}
if (d("rggooglemap-recordsonmap")){tx_rggooglemap_pi1activeRecords(getBound(),cat); }
var count=0;
var length = gmarkers.length;
if (###MAP_CLUSTER###==2) {
gmarkers = [];
map.clearOverlays();
}
var rggmclustermarkerscount = 0;
###DEBUG###GLog.write('POIs from request : ' + markers.length);
for (var i = 0; i < markers.length; i++) {
// obtain the attribues of each marker
var lat = parseFloat(markers[i].getAttribute("lat"));
var lng = parseFloat(markers[i].getAttribute("lng"));
var point = new GLatLng(lat,lng);
var title = [GXml.value(markers[i].getElementsByTagName("t")[0]) ];
var id = parseFloat(markers[i].getAttribute("uid"));
var table = markers[i].getAttribute("table");
var img = markers[i].getAttribute("img");
var id2 = parseFloat(markers[i].getAttribute("uid2"));
boundsgeneral.extend(point);
marker = createMarker(point, id, img, title, table);
markersList[i] = marker;
if (###MAP_CLUSTER###!=2) {
if (table == 'rggmcluster') {
rggmclustermarkers[rggmclustermarkerscount] = marker;
rggmclustermarkerscount++;
###ADD_MARKER###
} else {
if (gmarkers[id2]!=1) {
//GLog.write('mid: '+title+' '+count,'black');
//clusterer.AddMarker(marker,title);
count++
gmarkers[id2] = 1;
###ADD_MARKER###
}
}
}
}
###DEBUG###GLog.write('POIs added : '+count);
if (###MAP_CLUSTER###==2) {
var markerCluster = new MarkerClusterer(map, markersList, {maxZoom:12});
}
###DEBUG###GLog.write('Processing of additional datasets');
###PROCESS_DATASETS###
hide('rggooglemapload');
// general bound for the 1st call only
if (firstCall==0 && ###BOUNDS###==1) {
var zoom=map.getBoundsZoomLevel(boundsgeneral);
var centerLat = (boundsgeneral.getNorthEast().lat() + boundsgeneral.getSouthWest().lat()) /2;
var centerLng = (boundsgeneral.getNorthEast().lng() + boundsgeneral.getSouthWest().lng()) /2;
map.setCenter(new GLatLng(centerLat,centerLng),zoom);
firstCall = 1;
}
}
}
request.send(null);
}
function createMarker(point, id, img, title,table, searchIons) {
if (searchIons==1) {
icon = searchIcon;
icon.image = "###URL_ICONS###"+img;
//alert(icon.image);
} else {
var icon = gicons[img];
}
//
// var marker = new GxMarker( point, icon, ""+ title, { "offset": new GSize(10, -20), "isStatic": false } );
//
if (table == 'rggmcluster') {
var marker = new GMarker (point, icon);
} else {
var marker = new GxMarker( point, icon, ""+title );
}
// var marker = new GxMarker( point, "http://www.rggooglemap.com/uploads/tx_rggooglemap/VirtError_02.gif", ""+title );
var url = "###URL###&no_cache=1&tx_rggooglemap_pi1[detail]="+id+"&tx_rggooglemap_pi1[table]="+table;
GEvent.addListener(marker, "click", function() {
if (table == 'rggmcluster') {
map.zoomIn();
} else {
var req = GXmlHttp.create();
req.open("GET", url, true );
req.onreadystatechange = function() {
if ( req.readyState == 4 ) {
marker.openInfoWindowHtml( req.responseText );
}
};
req.send(null);
}
});
return marker;
}
// open the info bubble
function myclick(i, lng, lat, table,showMarker) {
var req = GXmlHttp.create();
var url = "###URL###&type=500&no_cache=1&tx_rggooglemap_pi1[detail]="+i+"&tx_rggooglemap_pi1[table]="+table;
req.open("GET", url, true);
var t=this;
req.onreadystatechange = function() {
if (req.readyState == 4) {
t.map.openInfoWindowHtml( new GLatLng(lat, lng), req.responseText );
}
};
req.send(null);
};
function clearCat() {
map.clearOverlays();
gmarkers.length = 0;
setTimeout("getXMLData(12);",2000);
show('rggooglemapload');
}
/*]]>*/
<!-- ###ALL### -->