KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > lamatek > tags > google > GoogleMapTag


1 package com.lamatek.tags.google;
2
3 import java.io.Serializable JavaDoc;
4 import java.util.Enumeration JavaDoc;
5 import java.util.Hashtable JavaDoc;
6 import java.util.Vector JavaDoc;
7
8 import javax.servlet.jsp.JspWriter JavaDoc;
9 import javax.servlet.jsp.tagext.BodyTagSupport JavaDoc;
10
11 import com.lamatek.tags.google.beans.TrafficEventBean;
12 import com.lamatek.tags.google.beans.XMLParser;
13 /**
14  * GoogleMapTag
15  *
16  * This class represents a <googlemaps;map> tag. Developers should not subclass or override this
17  * class or it's methods.
18  *
19  * @author Tom Cole
20  * @version 0.40
21  */

22 public class GoogleMapTag extends BodyTagSupport JavaDoc implements Serializable JavaDoc, GoogleMapEventListener {
23     
24     static final int SMALL_ZOOM_CONTROL = 0;
25     static final int LARGE_ZOOM_CONTROL = 1;
26     Hashtable JavaDoc markers = null;
27     Hashtable JavaDoc points = null;
28     Hashtable JavaDoc polylines = null;
29     Hashtable JavaDoc circles = null;
30     Hashtable JavaDoc polygons = null;
31     Hashtable JavaDoc boxes = null;
32     Hashtable JavaDoc traffic_tags = null;
33     Hashtable JavaDoc overlays = null;
34     Hashtable JavaDoc mapTypes = null;
35     Hashtable JavaDoc wms = null;
36     Vector JavaDoc events = null;
37     Vector JavaDoc labels = null;
38     Vector JavaDoc inserts = null;
39     Hashtable JavaDoc keys = null;
40     boolean showTypeControl = false;
41     boolean showZoomControl = false;
42     boolean showPanControl = true;
43     boolean showScaleControl = false;
44     boolean mouseWheelSupport = false;
45     boolean panEnabled = true;
46     String JavaDoc version = "2";
47     String JavaDoc id = null;
48     int zoomControlSize = SMALL_ZOOM_CONTROL;
49     String JavaDoc width = null;
50     String JavaDoc height = null;
51     String JavaDoc type = "map";
52     int zoom = -1;
53     String JavaDoc scope = "page";
54     double centerLatitude = -181.00d;
55     double centerLongitude = -181.00d;
56     double smallLon = 180.00d;
57     double smallLat = 180.00d;
58     double largeLon = -180.00d;
59     double largeLat = -180.00;
60     String JavaDoc body = "";
61     GoogleMapMessageTag message = null;
62     GoogleMapOverviewTag overviewControl = null;
63     GoogleMapClusterTag clusterer = null;
64     GoogleMapCoordinatesTag coords = null;
65     String JavaDoc xml = null;
66     boolean debug = false;
67     boolean headless = false;
68     int minZoom = 0;
69     int maxZoom = 17;
70     boolean bound = false;
71     String JavaDoc language = "en";
72     boolean showDaylight = false;
73     /**
74      * Overrides doStartTag from BodyTagSupport. Developers should not override this
75      * method.
76      */

77     public int doStartTag() {
78         if (scope.equalsIgnoreCase("site")) {
79             if (pageContext.getSession().getAttribute(id) == null) {
80                 if (xml != null) {
81                     parseXML();
82                 }
83                 return EVAL_BODY_INCLUDE;
84             }
85         }
86         else {
87             if (pageContext.getAttribute(id) == null) {
88                 if (xml != null) {
89                     parseXML();
90                 }
91                 return EVAL_BODY_INCLUDE;
92             }
93         }
94         return SKIP_BODY;
95     }
96     /**
97      * Parses the defined XML file (or generator), if specified, and adds the resulting entities...
98      *
99      */

100     private void parseXML() {
101         XMLParser.parseXML(xml, this);
102     }
103     /**
104      * Overrides doEndTag from BodyTagSupport. Developers should not override this
105      * method.
106      */

107     public int doEndTag() {
108         if (scope.equalsIgnoreCase("site")) {
109             if (pageContext.getSession().getAttribute(id) == null)
110                 pageContext.getSession().setAttribute(id, this);
111         }
112         else {
113             if (pageContext.getAttribute(id) == null)
114                 pageContext.setAttribute(id, this);
115         }
116         return EVAL_PAGE;
117     }
118     /**
119      * This method adds a GoogleMapMarkerTag to the map.
120      *
121      * @param marker An initialized GoogleMapMarkerTag.
122      */

123     public void addMarker(GoogleMapMarkerTag marker) {
124         if (markers == null)
125             markers = new Hashtable JavaDoc();
126         markers.put(marker.getId(), marker);
127     }
128     /**
129      * Removes a previously added GoogleMapMarkerTag from this map.
130      *
131      * @param marker The GoogleMapMarkerTag to remove.
132      */

133     public void removeMarker(GoogleMapMarkerTag marker) {
134         if (markers != null && marker != null) {
135             markers.remove(marker.getId());
136         }
137     }
138     /**
139      * Retrieves a GoogleMapMarkerTag by it's id.
140      *
141      * @param name The id of the GoogleMapMarkerTag to retrieve.
142      * @return The GoogleMapMarkerTag with this id, or null.
143      */

144     public GoogleMapMarkerTag getMarker(String JavaDoc name) {
145         if (markers != null) {
146             return (GoogleMapMarkerTag) markers.get(name);
147         }
148         else {
149             return null;
150         }
151     }
152     /**
153      * Adds a map type to the map storing it by id.
154      *
155      * @param mapType An initialized GoogleMapMapTypeTag
156      */

157     public void addMapType(GoogleMapMapTypeTag mapType) {
158         if (mapTypes == null)
159             mapTypes = new Hashtable JavaDoc();
160         mapTypes.put(mapType.getId(), mapType);
161     }
162     /**
163      * Returns the GoogleMapMapTypeTag with the given id
164      * or null if it cannot be found.
165      *
166      * @return A GoogleMapMapTypeTag with the given id or null.
167      */

168     public GoogleMapMapTypeTag getMapType(String JavaDoc id) {
169         if (mapTypes == null)
170             return null;
171         else
172             return (GoogleMapMapTypeTag) mapTypes.get(id);
173     }
174     /**
175      * Removes the map type with the given id.
176      *
177      * @param id The id of the map type to remove.
178      */

179     public void removeMapType(String JavaDoc id) {
180         if (mapTypes != null)
181             mapTypes.remove(id);
182     }
183     /**
184      * Retrieves a GoogleMapBoxtag by it's id.
185      *
186      * @param name The id of the GoogleMapBoxTag to retrieve.
187      * @return A GoogleMapBoxTag with the given id or null.
188      */

189     public GoogleMapBoxTag getBox(String JavaDoc name) {
190         if (boxes != null)
191             return (GoogleMapBoxTag) boxes.get(name);
192         else
193             return null;
194     }
195     /**
196      * Retrieves a GoogleMapCircletag by it's id.
197      *
198      * @param name The id of the GoogleMapCircleTag to retrieve.
199      * @return A GoogleMapCircleTag with the given id or null.
200      */

201     public GoogleMapCircleTag getCircle(String JavaDoc name) {
202         if (circles != null)
203             return (GoogleMapCircleTag) circles.get(name);
204         else
205             return null;
206     }
207     /**
208      * Retrieves a GoogleMapImageOverlayTag by it's id.
209      *
210      * @param name the id of the GoogleMapImageOvelay to retrieve.
211      * @return A GoogleMapImageOverlayTag with the given id, or null.
212      */

213     public GoogleMapImageOverlayTag getImageOverlay(String JavaDoc name) {
214         if (overlays == null)
215             return null;
216         else
217             return (GoogleMapImageOverlayTag) overlays.get(name);
218     }
219     /**
220      * Retrieves a GoogleMapPolygonTag by it's id.
221      *
222      * @param name The id of the GoogleMapPolygonTag to retrieve.
223      * @return A GoogleMapPolygonTag with the given id or null.
224      */

225     public GoogleMapPolygonTag getPolygon(String JavaDoc name) {
226         if (polygons != null)
227             return (GoogleMapPolygonTag) polygons.get(name);
228         else
229             return null;
230     }
231     /**
232      * Retrieves a GoogleMapPolylineTag by it's id.
233      *
234      * @param name The id of the GoogleMapPolylineTag to retrieve.
235      * @return A GoogleMapPolylineTag with the given id or null.
236      */

237     public GoogleMapPolylineTag getPolyline(String JavaDoc name) {
238         if (polylines != null)
239             return (GoogleMapPolylineTag) polylines.get(name);
240         else
241             return null;
242     }
243     /**
244      * Adds a new GoogleMapPointTag to this map. GoogleMapPointTags are used
245      * as location references for all overlays (markers, circles, boxes,
246      * polygons and polylines) in a map.
247      *
248      * @param point The initialized GoogleMapPointTag to add.
249      */

250     public void addPoint(GoogleMapPointTag point) {
251         if (points == null)
252             points = new Hashtable JavaDoc();
253         points.put(point.getId(), point);
254         if (point.getLatitude() < smallLat)
255             smallLat = point.getLatitude();
256         if (point.getLatitude() > largeLat)
257             largeLat = point.getLatitude();
258         if (point.getLongitude() < smallLon)
259             smallLon = point.getLongitude();
260         if (point.getLongitude() > largeLon)
261             largeLon = point.getLongitude();
262     }
263     /**
264      * Adds a new GoogleMapCircleTag to this map.
265      *
266      * @param circle The initialized GoogleMapCircleTag to add.
267      */

268     public void addCircle(GoogleMapCircleTag circle) {
269         if (circles == null)
270             circles = new Hashtable JavaDoc();
271         circles.put(circle.getId(), circle);
272     }
273     /**
274      * Adds a new image overlay to this map.
275      *
276      * @param image The initialized GoogleMapImageOverlayTag to add.
277      */

278     public void addImageOverlay(GoogleMapImageOverlayTag image) {
279         if (overlays == null)
280             overlays = new Hashtable JavaDoc();
281         overlays.put(image.getId(), image);
282     }
283     /**
284      * Adds a new GoogleMapTrafficTag to this map.
285      *
286      * @param traffic_tag The initialized GoogleMapTrafficTag to add.
287      */

288     public void addTraffic_tag(GoogleMapTrafficTag traffic) {
289         if (traffic_tags == null)
290             traffic_tags = new Hashtable JavaDoc();
291         traffic_tags.put(traffic.getId(), traffic);
292     }
293     /**
294      * Adds a new GoogleMapPolygonTag to this map.
295      *
296      * @param polygon The initialized GoogleMapPolygonTag to add.
297      */

298     public void addPolygon(GoogleMapPolygonTag polygon) {
299         if (polygons == null) {
300             polygons = new Hashtable JavaDoc();
301         }
302         polygons.put(polygon.getId(), polygon);
303     }
304     /**
305      * Adds a new GoogleMapPolylineTag to this map.
306      *
307      * @param polyline The initialized GoogleMapPolylineTag to add.
308      */

309     public void addPolyline(GoogleMapPolylineTag polyline) {
310         if (polylines == null)
311             polylines = new Hashtable JavaDoc();
312         polylines.put(polyline.getId(), polyline);
313     }
314     /**
315      * Adds a new GoogleMapBoxTag to this map.
316      *
317      * @param box The initialized GoogleMapBoxTag to add.
318      */

319     public void addBox(GoogleMapBoxTag box) {
320         if (boxes == null)
321             boxes = new Hashtable JavaDoc();
322         boxes.put(box.getId(), box);
323     }
324     /**
325      * Adds a new GoogleMapEventTag to this map.
326      *
327      * @param event The initialized GoogleMapEventTag to add.
328      */

329     public void addEvent(GoogleMapEventTag event) {
330         if (events == null)
331             events = new Vector JavaDoc();
332         events.add(event);
333     }
334     /**
335      * Adds a new GoogleMapKeyTag to this map.
336      *
337      * @param key The initialized GoogleMapKeyTag to add.
338      */

339     public void addKey(GoogleMapKeyTag key) {
340         if (keys == null)
341             keys = new Hashtable JavaDoc();
342         keys.put(key.domain, key.key);
343     }
344     /**
345      * Sets the singleton GoogleMapPanControlTag used by this map.
346      *
347      * @param control The initialized GoogleMapPanControlTag to add.
348      */

349     public void setPanControl(GoogleMapPanControlTag control) {
350         showPanControl = control.isEnable();
351         panEnabled = control.isEnable();
352     }
353     /**
354      * Sets the singleton GoogleMapWheelControlTag used by this map.
355      *
356      * @param control The initialized GoogleMapWheelControlTag to add.
357      */

358     public void setWheelControl(GoogleMapWheelControlTag control) {
359         mouseWheelSupport = control.isEnable();
360     }
361     /**
362      * Sets the singleton GoogleMapTypeControlTag used by this map.
363      *
364      * @param control The initialized GoogleMapTypeControlTag to add.
365      */

366     public void setTypeControl(GoogleMapTypeControlTag control) {
367         showTypeControl = control.isEnable();
368     }
369     /**
370      * Sets the singleton GoogleMapScaleControlTag used by this map.
371      *
372      * @param control The initialized GoogleMapScaleControlTag to add.
373      */

374     public void setScaleControl(GoogleMapScaleControlTag control) {
375         showScaleControl = control.isEnable();
376     }
377     /**
378      * Sets the singleton GoogleMapZoomControlTag used by this map.
379      *
380      * @param control The initialized GoogleMapZoomControlTag to add.
381      */

382     public void setZoomControl(GoogleMapZoomControlTag control) {
383         if (control.getSize().equalsIgnoreCase("small")) {
384             zoomControlSize = SMALL_ZOOM_CONTROL;
385         }
386         else if (control.getSize().equalsIgnoreCase("large")) {
387             zoomControlSize = LARGE_ZOOM_CONTROL;
388         }
389         showZoomControl = control.isEnable();
390     }
391     /**
392      * Sets the width of this map in pixels.
393      *
394      * @param height The heigt of this map in pixels.
395      */

396     public void setHeight(String JavaDoc height) {
397         this.height = height;
398     }
399     /**
400      * Sets the id for this map. The id is used by the output
401      * tags (script, javascript, div and initialize tags) to locate
402      * this map.
403      *
404      * @param id The id for this map.
405      */

406     public void setId(String JavaDoc id) {
407         this.id = id;
408     }
409     /**
410      * Sets the map type (map | satellite | hybrid) to display.
411      *
412      * @param type The map type to display (map | satellite | hybrid).
413      */

414     public void setType(String JavaDoc type) {
415         this.type = type;
416     }
417     /**
418      * Sets the Google Maps API version to use. If set to a whole number (1 or 2)
419      * the currently available stable version is used. If set to a specific
420      * version (like 2.39) then that version will be attempted to load.
421      *
422      * @param version The API version to load.
423      */

424     public void setVersion(String JavaDoc version) {
425         this.version = version;
426     }
427     /**
428      * Sets the width of this map in pixels.
429      *
430      * @param width The width of the map in pixels.
431      */

432     public void setWidth(String JavaDoc width) {
433         this.width = width;
434     }
435     /**
436      * Sets whether or not to generate the javascript needed to
437      * support mousewheel zoom control. This option currently
438      * only works when using version 1.x APIs. This is set automatically
439      * when the setWheelControl method is called.
440      *
441      * @param mouseWheelSupport Set to true (to enable) or false (to disable) mousewheel zoom support.
442      */

443     public void setMouseWheelSupport(boolean mouseWheelSupport) {
444         this.mouseWheelSupport = mouseWheelSupport;
445     }
446     /**
447      * Sets whether or not to generate the javascript needed to
448      * show the pan control. This is set automcatically when the
449      * setPanControl method is called.
450      *
451      * @param showPanControl Set to true (to enable) or false (to disable) pan controls.
452      */

453     public void setShowPanControl(boolean showPanControl) {
454         this.showPanControl = showPanControl;
455     }
456     /**
457      * Sets whether or not to generate the javascript needed to
458      * show the type control. This is set automcatically when the
459      * setTypeControl method is called.
460      *
461      * @param showTypeControl Set to true (to enable) or false (to disable) type controls.
462      */

463     public void setShowTypeControl(boolean showTypeControl) {
464         this.showTypeControl = showTypeControl;
465     }
466     /**
467      * Sets whether or not to generate the javascript needed to
468      * show the zoom control. This is set automcatically when the
469      * setZoomControl method is called.
470      *
471      * @param showZoomControl Set to true (to enable) or false (to disable) zoom controls.
472      */

473     public void setShowZoomControl(boolean showZoomControl) {
474         this.showZoomControl = showZoomControl;
475     }
476     /**
477      * Set the zoom level of the map.
478      *
479      * @param zoom The zoom level of the map.
480      */

481     public void setZoom(int zoom) {
482         this.zoom = zoom;
483     }
484     /**
485      * Sets the scope of the map. If set to "site" then the map
486      * is stored in the session. If set to "page" then the map
487      * is stored in the pageContext.
488      *
489      * @param scope The scope where to store the map data.
490      */

491     public void setScope(String JavaDoc scope) {
492         this.scope = scope;
493     }
494     /**
495      * Sets the body content of the map. This can be used by advanced developers
496      * to add javascript controls to the map. Nearly all implementations will
497      * not have a body. This should only be used by advanced javascript developers.
498      *
499      * @param body The body content for this map.
500      */

501     public void setBody(String JavaDoc body) {
502         this.body = body;
503     }
504     /**
505      * Sets the latitude of the map's centerpoint. This is typically calculated
506      * automatically through the points added to the map.
507      *
508      * @param latitude The latitude (in decimal form) to use as the centerpoint for the map.
509      */

510     public void setCenterLatitude(double latitude) {
511         this.centerLatitude = latitude;
512     }
513     /**
514      * Sets the longitude of the map's centerpoint. This is typically calculated
515      * automatically through the points added to the map.
516      *
517      * @param longitude The longitude (in decimal form) to use as the centerpoint for the map.
518      */

519     public void setCenterLongitude(double longitude) {
520         this.centerLongitude = longitude;
521     }
522     /**
523      * Generates the &lt;div> tag that represents the actual map.
524      *
525      * This method is called by GoogleMapDivTag (&lt;googlemaps:div>).
526      *
527      * @param div The GoogleMapDivTag that renders the output.
528      */

529     public void generateDivTag(GoogleMapDivTag div) {
530         try {
531             JspWriter JavaDoc out = pageContext.getOut();
532             String JavaDoc w_unit = "px";
533             String JavaDoc h_unit = "px";
534             if (width != null && (width.indexOf("%") > 0 || width.indexOf("px") > 0))
535                 w_unit = "";
536             if (height != null && (height.indexOf("%") > 0 || height.indexOf("px") > 0))
537                 h_unit = "";
538             out.print("<div id=\"" + id + "\"");
539             if (div.getStyle() != null) {
540                 out.print(" style=\"");
541                 if (width != null) {
542                     out.print("width: " + width + w_unit + ";");
543                 }
544                 if (height != null) {
545                     out.print("height: " + height + h_unit + ";");
546                 }
547                 out.print(div.getStyle() + "\"");
548             }
549             else {
550                 out.print(" style=\"width: " + width + w_unit + "; height: " + height + h_unit + ";\"");
551             }
552             if (div.getCss_class() != null) {
553                 out.print(" class=\"" + div.getCss_class() + "\"");
554             }
555             out.print(">");
556             out.print(body);
557             out.println("</div>");
558             if (message != null) {
559                 out.print("<div id=\"message_div\" ");
560                 if (message.getStyle() != null) {
561                     out.print(" style=\"" + message.getStyle() + "; visibility: hidden;\">");
562                 }
563                 else {
564                     out.print(" style=\"border: 1px dotted #660000; background-color: #ffffff; color: #000000; opacity: .75; filter: alpha(opacity=75); visibility: hidden;\">");
565                 }
566                 out.println("</div>");
567             }
568             if (overlays != null) {
569                 Enumeration JavaDoc names = overlays.keys();
570                 while (names.hasMoreElements()) {
571                     GoogleMapImageOverlayTag image = (GoogleMapImageOverlayTag) overlays.get(names.nextElement());
572                     out.print("<div id=\"" + image.getId() + "\" style=\"opacity: " + image.getOpacity() + "; filter: alhpa(opacity=" + (image.getOpacity() * 100) + "); visibility: hidden;\">");
573                     if (image.getLink() != null) {
574                         out.print("<a HREF=\"" + image.getLink() + "\">");
575                     }
576                     out.print("<img SRC=\"" + image.getUrl() + "\" border=\"0\"/>");
577                     if (image.getLink() != null) {
578                         out.print("</a>");
579                     }
580                     out.println("</div>");
581                 }
582             }
583             if (coords != null) {
584                 out.print("<div id=\"_coords\"");
585                 if (coords.getStyle() != null)
586                     out.print(" style=\"" + coords.getStyle() + "; visibility: hidden;\"");
587                 else
588                     out.print(" style=\"visibility: hidden;\"");
589                 if (coords.getCss_class() != null)
590                     out.print(" class=\"" + coords.getCss_class() + "\"");
591                 out.println("></div>");
592             }
593         }
594         catch(Exception JavaDoc ex) {
595             ex.printStackTrace(System.err);
596         }
597     }
598     /**
599      * Generates the &lt;script> tag that imports the Google Maps API code.
600      * Developers should not override this method.
601      */

602     public void generateScriptTag() {
603         try {
604             JspWriter JavaDoc out = pageContext.getOut();
605             String JavaDoc domain = pageContext.getRequest().getServerName();
606             if (keys != null) {
607                 String JavaDoc key = (String JavaDoc) keys.get(domain);
608                 //added second key check for ids with ports and subdirectories
609
if (key == null) {
610                     Enumeration JavaDoc domains = keys.keys();
611                     while (domains.hasMoreElements()) {
612                         String JavaDoc domainName = (String JavaDoc) domains.nextElement();
613                         if (domainName.indexOf(domain) >= 0)
614                             key = (String JavaDoc) keys.get(domainName);
615                     }
616                 }
617                 //end add.
618
if (key == null) {
619                     System.err.println("ERROR: Unable to locate GoogleMaps API key for domain " + domain);
620                 }
621                 else {
622                     out.println("<script SRC=\"http://maps.google.com/maps?file=api&v=" + version + "&key=" + key + "&hl=" + language + "\" type=\"text/javascript\"></script>");
623                     if (clusterer != null) {
624                         out.println("<script SRC=\"" + clusterer.getPathToScript() + "\" type=\"text/javascript\"></script>");
625                     }
626                     if (wms != null) {
627                         GoogleMapWMSTag tag = (GoogleMapWMSTag) wms.elements().nextElement();
628                         out.println("<script SRC=\"" + tag.getPathToScript() + "\" type=\"text/javascript\"></script>");
629                     }
630                     if (showDaylight) {
631                         out.println("<script SRC=\"http://www.daylightmap.com/daylight.js\" type=\"text/javascript\"></script>");
632                     }
633                 }
634             }
635             else {
636                 System.err.println("ERROR: No GoogleMap API keys were registered.");
637             }
638         }
639         catch(Exception JavaDoc ex) {
640             ex.printStackTrace(System.err);
641         }
642     }
643     /**
644      * Generates the javascript code that initializes the map. Developers
645      * should not override this method.
646      */

647     public void generateInitializationCode() {
648         try {
649             JspWriter JavaDoc out = pageContext.getOut();
650             out.println("<script type=\"text/javascript\">");
651             out.println("//<![CDATA[");
652             out.println("initializeMap" + id + "();");
653             if (mouseWheelSupport) {
654                 if (version.indexOf("1") == 0) {
655                     out.println("hookMouseWheelHandlers(\"" + id + "\")");
656                 }
657                 else if (version.indexOf("2") == 0) {
658                     //future version 2 support...
659
}
660             }
661             out.println("//]]>");
662             out.println("</script>");
663         }
664         catch(Exception JavaDoc ex) {
665             ex.printStackTrace(System.err);
666         }
667     }
668     /**
669      * Generates the complex javascript/AJAX code the map needs to function.
670      * Developers should not override this method.
671      */

672     public void generateJavascript() {
673         try {
674             JspWriter JavaDoc out = pageContext.getOut();
675             //Let's get the IE Polyline thing resolved...
676
out.println("<style type=\"text/css\">");
677             out.println("\tv\\:* {");
678             out.println("\t\tbehavior:url(#default#VML);");
679             out.println("\t}");
680             out.println("</style>");
681             //Gettin' jiggy with it!
682
out.println("<script type=\"text/javascript\">");
683             out.println("//<![CDATA[");
684             out.println("var " + id + ";");
685             out.println("var lastCenterLat;");
686             out.println("var lastCenterLon;");
687             out.println("var lastClick = new Date();");
688             if (inserts != null && version.indexOf("2") == 0) {
689                 for (int i = 0; i < inserts.size(); i++) {
690                     out.println("var " + ((GoogleMapInsertTag) inserts.elementAt(i)).getId() + ";");
691                 }
692             }
693             out.println("if(document.implementation.hasFeature(\"http://www.w3.org/TR/SVG11/feature#SVG\",\"1.1\")) {");
694             out.println("\t_mSvgEnabled = true;");
695             out.println("\t_mSvgForced = true;");
696             out.println("}");
697             out.println("function isDouble() {");
698             out.println("\tvar now = new Date();");
699             out.println("\tvar double_click = ((now.getTime() - lastClick.getTime()) < 500);");
700             out.println("\tlastClick = now;");
701             out.println("\treturn double_click;");
702             out.println("}");
703             if (message != null) {
704                 out.println("function showMessage() {");
705                 if (debug && version.indexOf("2") == 0) {
706                     out.println("\tGLog.write('Displaying message panel.');");
707                 }
708                 out.println("\tvar message_div = document.getElementById(\"message_div\");");
709                 out.println("\tvar google_map = document.getElementById(\"" + id + "\");");
710                 out.println("\tif (message_div != null && google_map != null) {");
711                 out.println("\t\tmessage_div.innerHTML = \"" + message.getMessage() + "\";");
712                 out.println("\t\tgoogle_map.appendChild(message_div);");
713                 out.println("\t\tmessage_div.style.zIndex = parseInt(google_map.style.zIndex + 1);");
714                 out.println("\t\tmessage_div.style.position = 'absolute';");
715                 out.println("\t\tmessage_div.style.top = ((google_map.offsetHeight - message_div.offsetHeight) / 2) + \"px\";");
716                 out.println("\t\tmessage_div.style.left = ((google_map.offsetWidth - message_div.offsetWidth) / 2) + \"px\";");
717                 out.println("\t\tmessage_div.style.visibility = 'visible';");
718                 out.println("\t}");
719                 out.println("}");
720                 out.println("function hideMessage() {");
721                 if (debug && version.indexOf("2") == 0) {
722                     out.println("\tGLog.write('Hiding message panel.');");
723                 }
724                 out.println("\tvar message_div = document.getElementById(\"message_div\");");
725                 out.println("\tif (message_div != null) {");
726                 out.println("\t\tmessage_div.style.zIndex = 0;");
727                 out.println("\t\tmessage_div.style.visibility = 'hidden';");
728                 out.println("\t}");
729                 out.println("}");
730             }
731             if (overlays != null) {
732                 out.println("function showImageOverlay(image_id, x, y) {");
733                 out.println("\tvar image_div = document.getElementById(image_id);");
734                 out.println("\tvar google_map = document.getElementById(\"" + id + "\");");
735                 out.println("\t\tgoogle_map.appendChild(image_div);");
736                 out.println("\timage_div.style.zIndex = 100;");
737                 out.println("\timage_div.style.position = 'absolute';");
738                 out.println("\timage_div.style.top = y + \"px\";");
739                 out.println("\timage_div.style.left = x + \"px\";");
740                 out.println("\timage_div.style.visibility = 'visible';");
741                 out.println("}");
742             }
743             if (coords != null && version.indexOf("2") == 0) {
744                 out.println("function showCoordinates(x, y) {");
745                 out.println("\tvar coords = document.getElementById(\"_coords\");");
746                 out.println("\tvar google_map = document.getElementById(\"" + id + "\");");
747                 out.println("\tgoogle_map.appendChild(coords);");
748                 out.println("\tcoords.style.zIndex = 100;");
749                 out.println("\tcoords.style.position = 'absolute';");
750                 out.println("\tcoords.style.top = y + \"px\";");
751                 out.println("\tcoords.style.left = x + \"px\";");
752                 out.println("\tcoords.style.visibility = 'visible';");
753                 out.println("}");
754                 out.println("function updateCoordinates(lon, lat) {");
755                 out.println("\tvar coords = document.getElementById(\"_coords\");");
756                 out.println("\tcoords.innerHTML = \"Lon: \" + lon + \"&deg;W Lat: \" + lat + \"&deg;N\";");
757                 out.println("}");
758             }
759             if (mapTypes != null) {
760                 if (version.indexOf("1") == 0) {
761                     out.println("function copyObject(original) {");
762                     out.println("\tvar object = new Object();");
763                     out.println("\tfor (var e in original) {");
764                     out.println("\t\tobject[e] = original[e];");
765                     out.println("\t}");
766                     out.println("\treturn object;");
767                     out.println("}");
768                 }
769             }
770             if (labels != null) {
771                 if (version.indexOf("2") == 0) {
772                     out.println("function Label(point, content, opacity, css_class, xOffset, yOffset) {");
773                     out.println("\tthis.point = point;");
774                     out.println("\tthis.content = content || \"\";");
775                     out.println("\tthis.css_class = css_class || \"\";");
776                     out.println("\tthis.opacity = opacity || 0.50;");
777                     out.println("\tthis.xOffset = xOffset || 0;");
778                     out.println("\tthis.yOffset = yOffset || 0;");
779                     out.println("}");
780                     out.println("Label.prototype = new GOverlay();");
781                     out.println("Label.prototype.initialize = function (googleMap) {");
782                     out.println("\tvar div = document.createElement(\"div\");");
783                     out.println("\tdiv.style.position = \"absolute\";");
784                     out.println("\tdiv.innerHTML = '<div class=\"' + this.css_class + '\">' + this.content + '</div>';");
785                     out.println("\tgoogleMap.getPane(G_MAP_FLOAT_SHADOW_PANE).appendChild(div);");
786                     out.println("\tthis.map_ = googleMap;");
787                     out.println("\tthis.div_ = div;");
788                     out.println("\tif(typeof(div.style.filter)=='string'){div.style.filter='alpha(opacity:'+(this.opacity*100)+')';}");
789                     out.println("\tif(typeof(div.style.KHTMLOpacity)=='string'){div.style.KHTMLOpacity=this.opacity;}");
790                     out.println("\tif(typeof(div.style.MozOpacity)=='string'){div.style.MozOpacity=this.opacity;}");
791                     out.println("\tif(typeof(div.style.opacity)=='string'){div.style.opacity=this.opacity;}");
792                     out.println("}");
793                     out.println("Label.prototype.remove = function() {");
794                     out.println("\tthis.div_.parentNode.removeChild(this.div_);");
795                     out.println("}");
796                     out.println("Label.prototype.copy = function() {");
797                     out.println("\treturn new Label(this.point, this.content, this.css_class, this.opacity);");
798                     out.println("}");
799                     out.println("Label.prototype.redraw = function(force) {");
800                     out.println("\tvar p = this.map_.fromLatLngToDivPixel(this.point);");
801                     out.println("\tvar h = parseInt(this.div_.clientHeight);");
802                     out.println("\tthis.div_.style.left = (p.x + this.xOffset) + \"px\";");
803                     out.println("\tthis.div_.style.top = ((p.y + this.yOffset) - h) + \"px\";");
804                     out.println("}");
805                 }
806             }
807             if (inserts != null) {
808                 if (version.indexOf("2") == 0) {
809                     out.println("function Insert(point, image, size, basezoom) {");
810                     out.println("\tthis.point = point;");
811                     out.println("\tthis.image = image;");
812                     out.println("\tthis.size = size;");
813                     out.println("\tthis.basezoom = basezoom;");
814                     out.println("\tvar agent = navigator.userAgent.toLowerCase();");
815                     out.println("}");
816                     out.println("Insert.prototype = new GOverlay();");
817                     out.println("Insert.prototype.initialize = function(map) {");
818                     out.println("\tvar div = document.createElement(\"div\");");
819                     out.println("\tdiv.style.position = \"absolute\";");
820                     out.println("\tmap.getPane(G_MAP_MAP_PANE).appendChild(div);");
821                     out.println("\tthis.map_ = map;");
822                     out.println("\tthis.div_ = div;");
823                     out.println("}");
824                     out.println("Insert.prototype.remove = function() {");
825                     out.println("\tthis.div_.parentNode.removeChild(this.div_);");
826                     out.println("}");
827                     out.println("Insert.prototype.copy = function() {");
828                     out.println("\treturn new Insert(this.point, this.image, this.size, this.basezoom);");
829                     out.println("}");
830                     out.println("Insert.prototype.redraw = function(force) {");
831                     out.println("\tif (force) {");
832                     out.println("\t\tvar p = this.map_.fromLatLngToDivPixel(this.point);");
833                     out.println("\t\tvar z = this.map_.getZoom();");
834                     out.println("\t\tvar scale = 1;");
835                     out.println("\t\tif (z > this.basezoom) {");
836                     out.println("\t\t\tscale = Math.pow(2, (z - this.basezoom));");
837                     out.println("\t\t}");
838                     out.println("\t\telse if (this.basezoom > z) {");
839                     out.println("\t\t\tscale = 1 / Math.pow(2, (this.basezoom - z));");
840                     out.println("\t\t}");
841                     out.println("\t\tvar h=this.size.height * scale;");
842                     out.println("\t\tvar w=this.size.width * scale;");
843                     out.println("\t\tthis.div_.style.left = (p.x - w/2) + \"px\";");
844                     out.println("\t\tthis.div_.style.top = (p.y - h/2) + \"px\";");
845                     out.println("\t\tthis.div_.innerHTML = '<img SRC=\"' +this.image+ '\" width='+w+' height='+h+' >';");
846                     out.println("\t\tthis.div_.style.zIndex = -1;");
847                     out.println("\t}");
848                     out.println("}");
849                     out.println("Insert.prototype.show = function() {");
850                     out.println("\tthis.div_.style.display=\"\";");
851                     out.println("}");
852                     out.println("Insert.prototype.hide = function() {");
853                     out.println("\tthis.div_.style.display=\"none\";");
854                     out.println("}");
855                 }
856             }
857             if (overviewControl != null && overviewControl.wasPlaced() && (version.compareTo("2.41") >= 0 || version.equals("2"))) {
858                 out.println("function positionOverview(x,y) {");
859                 if (debug && version.indexOf("2") == 0) {
860                     out.println("\tGLog.write('Positioning overview control.');");
861                 }
862                 out.println("\tvar overview = document.getElementById(\"" + id + "_overview\");");
863                 out.println("\tvar google_map = document.getElementById(\"" + id + "\");");
864                 out.println("\ttry {");
865                 out.println("\t\toverview.style.left = (x) + \"px\";");
866                 out.println("\t\toverview.style.top = (y) + \"px\";");
867                 out.println("\t\toverview.style.position = 'absolute';");
868                 out.println("\t}");
869                 out.println("\tcatch (e) {");
870                 out.println("\t\talert(e);");
871                 out.println("\t}");
872                 out.println("}");
873             }
874             if (version.indexOf("2") == 0) {
875                 out.println("function setZoomLevels() {");
876                 out.println("\tvar mapTypes = " + id + ".getMapTypes();");
877                 out.println("\tfor (var i = 0; i < mapTypes.length; i++) {");
878                 out.println("\t\tmapTypes[i].getMinimumResolution = function() {");
879                 out.println("\t\t\treturn " + minZoom + ";");
880                 out.println("\t\t}");
881                 out.println("\t\tmapTypes[i].getMaximumResolution = function() {");
882                 out.println("\t\t\treturn " + maxZoom + ";");
883                 out.println("\t\t}");
884                 out.println("\t}");
885                 out.println("}");
886                 if (bound) {
887                     out.println("var allowedBounds;");
888                     out.println("function checkBounds() {");
889                     out.println("\tif (allowedBounds.contains(" + id + ".getCenter())) {");
890                     out.println("\t\treturn;");
891                     out.println("\t}");
892                     out.println("\telse {");
893                     out.println("\t\tvar C = " + id + ".getCenter();");
894                     out.println("\t\tvar X = C.lng();");
895                     out.println("\t\tvar Y = C.lat();");
896                     out.println("\t\tvar AmaxX = allowedBounds.getNorthEast().lng();");
897                     out.println("\t\tvar AmaxY = allowedBounds.getNorthEast().lat();");
898                     out.println("\t\tvar AminX = allowedBounds.getSouthWest().lng();");
899                     out.println("\t\tvar AminY = allowedBounds.getSouthWest().lat();");
900                     out.println("\t\tif (X < AminX) {X = AminX;}");
901                     out.println("\t\tif (X > AmaxX) {X = AmaxX;}");
902                     out.println("\t\tif (Y < AminY) {Y = AminY;}");
903                     out.println("\t\tif (Y > AmaxY) {Y = AmaxY;}");
904                     out.println("\t\t" + id + ".setCenter(new GLatLng(Y,X));");
905                     out.println("\t}");
906                     out.println("}");
907                 }
908             }
909             out.println("function initializeMap" + id + "() {");
910             out.println("\tif (GBrowserIsCompatible()) {");
911             if (debug && version.indexOf("2") == 0) {
912                 out.println("\t\tGLog.write('Initializing GMap with id " + id + ".');");
913             }
914             out.println("\t\t" + id + " = new GMap(document.getElementById(\"" + id + "\"));");
915             if (message != null) {
916                 out.println("\t\tshowMessage();");
917             }
918             if (showDaylight) {
919                 if (debug && version.indexOf("2") == 0) {
920                     out.println("\t\tGLog.write('Initializing daylight map for map " + id + "');");
921                 }
922                 out.println("\t\tvar daylight = new daylightLayer();");
923                 out.println("\t\tdaylight.addToMap(" + id + ");");
924             }
925             if (debug && version.indexOf("2") == 0) {
926                 out.println("\t\tGLog.write('Setting initial map type to " + type + " for map " + id + "');");
927             }
928             if (type.equalsIgnoreCase("hybrid")) {
929                 out.println("\t\t" + id + ".setMapType(G_HYBRID_TYPE);");
930             }
931             else if (type.equalsIgnoreCase("satellite")) {
932                 out.println("\t\t" + id + ".setMapType(G_SATELLITE_TYPE);");
933             }
934             else {
935                 out.println("\t\t" + id + ".setMapType(G_MAP_TYPE);");
936             }
937             if (clusterer != null) {
938                 if (debug && version.indexOf("2") == 0) {
939                     out.println("\t\tGLog.write('Initializing clusterer " + id + "_cluster.');");
940                 }
941                 out.println("\t\tvar " + id + "_cluster = new Clusterer(" + id + ", " + debug + ");");
942                 if (clusterer.getIcon() != null) {
943                     GoogleMapIconTag icon = clusterer.getIcon();
944                     if (debug && version.indexOf("2") == 0) {
945                         out.println("\t\tGLog.write('Creating custom clusterer icons.');");
946                     }
947                     out.println("\t\tvar " + id + "_cluster_icon = new GIcon();");
948                     out.println("\t\t" + id + "_cluster_icon.image = '" + icon.getIcon() + "';");
949                     out.println("\t\t" + id + "_cluster_icon.iconSize = new GSize(" + icon.getIconWidth() + ", " + icon.getIconHeight() + ");");
950                     out.println("\t\t" + id + "_cluster_icon.iconAnchor = new GPoint(" + icon.getAnchorX() + ", " + icon.getAnchorY() + ");");
951                     out.println("\t\t" + id + "_cluster_icon.infoWindowAnchor = new GPoint(" + icon.getInfoWindowAnchorX() + ", " + icon.getInfoWindowAnchorY() + ");");
952                     if (icon.getShadow() != null) {
953                         out.println("\t\t" + id + "_cluster_icon.shadow = '" + icon.getShadow() + "';");
954                         out.println("\t\t" + id + "_cluster_icon.shadowSize = new GSize(" + icon.getShadowWidth() + ", " + icon.getShadowHeight() + ");");
955                     }
956                     out.println("\t\t" + id + "_cluster.SetIcon(" + id + "_cluster_icon);");
957                 }
958                 out.println("\t\t" + id + "_cluster.maxVisibleMarkers = " + clusterer.getMaxVisibleMarkers() + ";");
959                 out.println("\t\t" + id + "_cluster.minMarkersPerCluster = " + clusterer.getMarkersPerCluster() + ";");
960                 out.println("\t\t" + id + "_cluster.gridSize = " + clusterer.getGridSize() + ";");
961             }
962             if (wms != null && version.indexOf("1") == 0) {
963                 Enumeration JavaDoc names = wms.keys();
964                 while (names.hasMoreElements()) {
965                     GoogleMapWMSTag tag = (GoogleMapWMSTag) wms.get(names.nextElement());
966                     if (debug && version.indexOf("2") == 0) {
967                         out.println("\t\tGLog.write('Adding wms map " + tag.getId() + "');");
968                     }
969                     out.println("\t\tvar " + tag.getId() + " = new WMSSpec(" + id + ", '" + tag.getUrl() + "', '" + tag.getName() + "', '" + tag.getName() + "', '" + tag.getLayers() + "', '" + tag.getSrs() + "', '" + tag.getVersion() + "', 'default', '" + tag.getFormat() + "', '" + tag.getCopyright() + "');");
970                     if (tag.isShowOverlay()) {
971                         if (debug && version.indexOf("2") == 0) {
972                             out.println("\t\tGLog.write('Setting overlay for wms map " + tag.getId() + "');");
973                         }
974                         out.println("\t\t" + tag.getId() + ".OverlaySpec = " + id + ".mapTypes[2];");
975                     }
976                     out.println("\t\t" + id + ".mapTypes[" + id + ".mapTypes.length] = " + tag.getId() + ";");
977                     if (tag.isShowOnStartup()) {
978                         if (debug && version.indexOf("2") == 0) {
979                             out.println("\t\tGLog.write('Setting Google Map to initially display wms map " + tag.getId() + "');");
980                         }
981                         out.println("\t\t" + id + ".setMapType(" + id + ".mapTypes[" + id + ".mapTypes.length-1]);");
982                     }
983                 }
984             }
985             else if (wms != null && version.indexOf("2") == 0) {
986                 Enumeration JavaDoc names = wms.keys();
987                 while (names.hasMoreElements()) {
988                     GoogleMapWMSTag tag = (GoogleMapWMSTag) wms.get(names.nextElement());
989                     if (debug && version.indexOf("2") == 0) {
990                         out.println("\t\tGLog.write('Adding wms map " + tag.getId() + "');");
991                     }
992                     out.println("\t\tvar " + tag.getId() + " = new WMSSpec(" + id + ", '" + tag.getUrl() + "', '" + tag.getName() + "', '" + tag.getName() + "', '" + tag.getLayers() + "', '" + tag.getSrs() + "', '" + tag.getVersion() + "', 'default', '" + tag.getFormat() + "', '" + tag.getCopyright() + "');");
993                     /*
994                     if (tag.isShowOverlay()) {
995                         out.println("\t\tvar layer_" + tag.getId() + " = [G_SATELLITE_MAP.getTileLayers()[0], G_HYBRID_MAP.getTileLayers()[1], " + tag.getId() + "];");
996                     }
997                     else {
998                     */

999                         out.println("\t\tvar layer_" + tag.getId() + " = [" + tag.getId() + "];");
1000                    /*
1001                    }
1002                    */

1003                    out.println("\t\tvar map_" + tag.getId() + " = new GMapType(layer_" + tag.getId() + ", G_SATELLITE_MAP.getProjection(), \"" + tag.getName() + "\", G_SATELLITE_MAP);");
1004                    out.println("\t\t" + id + ".addMapType(map_" + tag.getId() + ");");
1005                    if (tag.isShowOnStartup()) {
1006                        if (debug && version.indexOf("2") == 0) {
1007                            out.println("\t\tGLog.write('Setting Google Map to initially display wms map " + tag.getId() + "');");
1008                        }
1009                        out.println("\t\t" + id + ".setMapType(map_" + tag.getId() + ");");
1010                    }
1011                }
1012            }
1013            if (mapTypes != null) {
1014                if (version.indexOf("1") == 0) {
1015                    Enumeration JavaDoc names = mapTypes.keys();
1016                    while (names.hasMoreElements()) {
1017                        GoogleMapMapTypeTag type = (GoogleMapMapTypeTag) mapTypes.get(names.nextElement());
1018                        if (debug && version.indexOf("2") == 0) {
1019                            out.println("\t\tGLog.write('Adding custom map " + type.getId() + "');");
1020                        }
1021                        int parentType = 0;
1022                        if (type.getBaseType().equals("satellite"))
1023                            parentType = 1;
1024                        else if (type.getBaseType().equals("hybrid"))
1025                            parentType = 2;
1026                        if (debug && version.indexOf("2") == 0) {
1027                            out.println("\t\tGLog.write('Copying base map type " + parentType + " into map " + type.getId() + "');");
1028                        }
1029                        out.println("\t\tvar " + type.getId() + " = copyObject(" + id + ".mapTypes[" + parentType + "]);");
1030                        if (type.getUrl() != null) {
1031                            if (debug && version.indexOf("2") == 0) {
1032                                out.println("\t\tGLog.write('Setting base tile url to " + type.getUrl() + " for map " + type.getId() + "');");
1033                            }
1034                            out.println("\t\t" + type.getId() + ".baseUrls = new Array();");
1035                            out.println("\t\t" + type.getId() + ".baseUrls[0]=\"" + type.getUrl() + "?\";");
1036                        }
1037                        if (type.getLowResUrl() != null) {
1038                            if (debug && version.indexOf("2") == 0) {
1039                                out.println("\t\tGLog.write('Setting lowres tile url to " + type.getLowResUrl() + " for map " + type.getId() + "');");
1040                            }
1041                            out.println("\t\t" + type.getId() + ".lowResBaseUrls = new Array();");
1042                            out.println("\t\t" + type.getId() + ".lowResBaseUrls[0]=\"" + type.getLowResUrl() + "?\";");
1043                        }
1044                        if (type.getOverlayUrl() != null) {
1045                            if (debug && version.indexOf("2") == 0) {
1046                                out.println("\t\tGLog.write('Setting overlay tile url to " + type.getOverlayUrl() + " for map " + type.getId() + "');");
1047                            }
1048                            out.println("\t\t" + type.getId() + ".overlayBaseUrls = new Array();");
1049                            out.println("\t\t" + type.getId() + ".overlayBaseUrls[0]=\"" + type.getOverlayUrl() + "?\";");
1050                        }
1051                        if (type.getCopyright() != null) {
1052                            if (debug && version.indexOf("2") == 0) {
1053                                out.println("\t\tGLog.write('Setting copyright for map " + type.getId() + "');");
1054                            }
1055                            out.println("\t\t" + type.getId() + ".getCopyright = function() {");
1056                            out.println("\t\t\treturn '" + type.getCopyright() + "';");
1057                            out.println("\t\t}");
1058                        }
1059                        if (type.getMaxZoom() >= 0) {
1060                            if (debug && version.indexOf("2") == 0) {
1061                                out.println("\t\tGLog.write('Setting max zoom to " + type.getMaxZoom() + " for map " + type.getId() + "');");
1062                            }
1063                            out.println("\t\t" + type.getId() + ".getMaxZoomLevel = function() {");
1064                            out.println("\t\t\treturn " + type.getMaxZoom() + ";");
1065                            out.println("\t\t}");
1066                        }
1067                        if (type.getBaseType() != null) {
1068                            String JavaDoc base = "G_MAP_TYPE";
1069                            if (type.getBaseType().equals("satellite"))
1070                                base = "G_SATELLITE_MAP";
1071                            else if (type.getBaseType().equals("hybrid"))
1072                                base = "G_HYBRID_TYPE";
1073                            if (debug && version.indexOf("2") == 0) {
1074                                out.println("\t\tGLog.write('Setting alternative map type to " + base + " for map " + type.getId() + "');");
1075                            }
1076                            out.println("\t\t" + type.getId() + ".getAlternativeMapType = function() {");
1077                            out.println("\t\t\treturn " + base + ";");
1078                            out.println("\t\t}");
1079                        }
1080                        if (type.getLowerRightBound() != null && type.getUpperLeftBound() != null && points != null) {
1081                            GoogleMapPointTag ul = (GoogleMapPointTag) points.get(type.getUpperLeftBound());
1082                            GoogleMapPointTag lr = (GoogleMapPointTag) points.get(type.getLowerRightBound());
1083                            if (ul != null && lr != null) {
1084                                out.println("\t\t" + type.getId() + ".bounds = new GBounds(" + ul.getLongitude() + "," + ul.getLatitude() + "," + lr.getLongitude() + "," + lr.getLatitude() + ");");
1085                                out.println("\t\t" + type.getId() + ".getBounds = function() {");
1086                                out.println("\t\t\treturn this.bounds;");
1087                                out.println("\t\t}");
1088                            }
1089                        }
1090                        out.println("\t\t" + type.getId() + ".getLinkText = function() {");
1091                        out.println("\t\t\treturn '" + type.getName() + "';");
1092                        out.println("\t\t}");
1093                        out.println("\t\t" + id + ".mapTypes[" + id + ".mapTypes.length] = " + type.getId() + ";");
1094                        if (type.isShowOnStartup()) {
1095                            if (debug && version.indexOf("2") == 0) {
1096                                out.println("\t\tGLog.write('Setting Google Map to initially display custom map " + type.getId() + "');");
1097                            }
1098                            out.println("\t\t" + id + ".setMapType(" + id + ".mapTypes[" + id + ".mapTypes.length-1]);");
1099                        }
1100                    }
1101                }
1102                else if (version.indexOf("2") == 0) {
1103                    Enumeration JavaDoc names = mapTypes.keys();
1104                    while (names.hasMoreElements()) {
1105                        int layerCount = -1;
1106                        GoogleMapMapTypeTag type = (GoogleMapMapTypeTag) mapTypes.get(names.nextElement());
1107                        if (debug && version.indexOf("2") == 0) {
1108                            out.println("\t\tGLog.write('Adding custom map " + type.getId() + "');");
1109                        }
1110                        out.println("\t\tvar " + type.getId() + "_array = new Array();");
1111                        String JavaDoc copy = type.getCopyright();
1112                        int minZoom = type.getMinZoom();
1113                        int maxZoom = type.getMaxZoom();
1114                        if (minZoom < 0)
1115                            minZoom = 0;
1116                        if (maxZoom < 0)
1117                            maxZoom = 0;
1118                        if (copy == null)
1119                            copy = "";
1120                        String JavaDoc base = "G_NORMAL_MAP";
1121                        if (type.getBaseType() != null) {
1122                            if (type.getBaseType().equals("satellite"))
1123                                base = "G_SATELLITE_MAP";
1124                            else if (type.getBaseType().equals("hybrid"))
1125                                base = "G_HYBRID_TYPE";
1126                        }
1127                        if (type.getUrl() != null) {
1128                            layerCount++;
1129                            if (debug && version.indexOf("2") == 0) {
1130                                out.println("\t\tGLog.write('Adding base tile for custom map " + type.getId() + "');");
1131                            }
1132                            out.println("\t\tvar " + type.getId() + "_base = new GTileLayer(new GCopyrightCollection(\"" + copy + "\"), " + minZoom + ", " + maxZoom + ");");
1133                            out.println("\t\t" + type.getId() + "_base.getCopyright = function(a, b) {");
1134                            out.println("\t\t\treturn \"" + copy + "\";");
1135                            out.println("\t\t}");
1136                            out.println("\t\t" + type.getId() + "_base.getTileUrl = function(a, b) {");
1137                            out.println("\t\tvar oldZoom = 17 - b;");
1138                            out.println("\t\t\treturn \"" + type.getUrl() + "?x=\" + a.x + \"&y=\" + a.y + \"&zoom=\" + oldZoom;");
1139                            out.println("\t\t}");
1140                            out.println("\t\t" + type.getId() + "_base.isPng = function(a, b) {");
1141                            out.println("\t\t\treturn " + type.isPng() + ";");
1142                            out.println("\t\t}");
1143                            out.println("\t\t" + type.getId() + "_array[" + layerCount + "] = " + type.getId() + "_base;");
1144                        }
1145                        if (type.getOverlayUrl() != null) {
1146                            layerCount++;
1147                            if (debug && version.indexOf("2") == 0) {
1148                                out.println("\t\tGLog.write('Adding overlay tile for map " + type.getId() + "');");
1149                            }
1150                            out.println("\t\tvar " + type.getId() + "_overlay = new GTileLayer(new GCopyrightCollection(\"" + copy + "\"), " + minZoom + ", " + maxZoom + ");");
1151                            out.println("\t\t" + type.getId() + "_overlay.getCopyright = function(a, b) {");
1152                            out.println("\t\t\treturn \"" + copy + "\";");
1153                            out.println("\t\t}");
1154                            out.println("\t\t" + type.getId() + "_overlay.getTileUrl = function(a, b) {");
1155                            out.println("\t\tvar oldZoom = 17 - b;");
1156                            out.println("\t\t\treturn \"" + type.getOverlayUrl() + "?x=\" + a.x + \"&y=\" + a.y + \"&zoom=\" + oldZoom;");
1157                            out.println("\t\t}");
1158                            out.println("\t\t" + type.getId() + "_overlay.isPng = function(a, b) {");
1159                            out.println("\t\t\treturn " + type.isPng() + ";");
1160                            out.println("\t\t}");
1161                            out.println("\t\t" + type.getId() + "_array[" + layerCount + "] = " + type.getId() + "_overlay;");
1162                        }
1163                        out.println("\t\tvar " + type.getId() + " = new GMapType(" + type.getId() + "_array, " + base + ".getProjection(), \"" + type.getName() + "\", {shortName:\"" + type.getName() + "\",maxResolution:" + maxZoom + ",minResolution:" + minZoom + ",errorMessage:_mMapError});");
1164                        out.println("\t\t" + id + ".addMapType(" + type.getId() + ");");
1165                        if (type.isShowOnStartup()) {
1166                            if (debug && version.indexOf("2") == 0) {
1167                                out.println("\t\tGLog.write('Setting Google Map to initially display custom map " + type.getId() + "');");
1168                            }
1169                            out.println("\t\t" + id + ".setMapType(" + type.getId() + ");");
1170                        }
1171                    }
1172                }
1173            }
1174            if (version.indexOf("2") == 0) {
1175                out.println("\t\tsetZoomLevels();");
1176            }
1177            double lon = 0.00d;
1178            double lat = 0.00d;
1179            if (centerLongitude >= -180.00d && centerLatitude >= -180.00d) {
1180                lon = centerLongitude;
1181                lat = centerLatitude;
1182            }
1183            else { //calculate center point from points..
1184
lon = (largeLon + smallLon) / 2;
1185                lat = (largeLat + smallLat) / 2;
1186                centerLatitude = lat;
1187                centerLongitude = lon;
1188            }//end find centerpoint...
1189
if (bound && version.indexOf("2") == 0) {
1190                if (debug)
1191                    out.println("\t\tGLog.write('Creating bounding box for map.');");
1192                double adjustedSmallLon = smallLon - 0.05;
1193                double adjustedSmallLat = smallLat - 0.05;
1194                double adjustedLargeLon = largeLon + 0.05;
1195                double adjustedLargeLat = largeLat + 0.05;
1196                out.println("\t\tallowedBounds = new GLatLngBounds(new GLatLng(" + adjustedSmallLat + ", " + adjustedSmallLon + "), new GLatLng(" + adjustedLargeLat + ", " + adjustedLargeLon + "));");
1197                out.println("\t\tGEvent.addListener(" + id + ", 'move', function() {");
1198                if (debug && version.indexOf("2") == 0) {
1199                    out.println("\t\tGLog.write('Move event fired by map " + id + ".');");
1200                }
1201                out.println("\t\t\tcheckBounds();");
1202                out.println("\t\t});");
1203            }
1204            if (debug && version.indexOf("2") == 0) {
1205                out.println("\t\tGLog.write('Calculating default center and zoom values.');");
1206            }
1207            if (zoom < 0) {
1208                out.println("\t\t" + id + ".centerAndZoom(new GPoint(" + lon + ", " + lat + "), 8);");
1209            }
1210            else {
1211                out.println("\t\t" + id + ".centerAndZoom(new GPoint(" + lon + ", " + lat + "), " + zoom + ");");
1212            }
1213            //Render map labels if version 2...
1214
if (version.indexOf("2") == 0 && labels != null) {
1215                for (int i = 0; i < labels.size(); i++) {
1216                    GoogleMapLabelTag label = (GoogleMapLabelTag) labels.elementAt(i);
1217                    GoogleMapPointTag point = (GoogleMapPointTag) points.get(label.getPoint());
1218                    if (point != null) {
1219                        if (debug && version.indexOf("2") == 0) {
1220                            out.println("\t\tGLog.write('Adding label to map using point " + point.getId() + "');");
1221                        }
1222                        String JavaDoc constructor = "new GLatLng(" + point.getLatitude() + ", " + point.getLongitude() + "), ";
1223                        constructor += "'";
1224                        if (label.getStyle() != null) {
1225                            constructor += "<div style=\"" + label.getStyle() + "\">";
1226                        }
1227                        constructor += label.getContent();
1228                        if (label.getStyle() != null) {
1229                            constructor += "</div>";
1230                        }
1231                        constructor += "', " + label.getOpacity() + ", ";
1232                        if (label.getCss_class() != null) {
1233                            constructor += "'" + label.getCss_class() + "'";
1234                        }
1235                        else {
1236                            constructor += "null";
1237                        }
1238                        constructor += ", " + label.getX_offset() + ", " + label.getY_offset();
1239                        out.println("\t\tvar label_" + i + " = new Label(" + constructor + ");");
1240                        out.println("\t\t" + id + ".addOverlay(label_" + i + ");");
1241                    }
1242                }
1243            }
1244            //Renders inserts if version 2...
1245
if (version.indexOf("2") == 0 && inserts != null) {
1246                if (debug) {
1247                    out.println("\t\tGLog.write('Adding inserts to map with id " + id + "');");
1248                }
1249                for (int i = 0; i < inserts.size(); i++) {
1250                    GoogleMapInsertTag insert = (GoogleMapInsertTag) inserts.elementAt(i);
1251                    GoogleMapPointTag point = (GoogleMapPointTag) points.get(insert.getPoint());
1252                    if (point != null) {
1253                        if (debug) {
1254                            out.println("\t\tGLog.write('Adding insert " + insert.getId() + " to map using point " + point.getId() + "');");
1255                        }
1256                        out.println("\t\t" + insert.getId() + " = new Insert(new GLatLng(" + point.getLatitude() + ", " + point.getLongitude() + "), \"" + insert.getUrl() + "\", new GSize(" + insert.getWidth() + ", " + insert.getHeight() + "), " + insert.getBaseZoom() + ");");
1257                        out.println("\t\t" + id + ".addOverlay(" + insert.getId() + ");");
1258                        out.print("\t\tif (");
1259                        for (int j = 0; j < insert.getMapTypeCount(); j++) {
1260                            String JavaDoc mapType = insert.getMapType(j);
1261                            if (j > 0) {
1262                                out.print(" || ");
1263                            }
1264                            out.print(id + ".getCurrentMapType().getName() == '" + mapType + "'");
1265                        }
1266                        out.println(") {");
1267                        out.println("\t\t\t" + insert.getId() + ".show();");
1268                        out.println("\t\t}");
1269                        out.println("\t\telse {");
1270                        out.println("\t\t\t" + insert.getId() + ".hide();");
1271                        out.println("\t\t}");
1272                    }
1273                    else {
1274                        if (debug)
1275                            out.println("\t\tGLog.write('Point was null in " + insert.getId() + "');");
1276                    }
1277                }
1278            }
1279            //Render the markers...
1280
if (markers != null && markers.size() > 0) {
1281                Enumeration JavaDoc names = markers.keys();
1282                while (names.hasMoreElements()) {
1283                    GoogleMapMarkerTag marker = (GoogleMapMarkerTag) markers.get(names.nextElement());
1284                    GoogleMapPointTag point = (GoogleMapPointTag) points.get(marker.getPoint());
1285                    if (debug && version.indexOf("2") == 0) {
1286                        out.println("\t\tGLog.write('Adding marker " + marker.getId() + " using point " + point.getId() + "');");
1287                    }
1288                    if (point != null) {
1289                        GoogleMapIconTag icon = marker.getIcon();
1290                        if (icon != null) {
1291                            if (debug && version.indexOf("2") == 0) {
1292                                out.println("\t\tGLog.write('Setting custom icon for marker " + marker.getId() + "');");
1293                            }
1294                            out.println("\t\tvar " + marker.getId() + "_icon = new GIcon();");
1295                            out.println("\t\t" + marker.getId() + "_icon.image = \"" + icon.getIcon() + "\";");
1296                            out.println("\t\t" + marker.getId() + "_icon.iconSize = new GSize(" + icon.getIconWidth() + ", " + icon.getIconHeight() + ");");
1297                            if (icon.getShadow() != null) {
1298                                out.println("\t\t" + marker.getId() + "_icon.shadow = \"" + icon.getShadow() + "\";");
1299                                out.println("\t\t" + marker.getId() + "_icon.shadowSize = new GSize(" + icon.getShadowWidth() + ", " + icon.getShadowHeight() + ");");
1300                            }
1301                            out.println("\t\t" + marker.getId() + "_icon.iconAnchor = new GPoint(" + icon.getAnchorX() + ", " + icon.getAnchorY() + ");");
1302                            out.println("\t\t" + marker.getId() + "_icon.infoWindowAnchor = new GPoint(" + icon.getInfoWindowAnchorX() + ", " + icon.getInfoWindowAnchorY() + ");");
1303                            if (marker.isDraggable() && (version.compareTo("2.46") >= 0 || version.equals("2"))) {
1304                                out.println("\t\tvar " + marker.getId() + " = new GMarker(new GLatLng(" + point.getLatitude() + ", " + point.getLongitude() + "), {icon: " + marker.getId() + "_icon, draggable: true});");
1305                            }
1306                            else {
1307                                out.println("\t\tvar " + marker.getId() + " = new GMarker(new GPoint(" + point.getLongitude() + ", " + point.getLatitude() + "), " + marker.getId() + "_icon);");
1308                            }
1309                        }
1310                        else {
1311                            if (marker.isDraggable() && (version.compareTo("2.46") >= 0 || version.equals("2"))) {
1312                                out.println("\t\tvar " + marker.getId() + " = new GMarker(new GLatLng(" + point.getLatitude() + ", " + point.getLongitude() + "), {draggable: true});");
1313                            }
1314                            else {
1315                                out.println("\t\tvar " + marker.getId() + " = new GMarker(new GPoint(" + point.getLongitude() + ", " + point.getLatitude() + "));");
1316                            }
1317                        }
1318                        if (clusterer == null) {
1319                            if (debug && version.indexOf("2") == 0) {
1320                                out.println("\t\tGLog.write('Adding marker " + marker.getId() + " to map " + id + "');");
1321                            }
1322                            out.println("\t\t" + id + ".addOverlay(" + marker.getId() + ");");
1323                        }
1324                        else {
1325                            if (debug && version.indexOf("2") == 0) {
1326                                out.println("\t\tGLog.write('Adding marker " + marker.getId() + " to clusterer " + id + "_cluster');");
1327                            }
1328                            out.println("\t\t" + id + "_cluster.AddMarker(" + marker.getId() + ", \"Zoom in for details\");");
1329                        }
1330                        if (marker.isDraggable() && (version.compareTo("2.46") >= 0 || version.equals("2"))) {
1331                            out.println("\t\t" + marker.getId() + ".enableDragging();");
1332                        }
1333                        if (marker.getInfoWindow() != null) {
1334                            if (marker.getInfoWindow().isTabbed()) {
1335                                GoogleMapInfoWindowTabbedTag info = (GoogleMapInfoWindowTabbedTag) marker.getInfoWindow();
1336                                if (debug && version.indexOf("2") == 0) {
1337                                    out.println("\t\tGLog.write('Setting tabbed infowindow for marker " + marker.getId() + "');");
1338                                }
1339                                int tabWidth = 88 * info.getTabCount();
1340                                String JavaDoc style = info.getStyle();
1341                                if (style == null)
1342                                    style = "white-space: nowrap; width: " + tabWidth + "px;";
1343                                String JavaDoc css_class = "";
1344                                if (info.getCss_class() != null)
1345                                    css_class = "class=\\\"" + info.getCss_class() + "\\\"";
1346                                out.println("\t\tvar " + marker.getId() + "_tabs = new Array();");
1347                                for (int i = 0; i < info.getTabCount(); i++) {
1348                                    GoogleMapTabTag tab = info.getTab(i);
1349                                    out.println("\t\t" + marker.getId() + "_tabs.push(new GInfoWindowTab(\"" + tab.getLabel() + "\", \"<div " + css_class + " style=\\\"" + style + "\\\">" + tab.getContent() + "</div>\"));");
1350                                }
1351                                out.println("\t\tGEvent.addListener(" + marker.getId() + ", 'click', function() {");
1352                                if (debug && version.indexOf("2") == 0) {
1353                                    out.println("\t\t\tGLog.write('Click event fired by marker " + marker.getId() + ".');");
1354                                }
1355                                out.println("\t\t\t" + marker.getId() + ".openInfoWindowTabsHtml(" + marker.getId() + "_tabs);");
1356                                out.println("\t\t});");
1357                                if (info.isDisplay()) {
1358                                    out.println("\t\t" + marker.getId() + ".openInfoWindowTabsHtml(" + marker.getId() + "_tabs);");
1359                                }
1360                            }
1361                            else {
1362                                if (debug && version.indexOf("2") == 0) {
1363                                    out.println("\t\tGLog.write('Setting info window for marker " + marker.getId() + "');");
1364                                }
1365                                GoogleMapInfoWindowTag info = (GoogleMapInfoWindowTag) marker.getInfoWindow();
1366                                String JavaDoc style = info.getStyle();
1367                                if (style == null)
1368                                    style = "white-space: nowrap;";
1369                                String JavaDoc css_class = "";
1370                                if (info.getCss_class() != null)
1371                                    css_class = "class=\\\"" + info.getCss_class() + "\\\"";
1372                                out.println("\t\tGEvent.addListener(" + marker.getId() + ", 'click', function() {");
1373                                if (debug && version.indexOf("2") == 0) {
1374                                    out.println("\t\t\tGLog.write('Click event fired by marker " + marker.getId() + ".');");
1375                                }
1376                                out.println("\t\t\t" + marker.getId() + ".openInfoWindowHtml(\"<div " + css_class + " style=\\\"" + style + "\\\">" + info.getContent() + "</div>\");");
1377                                out.println("\t\t});");
1378                                if (info.isDisplay()) {
1379                                    out.println("\t\t" + marker.getId() + ".openInfoWindowHtml(\"<div " + css_class + " style=\\\"" + style + "\\\">" + info.getContent() + "</div>\");");
1380                                }
1381                            }
1382                        }
1383                        if (marker.getBlowup() != null) {
1384                            if (debug && version.indexOf("2") == 0) {
1385                                out.println("\t\tGLog.write('Adding blowup map to marker " + marker.getId() + "');");
1386                            }
1387                            out.println("\t\tGEvent.addListener(" + marker.getId() + ", 'click', function() {");
1388                            if (debug && version.indexOf("2") == 0) {
1389                                out.println("\t\t\tGLog.write('Click event fired by marker " + marker.getId() + "');");
1390                            }
1391                            String JavaDoc parameters = "" + marker.getBlowup().getZoom();
1392                            if (marker.getBlowup().getMaptype() != null) {
1393                                if (marker.getBlowup().getMaptype().equalsIgnoreCase("satellite"))
1394                                    parameters += ", G_SATELLITE_TYPE";
1395                                else if (marker.getBlowup().getMaptype().equalsIgnoreCase("hybrid"))
1396                                    parameters += ", G_HYBRID_TYPE";
1397                                else
1398                                    parameters += ", G_MAP_TYPE";
1399                            }
1400                            else {
1401                                if (type.equalsIgnoreCase("hybrid")) {
1402                                    parameters += ", G_HYBRID_TYPE";
1403                                }
1404                                else if (type.equalsIgnoreCase("satellite")) {
1405                                    parameters += ", G_SATELLITE_TYPE";
1406                                }
1407                                else {
1408                                    parameters += ", G_MAP_TYPE";
1409                                }
1410                            }
1411                            out.println("\t\t\t" + marker.getId() + ".showMapBlowup(" + parameters + ");");
1412                            out.println("\t\t});");
1413                            if (marker.getBlowup().isDisplay()) {
1414                                out.println("\t\t" + marker.getId() + ".showMapBlowup(" + parameters + ");");
1415                            }
1416                        }
1417                        if (marker.getEvents() != null) {
1418                            Vector JavaDoc e = marker.getEvents();
1419                            for (int i = 0; i < e.size(); i++) {
1420                                GoogleMapEventTag event = (GoogleMapEventTag) e.elementAt(i);
1421                                String JavaDoc baseURL = event.getUrl();
1422                                if (baseURL.indexOf("?") >= 0)
1423                                    baseURL += "&";
1424                                else
1425                                    baseURL += "?";
1426                                if (debug && version.indexOf("2") == 0) {
1427                                    out.println("\t\tGLog.write('Adding " + event.getAction() + " event to marker " + marker.getId() + "');");
1428                                }
1429                                if (event.getAction().equals("click")) {
1430                                    out.println("\t\tGEvent.addListener(" + marker.getId() + ", '" + event.getAction() + "', function(overlay, point) {");
1431                                    if (debug && version.indexOf("2") == 0) {
1432                                        out.println("\t\t\tGLog.write('Click event fired by marker " + marker.getId() + "');");
1433                                    }
1434                                    if (event.isAsynchronous()) {
1435                                        out.println("\t\t\tvar asr = GXmlHttp.create();");
1436                                        out.println("\t\t\tasr.open(\"GET\", \"" + baseURL + "event=" + event.getAction() + "&map=" + id + "&component=" + marker.getId() + "&type=marker\", true);");
1437                                        out.println("\t\t\tasr.send(null);");
1438                                    }
1439                                    else {
1440                                        if (message != null)
1441                                            out.println("\t\t\tshowMessage();");
1442                                        out.println("\t\t\tdocument.location=\""+ baseURL + "event=" + event.getAction() + "&map=" + id + "&component=" + marker.getId() + "&type=marker\";");
1443                                    }
1444                                    out.println("\t\t});");
1445                                }
1446                                else if (event.getAction().indexOf("drag") >= 0 && (version.compareTo("2.46") >= 0 || version.equals("2"))) {
1447                                    out.println("\t\tGEvent.addListener(" + marker.getId() + ", '" + event.getAction() + "', function(overlay, point) {");
1448                                    if (debug && version.indexOf("2") == 0) {
1449                                        out.println("\t\t\tGLog.write('Drag event fired by marker " + marker.getId() + ".');");
1450                                    }
1451                                    out.println("\t\t\tvar longitude = " + marker.getId() + ".getPoint().x;");
1452                                    out.println("\t\t\tvar latitude = " + marker.getId() + ".getPoint().y;");
1453                                    if (event.isAsynchronous()) {
1454                                        out.println("\t\t\tvar asr = GXmlHttp.create();");
1455                                        out.println("\t\t\tasr.open(\"GET\", \"" + baseURL + "event=" + event.getAction() + "&map=" + id + "&component=" + marker.getId() + "&type=marker&longitude=\" + longitude + \"&latitude=\" + latitude, true);");
1456                                        out.println("\t\t\tasr.send(null);");
1457                                    }
1458                                    else {
1459                                        if (message != null)
1460                                            out.println("\t\t\tshowMessage();");
1461                                        out.println("\t\t\tdocument.location=\""+ baseURL + "event=" + event.getAction() + "&map=" + id + "&component=" + marker.getId() + "&type=marker&longitude=\" + longitude + \"&latitude=\" + latitude;");
1462                                    }
1463                                    out.println("\t\t});");
1464                                }
1465                                else if (event.getAction().equals("dblclick")) {
1466                                    out.println("\t\tGEvent.addListener(" + marker.getId() + ", 'mouseup', function(overlay, point) {");
1467                                    out.println("\t\t\tif (isDouble()) {");
1468                                    if (debug && version.indexOf("2") == 0) {
1469                                        out.println("\t\t\t\tGLog.write('Double click event fired by marker " + marker.getId() + "');");
1470                                    }
1471                                    if (event.isAsynchronous()) {
1472                                        out.println("\t\t\t\tvar asr = GXmlHttp.create();");
1473                                        out.println("\t\t\t\tasr.open(\"GET\", \"" + baseURL + "event=" + event.getAction() + "&map=" + id + "&component=" + marker.getId() + "&type=marker\", true);");
1474                                        out.println("\t\t\t\tasr.send(null);");
1475                                    }
1476                                    else {
1477                                        if (message != null)
1478                                            out.println("\t\t\t\tshowMessage();");
1479                                        out.println("\t\t\t\tdocument.location=\"" + baseURL + "event=" + event.getAction() + "&map=" + id + "&component=" + marker.getId() + "&type=marker\";");
1480                                    }
1481                                    out.println("\t\t\t}");
1482                                    out.println("\t\t});");
1483                                }
1484                            }
1485                        }
1486                    }
1487                }
1488            }
1489            //add Controls...
1490
if (showZoomControl) {
1491                if (debug && version.indexOf("2") == 0) {
1492                    out.println("\t\tGLog.write('Adding zoom controls to map " + id + "');");
1493                }
1494                if (zoomControlSize == LARGE_ZOOM_CONTROL) {
1495                    out.println("\t\t" + id + ".addControl(new GLargeMapControl());");
1496                }
1497                else {
1498                    out.println("\t\t" + id + ".addControl(new GSmallMapControl());");
1499                }
1500            }
1501            if (showPanControl) {
1502                if (debug && version.indexOf("2") == 0) {
1503                    out.println("\t\tGLog.write('Adding pan controls to map " + id + "');");
1504                }
1505                out.println("\t\t" + id + ".enableDragging();");
1506            }
1507            else {
1508                out.println("\t\t" + id + ".disableDragging();");
1509            }
1510            if (showTypeControl) {
1511                if (debug && version.indexOf("2") == 0) {
1512                    out.println("\t\tGLog.write('Adding type controls to map " + id + "');");
1513                }
1514                out.println("\t\t" + id + ".addControl(new GMapTypeControl());");
1515            }
1516            if (showScaleControl) {
1517                if (debug && version.indexOf("2") == 0) {
1518                    out.println("\t\tGLog.write('Adding scale controls to map " + id + "');");
1519                }
1520                out.println("\t\t" + id + ".addControl(new GScaleControl());");
1521            }
1522            if (overviewControl != null && (version.compareTo("2.41") >= 0 || version.equals("2"))) {
1523                if (debug && version.indexOf("2") == 0) {
1524                    out.println("\t\tGLog.write('Adding overview control to map " + id + "');");
1525                }
1526                out.println("\t\t" + id + ".addControl(new GOverviewMapControl(new GSize(" + overviewControl.getWidth() + "," + overviewControl.getHeight() + ")));");
1527                if (overviewControl.wasPlaced()) {
1528                    out.println("\t\tsetTimeout(\"positionOverview(" + overviewControl.getX() + "," + overviewControl.getY() + ")\",1);");
1529                }
1530                else {
1531                    out.println("\t\tvar overview = document.getElementById(\"" + id + "_overview\");");
1532                    out.println("\t\tdocument.getElementById(\"" + id + "\").appendChild(overview);");
1533                }
1534            }
1535            if (headless && (version.compareTo("2.45") >= 0 || version.equals("2"))) {
1536                out.println("\t\t" + id + ".hideControls();");
1537                out.println("\t\tGEvent.addListener(" + id + ", 'mouseover', function() {");
1538                if (debug && version.indexOf("2") == 0) {
1539                    out.println("\t\t\tGLog.write('Mouseover event fired by map " + id + ".');");
1540                }
1541                out.println("\t\t\t" + id + ".showControls();");
1542                out.println("\t\t});");
1543                out.println("\t\tGEvent.addListener(" + id + ", 'mouseout', function() {");
1544                if (debug && version.indexOf("2") == 0) {
1545                    out.println("\t\t\tGLog.write('Mouseout event fired by map " + id + ".');");
1546                }
1547                out.println("\t\t\t" + id + ".hideControls();");
1548                out.println("\t\t});");
1549                
1550            }
1551            //Next add traffic markers...
1552
if (traffic_tags != null && traffic_tags.size() > 0) {
1553                Enumeration JavaDoc names = traffic_tags.keys();
1554                while (names.hasMoreElements()) {
1555                    GoogleMapTrafficTag events = (GoogleMapTrafficTag) traffic_tags.get(names.nextElement());
1556                    GoogleMapPointTag point = (GoogleMapPointTag) points.get(events.getPoint());
1557                    if (debug && version.indexOf("2") == 0) {
1558                        out.println("\t\tGLog.write('Intializing traffic tag " + events.getId() + " using point " + point.getId() + "');");
1559                    }
1560                    if (events.geocode(point.getLongitude(), point.getLatitude())) {
1561                        for (int i = 0; i < events.eventCount(); i++) {
1562                            TrafficEventBean event = events.getEvent(i);
1563                            String JavaDoc event_id = events.getId() + "_" + i;
1564                            if (debug && version.indexOf("2") == 0) {
1565                                out.println("\t\tGLog.write('Adding traffic event " + events.getId() + "_" + i + " to traffic tag " + events.getId() + "');");
1566                            }
1567                            GoogleMapPointTag p = new GoogleMapPointTag();
1568                            p.setId(event_id);
1569                            p.setLatitude(event.getLatitude());
1570                            p.setLongitude(event.getLongitude());
1571                            addPoint(p);
1572                            GoogleMapIconTag icon = events.getIcon();
1573                            if (icon != null) {
1574                                if (debug && version.indexOf("2") == 0) {
1575                                    out.println("\t\tGLog.write('Setting custom icon for traffic event " + events.getId() + "');");
1576                                }
1577                                out.println("\t\tvar " + event_id + "_icon = new GIcon();");
1578                                out.println("\t\t" + event_id + "_icon.image = \"" + icon.getIcon() + "\";");
1579                                out.println("\t\t" + event_id + "_icon.iconSize = new GSize(" + icon.getIconWidth() + ", " + icon.getIconHeight() + ");");
1580                                if (icon.getShadow() != null) {
1581                                    out.println("\t\t" + event_id + "_icon.shadow = \"" + icon.getShadow() + "\";");
1582                                    out.println("\t\t" + event_id + "_icon.shadowSize = new GSize(" + icon.getShadowWidth() + ", " + icon.getShadowHeight() + ");");
1583                                }
1584                                out.println("\t\t" + event_id + "_icon.iconAnchor = new GPoint(" + icon.getAnchorX() + ", " + icon.getAnchorY() + ");");
1585                                out.println("\t\t" + event_id + "_icon.infoWindowAnchor = new GPoint(" + icon.getInfoWindowAnchorX() + ", " + icon.getInfoWindowAnchorY() + ");");
1586                                out.println("\t\tvar " + event_id + " = new GMarker(new GPoint(" + event.getLongitude() + ", " + event.getLatitude() + "), " + event_id + "_icon);");
1587                            }
1588                            else {
1589                                out.println("\t\tvar " + event_id + " = new GMarker(new GPoint(" + event.getLongitude() + ", " + event.getLatitude() + "));");
1590                            }
1591                            if (clusterer == null) {
1592                                if (debug && version.indexOf("2") == 0) {
1593                                    out.println("\t\tGLog.write('Adding traffic event " + events.getId() + "_" + i + " to clusterer " + id + "_cluster');");
1594                                }
1595                                out.println("\t\t" + id + ".addOverlay(" + event_id + ");");
1596                            }
1597                            else {
1598                                if (debug && version.indexOf("2") == 0) {
1599                                    out.println("\t\tGLog.write('Adding traffic event " + events.getId() + "_" + i + " to map " + id + "');");
1600                                }
1601                                out.println("\t\t" + id + "_cluster.AddMarker(" + event_id + ", \"" + event.getTitle() + "\");");
1602                            }
1603                            out.println("\t\tGEvent.addListener(" + event_id + ", 'click', function() {");
1604                            if (debug && version.indexOf("2") == 0) {
1605                                out.println("\t\t\tGLog.write('Click event fired by clustered marker " + event_id + ".');");
1606                            }
1607                            out.println("\t\t\t" + event_id + ".openInfoWindowHtml(\"<div style=\\\"white-space:nowrap;\\\">" + event.getContent() + "</div>\");");
1608                            out.println("\t\t});");
1609                        }
1610                    }
1611                    else {
1612                        System.err.println("Couldn't geocode, or none found.");
1613                        if (debug && version.indexOf("2") == 0) {
1614                            out.println("\t\tGLog.write('Error geocoding traffic event in taffic tag " + events.getId() + "');");
1615                        }
1616                    }
1617                 }
1618             }
1619            //Now do polylines...
1620
if (polylines != null && polylines.size() > 0) {
1621                Enumeration JavaDoc names = polylines.keys();
1622                while (names.hasMoreElements()) {
1623                    GoogleMapPolylineTag line = (GoogleMapPolylineTag) polylines.get(names.nextElement());
1624                    if (debug && version.indexOf("2") == 0) {
1625                        out.println("\t\tGLog.write('Adding polyline " + line.getId() + " to map " + id + "');");
1626                    }
1627                    out.print("\t\tvar " + line.getId() + " = new GPolyline([");
1628                    for (int p = 0; p < line.pointCount(); p++) {
1629                        GoogleMapPointTag point = (GoogleMapPointTag) points.get(line.getPoint(p));
1630                        if (point != null) {
1631                            out.print("new GPoint(" + point.getLongitude() + ", " + point.getLatitude() + ")");
1632                            if (p < line.pointCount() - 1)
1633                                out.print(", ");
1634                        }
1635                    }
1636                    out.println("], \"" + line.getColor() + "\", " + line.getWeight() + ", " + line.getOpacity() + ");");
1637                    out.println("\t\t" + id + ".addOverlay(" + line.getId() + ");");
1638                    if (line.getEvents() != null) {
1639                        Vector JavaDoc e = line.getEvents();
1640                        for (int j = 0; j < e.size(); j++) {
1641                            GoogleMapEventTag event = (GoogleMapEventTag) e.elementAt(j);
1642                            String JavaDoc baseURL = event.getUrl();
1643                            if (baseURL.indexOf("?") >= 0)
1644                                baseURL += "&";
1645                            else
1646                                baseURL += "?";
1647                            if (debug && version.indexOf("2") == 0) {
1648                                out.println("\t\tGLog.write('Adding " + event.getAction() + " event to polyline " + line.getId() + "');");
1649                            }
1650                            if (event.getAction().equals("click")) {
1651                                out.println("\t\tGEvent.addListener(" + line.getId() + ", 'click', function(overlay, point) {");
1652                                if (debug && version.indexOf("2") == 0) {
1653                                    out.println("\t\t\tGLog.write('Click event fired by polyline " + line.getId() + ".');");
1654                                }
1655                                if (event.isAsynchronous()) {
1656                                    out.println("\t\t\tvar asr = GXmlHttp.create();");
1657                                    out.println("\t\t\tasr.open(\"GET\", \"" + baseURL + "event=" + event.getAction() + "&map=" + id + "&component=" + line.getId() + "&type=polyline\", true);");
1658                                    out.println("\t\t\tasr.send(null);");
1659                                }
1660                                else {
1661                                    if (message != null)
1662                                        out.println("\t\t\t\tshowMessage();");
1663                                    out.println("\t\t\tdocument.location=\""+ baseURL + "event=" + event.getAction() + "&map=" + id + "&component=" + line.getId() + "&type=polyline\";");
1664                                }
1665                                out.println("\t\t});");
1666                            }
1667                            else if (event.getAction().equals("dblclick")) {
1668                                out.println("\t\tGEvent.addListener(" + line.getId() + ", 'mouseup', function(overlay, point) {");
1669                                out.println("\t\t\tif (isDouble()) {");
1670                                if (debug && version.indexOf("2") == 0) {
1671                                    out.println("\t\t\t\tGLog.write('Double click event fired by line " + line.getId() + "');");
1672                                }
1673                                if (event.isAsynchronous()) {
1674                                    out.println("\t\t\t\tvar asr = GXmlHttp.create();");
1675                                    out.println("\t\t\t\tasr.open(\"GET\", \"" + baseURL + "event=" + event.getAction() + "&map=" + id + "&component=" + line.getId() + "&type=polyline\", true);");
1676                                    out.println("\t\t\t\tasr.send(null);");
1677                                }
1678                                else {
1679                                    if (message != null)
1680                                        out.println("\t\t\t\tshowMessage();");
1681                                    out.println("\t\t\t\tdocument.location=\""+ baseURL + "event=" + event.getAction() + "&map=" + id + "&component=" + line.getId() + "&type=polyline\";");
1682                                }
1683                                out.println("\t\t\t}");
1684                                out.println("\t\t});");
1685                            }
1686                        }
1687                    }
1688                }
1689            }
1690            //Then circles...
1691
if (circles != null && circles.size() > 0) {
1692                Enumeration JavaDoc names = circles.keys();
1693                while(names.hasMoreElements()) {
1694                    GoogleMapCircleTag circle = (GoogleMapCircleTag) circles.get(names.nextElement());
1695                    GoogleMapPointTag point = (GoogleMapPointTag) points.get(circle.getPoint());
1696                    if (debug && version.indexOf("2") == 0) {
1697                        out.println("\t\tGLog.write('Adding circle " + circle.getId() + " to map " + id + "');");
1698                    }
1699                    if (point != null) {
1700                        out.println("\t\tvar " + circle.getId() + " = drawCircle(" + point.getLongitude() + ", " + point.getLatitude() + ", " + circle.getRadius() + ", \"" + circle.getColor() + "\", " + circle.getWeight() + ", " + circle.getOpacity() + ");");
1701                        out.println("\t\t" + id + ".addOverlay(" + circle.getId() + ");");
1702                        if (circle.getEvents() != null) {
1703                            Vector JavaDoc e = circle.getEvents();
1704                            for (int j = 0; j < e.size(); j++) {
1705                                GoogleMapEventTag event = (GoogleMapEventTag) e.elementAt(j);
1706                                String JavaDoc baseURL = event.getUrl();
1707                                if (baseURL.indexOf("?") >= 0)
1708                                    baseURL += "&";
1709                                else
1710                                    baseURL += "?";
1711                                if (debug && version.indexOf("2") == 0) {
1712                                    out.println("\t\tGLog.write('Adding " + event.getAction() + " event to cricle " + circle.getId() + "');");
1713                                }
1714                                if (event.getAction().equals("click")) {
1715                                    out.println("\t\tGEvent.addListener(" + circle.getId() + ", 'click', function(overlay, point) {");
1716                                    if (debug && version.indexOf("2") == 0) {
1717                                        out.println("\t\t\tGLog.write('Click event fired by circle " + circle.getId() + ".');");
1718                                    }
1719                                    if (event.isAsynchronous()) {
1720                                        out.println("\t\t\tvar asr = GXmlHttp.create();");
1721                                        out.println("\t\t\tasr.open(\"GET\", \"" + baseURL + "event=" + event.getAction() + "&map=" + id + "&component=" + circle.getId() + "&type=circle\", true);");
1722                                        out.println("\t\t\tasr.send(null);");
1723                                    }
1724                                    else {
1725                                        if (message != null)
1726                                            out.println("\t\t\t\tshowMessage();");
1727                                        out.println("\t\t\tdocument.location=\""+ baseURL + "event=" + event.getAction() + "&map=" + id + "&component=" + circle.getId() + "&type=circle\";");
1728                                    }
1729                                    out.println("\t\t});");
1730                                }
1731                                else if (event.getAction().equals("dblclick")) {
1732                                    out.println("\t\tGEvent.addListener(" + circle.getId() + ", 'mouseup', function(overlay, point) {");
1733                                    out.println("\t\t\tif (isDouble()) {");
1734                                    if (debug && version.indexOf("2") == 0) {
1735                                        out.println("\t\t\t\tGLog.write('Double click event fired by circle " + circle.getId() + ".');");
1736                                    }
1737                                    if (event.isAsynchronous()) {
1738                                        out.println("\t\t\t\tvar asr = GXmlHttp.create();");
1739                                        out.println("\t\t\t\tasr.open(\"GET\", \"" + baseURL + "event=" + event.getAction() + "&map=" + id + "&component=" + circle.getId() + "&type=circle\", true);");
1740                                        out.println("\t\t\t\tasr.send(null);");
1741                                    }
1742                                    else {
1743                                        if (message != null)
1744                                            out.println("\t\t\t\tshowMessage();");
1745                                        out.println("\t\t\t\tdocument.location=\""+ baseURL + "event=" + event.getAction() + "&map=" + id + "&component=" + circle.getId() + "&type=circle\";");
1746                                    }
1747                                    out.println("\t\t\t}");
1748                                    out.println("\t\t});");
1749                                }
1750                            }
1751                        }
1752                    }
1753                }
1754            }
1755            //Then polygons...
1756
if (polygons != null && polygons.size() > 0) {
1757                Enumeration JavaDoc names = polygons.keys();
1758                while (names.hasMoreElements()) {
1759                    GoogleMapPolygonTag polygon = (GoogleMapPolygonTag) polygons.get(names.nextElement());
1760                    if (debug && version.indexOf("2") == 0) {
1761                        out.println("\t\tGLog.write('Adding polygon " + polygon.getId() + " to map " + id + "');");
1762                    }
1763                    out.print("\t\tvar " + polygon.getId() + " = new GPolyline([");
1764                    for (int p = 0; p < polygon.pointCount(); p++) {
1765                        GoogleMapPointTag point = (GoogleMapPointTag) points.get(polygon.getPoint(p));
1766                        if (point != null) {
1767                            out.print("new GPoint(" + point.getLongitude() + ", " + point.getLatitude() + "), ");
1768                        }
1769                    }
1770                    GoogleMapPointTag point = (GoogleMapPointTag) points.get(polygon.getPoint(0));
1771                    out.print("new GPoint(" + point.getLongitude() + ", " + point.getLatitude() + ")");
1772                    out.println("], \"" + polygon.getColor() + "\", " + polygon.getWeight() + ", " + polygon.getOpacity() + ");");
1773                    out.println("\t\t" + id + ".addOverlay(" + polygon.getId() + ");");
1774                    if (polygon.getEvents() != null) {
1775                        Vector JavaDoc e = polygon.getEvents();
1776                        for (int j = 0; j < e.size(); j++) {
1777                            GoogleMapEventTag event = (GoogleMapEventTag) e.elementAt(j);
1778                            String JavaDoc baseURL = event.getUrl();
1779                            if (baseURL.indexOf("?") >= 0)
1780                                baseURL += "&";
1781                            else
1782                                baseURL += "?";
1783                            if (debug && version.indexOf("2") == 0) {
1784                                out.println("\t\tGLog.write('Adding " + event.getAction() + " to polygon " + polygon.getId() + "');");
1785                            }
1786                            if (event.getAction().equals("click")) {
1787                                out.println("\t\tGEvent.addListener(" + polygon.getId() + ", 'click', function(overlay, point) {");
1788                                if (debug && version.indexOf("2") == 0) {
1789                                    out.println("\t\t\tGLog.write('Click event fired by polygon " + polygon.getId() + ".');");
1790                                }
1791                                if (event.isAsynchronous()) {
1792                                    out.println("\t\t\tvar asr = GXmlHttp.create();");
1793                                    out.println("\t\t\tasr.open(\"GET\", \"" + baseURL + "event=" + event.getAction() + "&map=" + id + "&component=" + polygon.getId() + "&type=polygon\", true);");
1794                                    out.println("\t\t\tasr.send(null);");
1795                                }
1796                                else {
1797                                    if (message != null)
1798                                        out.println("\t\t\t\tshowMessage();");
1799                                    out.println("\t\t\tdocument.location=\""+ baseURL + "event=" + event.getAction() + "&map=" + id + "&component=" + polygon.getId() + "&type=polygon\";");
1800                                }
1801                                out.println("\t\t});");
1802                            }
1803                            else if (event.getAction().equals("dblclick")) {
1804                                out.println("\t\tGEvent.addListener(" + polygon.getId() + ", 'mouseup', function(overlay, point) {");
1805                                out.println("\t\t\tif (isDouble()) {");
1806                                if (debug && version.indexOf("2") == 0) {
1807                                    out.println("\t\t\t\tGLog.write('Double click event fired by polygon " + polygon.getId() + ".');");
1808                                }
1809                                if (event.isAsynchronous()) {
1810                                    out.println("\t\t\t\tvar asr = GXmlHttp.create();");
1811                                    out.println("\t\t\t\tasr.open(\"GET\", \"" + baseURL + "event=" + event.getAction() + "&map=" + id + "&component=" + polygon.getId() + "&type=polygon\", true);");
1812                                    out.println("\t\t\t\tasr.send(null);");
1813                                }
1814                                else {
1815                                    if (message != null)
1816                                        out.println("\t\t\t\tshowMessage();");
1817                                    out.println("\t\t\t\tdocument.location=\""+ baseURL + "event=" + event.getAction() + "&map=" + id + "&component=" + polygon.getId() + "&type=polygon\";");
1818                                }
1819                                out.println("\t\t\t}");
1820                                out.println("\t\t});");
1821                            }
1822                        }
1823                    }
1824                }
1825            }
1826            //And last boxes...
1827
if (boxes != null && boxes.size() > 0) {
1828                Enumeration JavaDoc names = boxes.keys();
1829                while (names.hasMoreElements()) {
1830                    GoogleMapBoxTag box = (GoogleMapBoxTag) boxes.get(names.nextElement());
1831                    if (debug && version.indexOf("2") == 0) {
1832                        out.println("\t\tGLog.write('Adding box " + box.getId() + " to map " + id + "');");
1833                    }
1834                    if (box.pointCount() > 1) {
1835                        out.print("\t\tvar " + box.getId() + " = new GPolyline([");
1836                        GoogleMapPointTag ul = (GoogleMapPointTag) points.get(box.getPoint(0));
1837                        GoogleMapPointTag lr = (GoogleMapPointTag) points.get(box.getPoint(1));
1838                        out.print("new GPoint(" + ul.getLongitude() + ", " + ul.getLatitude() + "), ");
1839                        out.print("new GPoint(" + lr.getLongitude() + ", " + ul.getLatitude() + "), ");
1840                        out.print("new GPoint(" + lr.getLongitude() + ", " + lr.getLatitude() + "), ");
1841                        out.print("new GPoint(" + ul.getLongitude() + ", " + lr.getLatitude() + "), ");
1842                        out.print("new GPoint(" + ul.getLongitude() + ", " + ul.getLatitude() + ")");
1843                        out.println("], \"" + box.getColor() + "\", " + box.getWeight() + ", " + box.getOpacity() + ");");
1844                        out.println("\t\t" + id + ".addOverlay(" + box.getId() + ");");
1845                        if (box.getEvents() != null) {
1846                            Vector JavaDoc e = box.getEvents();
1847                            for (int j = 0; j < e.size(); j++) {
1848                                GoogleMapEventTag event = (GoogleMapEventTag) e.elementAt(j);
1849                                String JavaDoc baseURL = event.getUrl();
1850                                if (baseURL.indexOf("?") >= 0)
1851                                    baseURL += "&";
1852                                else
1853                                    baseURL += "?";
1854                                if (debug && version.indexOf("2") == 0) {
1855                                    out.println("\t\tGLog.write('Adding " + event.getAction() + " event to box " + box.getId() + "');");
1856                                }
1857                                if (event.getAction().equals("click")) {
1858                                    out.println("\t\tGEvent.addListener(" + box.getId() + ", 'click', function(overlay, point) {");
1859                                    if (debug && version.indexOf("2") == 0) {
1860                                        out.println("\t\t\tGLog.write('Click event fired by box " + box.getId() + ".');");
1861                                    }
1862                                    if (event.isAsynchronous()) {
1863                                        out.println("\t\t\tvar asr = GXmlHttp.create();");
1864                                        out.println("\t\t\tasr.open(\"GET\", \"" + baseURL + "event=" + event.getAction() + "&map=" + id + "&component=" + box.getId() + "&type=box\", true);");
1865                                        out.println("\t\t\tasr.send(null);");
1866                                    }
1867                                    else {
1868                                        if (message != null)
1869                                            out.println("\t\t\t\tshowMessage();");
1870                                        out.println("\t\t\tdocument.location=\""+ baseURL + "event=" + event.getAction() + "&map=" + id + "&component=" + box.getId() + "&type=box\";");
1871                                    }
1872                                    out.println("\t\t});");
1873                                }
1874                                else if (event.getAction().equals("dblclick")) {
1875                                    out.println("\t\tGEvent.addListener(" + box.getId() + ", 'mouseup', function(overlay, point) {");
1876                                    out.println("\t\t\tif (isDouble()) {");
1877                                    if (debug && version.indexOf("2") == 0) {
1878                                        out.println("\t\t\t\tGLog.write('Double click event fired by box " + box.getId() + ".');");
1879                                    }
1880                                    if (event.isAsynchronous()) {
1881                                        out.println("\t\t\t\tvar asr = GXmlHttp.create();");
1882                                        out.println("\t\t\t\tasr.open(\"GET\", \"" + baseURL + "event=" + event.getAction() + "&map=" + id + "&component=" + box.getId() + "&type=box\", true);");
1883                                        out.println("\t\t\t\tasr.send(null);");
1884                                    }
1885                                    else {
1886                                        if (message != null)
1887                                            out.println("\t\t\t\tshowMessage();");
1888                                        out.println("\t\t\t\tdocument.location=\"" + baseURL + "event=" + event.getAction() + "&map=" + id + "&component=" + box.getId() + "&type=box\";");
1889                                    }
1890                                    out.println("\t\t\t}");
1891                                    out.println("\t\t});");
1892                                }
1893                            }
1894                        }
1895                    }
1896                }
1897            }
1898            //center and zoom...
1899
//first recalculate to see if there where any additions...
1900
if (centerLongitude >= -180.00d && centerLatitude >= -180.00d) {
1901                if (debug && version.indexOf("2") == 0) {
1902                    out.println("\t\tGLog.write('Recalculating center for map " + id + "');");
1903                }
1904                lon = centerLongitude;
1905                lat = centerLatitude;
1906            }
1907            else { //calculate center point from points..
1908
lon = (largeLon + smallLon) / 2;
1909                lat = (largeLat + smallLat) / 2;
1910                centerLatitude = lat;
1911                centerLongitude = lon;
1912            }//end find centerpoint...
1913
if (zoom < 0) { //calcuate zoom from points if not defined by the user...
1914
if (debug && version.indexOf("2") == 0) {
1915                    out.println("\t\tGLog.write('Recalculating zoom for map " + id + "');");
1916                }
1917                double adjustment = 0.50d;
1918                if (showZoomControl || showTypeControl)
1919                    adjustment = 1.00d;
1920                if (version.trim().indexOf("1") == 0) { //we're version 1.x...
1921
out.println("\t\tvar zoom = " + id + ".spec.getLowestZoomLevel(new GPoint(" + lon + ", " + lat + "), new GSize(" + ((largeLon - smallLon) + adjustment) + ", " + ((largeLat - smallLat) + adjustment) + "), " + id + ".viewSize);");
1922                    out.println("\t\t" + id + ".centerAndZoom(new GPoint(" + lon + ", " + lat + "), zoom);");
1923                }
1924                else { //we'll assume version 2.x and also hope for forward compatibility...
1925
out.println("\t\tvar bounds = new GLatLngBounds();");
1926                    Enumeration JavaDoc key = points.keys();
1927                    while (key.hasMoreElements()) {
1928                        GoogleMapPointTag point = (GoogleMapPointTag) points.get(key.nextElement());
1929                        out.println("\t\tbounds.extend(new GLatLng(" + point.getLatitude() + ", " + point.getLongitude() + "));");
1930                    }
1931                    out.println("\t\t" + id + ".setZoom(" + id + ".getBoundsZoomLevel(bounds));");
1932                    out.println("\t\tlastCenterLat = " + id + ".getCenterLatLng().y;");
1933                    out.println("\t\tlastCenterLon = " + id + ".getCenterLatLng().x;");
1934                }
1935            }
1936            //Register map events...
1937
if (events != null) {
1938                for (int i = 0; i < events.size(); i++) {
1939                    GoogleMapEventTag event = (GoogleMapEventTag) events.elementAt(i);
1940                    String JavaDoc baseURL = event.getUrl();
1941                    if (baseURL.indexOf("?") >= 0)
1942                        baseURL += "&";
1943                    else
1944                        baseURL += "?";
1945                    if (debug && version.indexOf("2") == 0) {
1946                        out.println("\t\tGLog.write('Adding " + event.getAction() + " event to map " + id + "');");
1947                    }
1948                    if (event.getAction().equals("click")) {
1949                        out.println("\t\tGEvent.addListener(" + id + ", '" + event.getAction() + "', function(overlay, point) {");
1950                        out.println("\t\t\tif (!overlay && point) {");
1951                        if (debug && version.indexOf("2") == 0) {
1952                            out.println("\t\t\t\tGLog.write('" + event.getAction() + " event fired by map " + id + ".');");
1953                        }
1954                        out.println("\t\t\t\tvar longitude = point.x;");
1955                        out.println("\t\t\t\tvar latitude = point.y;");
1956                        if (event.isAsynchronous()) {
1957                            out.println("\t\t\t\tvar asr = GXmlHttp.create();");
1958                            out.println("\t\t\t\tasr.open(\"GET\", \"" + baseURL + "event=" + event.getAction() + "&map=" + id + "&longitude=\" + longitude + \"&latitude=\" + latitude, true);");
1959                            out.println("\t\t\t\tasr.send(null);");
1960                        }
1961                        else {
1962                            if (message != null)
1963                                out.println("\t\t\t\tshowMessage();");
1964                            out.println("\t\t\t\tdocument.location = \"" + baseURL + "event=" + event.getAction() + "&map=" + id + "&longitude=\" + longitude + \"&latitude=\" + latitude;");
1965                        }
1966                        out.println("\t\t\t}");
1967                        out.println("\t\t});");
1968                    }
1969                    else if (event.getAction().equals("dblclick")) {
1970                        out.println("\t\tGEvent.addListener(" + id + ", 'mousedown', function(overlay, point) {");
1971                        out.println("\t\t\tif (isDouble()) {");
1972                        if (debug && version.indexOf("2") == 0) {
1973                            out.println("\t\t\t\tGLog.write('Double click event fired by map " + id + ".');");
1974                        }
1975                        out.println("\t\t\t\tvar longitude = point.x;");
1976                        out.println("\t\t\t\tvar latitude = point.y;");
1977                        if (event.isAsynchronous()) {
1978                            out.println("\t\t\t\tvar asr = GXmlHttp.create();");
1979                            out.println("\t\t\t\tasr.open(\"GET\", \"" + baseURL + "event=" + event.getAction() + "&map=" + id + "&longitude=\" + longitude + \"&latitude=\" + latitude, true);");
1980                            out.println("\t\t\t\tasr.send(null);");
1981                        }
1982                        else {
1983                            if (message != null)
1984                                out.println("\t\t\t\tshowMessage();");
1985                            out.println("\t\t\t\tdocument.location = \"" + baseURL + "event=" + event.getAction() + "&map=" + id + "&longitude=\" + longitude + \"&latitude=\" + latitude;");
1986                        }
1987                        out.println("\t\t\t}");
1988                        out.println("\t\t});");
1989                    }
1990                    else if (event.getAction().equals("moveend")) {
1991                        out.println("\t\tGEvent.addListener(" + id + ", '" + event.getAction() + "', function() {");
1992                        if (debug && version.indexOf("2") == 0) {
1993                            out.println("\t\t\tGLog.write('Moveend event fired by map " + id + ".');");
1994                        }
1995                        out.println("\t\t\tvar longitude = " + id + ".getCenterLatLng().x;");
1996                        out.println("\t\t\tvar latitude = " + id + ".getCenterLatLng().y;");
1997                        out.println("\t\t\tif (latitude != lastCenterLat || longitude != lastCenterLon) {");
1998                        out.println("\t\t\t\tlastCenterLat = latitude;");
1999                        out.println("\t\t\t\tlastCenterLon = longitude;");
2000                        if (event.isAsynchronous()) {
2001                            out.println("\t\t\t\tvar asr = GXmlHttp.create();");
2002                            out.println("\t\t\t\tasr.open(\"GET\", \"" + baseURL + "event=" + event.getAction() + "&map=" + id + "&longitude=\" + longitude + \"&latitude=\" + latitude, true);");
2003                            out.println("\t\t\t\tasr.send(null);");
2004                        }
2005                        else {
2006                            if (message != null)
2007                                out.println("\t\t\t\tshowMessage();");
2008                            out.println("\t\t\t\tdocument.location = \"" + baseURL + "event=" + event.getAction() + "&map=" + id + "&longitude=\" + longitude + \"&latitude=\" + latitude;");
2009                        }
2010                        out.println("\t\t\t}");
2011                        out.println("\t\t});");
2012                    }
2013                    else if (event.getAction().equals("zoom")) {
2014                        out.println("\t\tGEvent.addListener(" + id + ", '" + event.getAction() + "', function(oldzoom, newzoom) {");
2015                        if (debug && version.indexOf("2") == 0) {
2016                            out.println("\t\t\tGLog.write('Zoom event fired by map " + id + ".');");
2017                        }
2018                        if (event.isAsynchronous()) {
2019                            out.println("\t\t\tvar asr = GXmlHttp.create();");
2020                            out.println("\t\t\tasr.open(\"GET\", \"" + baseURL + "event=" + event.getAction() + "&map=" + id + "&zoom=\" + newzoom, true);");
2021                            out.println("\t\t\tasr.send(null);");
2022                        }
2023                        else {
2024                            if (message != null)
2025                                out.println("\t\t\tshowMessage();");
2026                            out.println("\t\t\tdocument.location = \"" + baseURL + "event=" + event.getAction() + "&map=" + id + "&zoom=\" + newzoom;");
2027                        }
2028                        out.println("\t\t});");
2029                    }
2030                    else if (event.getAction().equals("maptypechanged")) {
2031                        out.println("\t\tGEvent.addListener(" + id + ", '" + event.getAction() + "', function() {");
2032                        out.println("\t\t\tvar type = " + id + ".getCurrentMapType();");
2033                        if (debug && version.indexOf("2") == 0) {
2034                            out.println("\t\t\tGLog.write('Maptypechanged event fired by map " + id + ".');");
2035                            out.println("\t\t\tGLog.write('Map type selected is: ' + type.getName());");
2036                        }
2037                        out.println("\t\t\tvar typeText = \"\";");
2038                        out.println("\t\t\tif (type == G_MAP_TYPE) {");
2039                        out.println("\t\t\t\ttypeText = \"map\";");
2040                        out.println("\t\t\t}");
2041                        out.println("\t\t\telse if (type == G_HYBRID_TYPE) {");
2042                        out.println("\t\t\t\ttypeText = \"hybrid\";");
2043                        out.println("\t\t\t}");
2044                        out.println("\t\t\tif (type == G_SATELLITE_TYPE) {");
2045                        out.println("\t\t\t\ttypeText = \"satellite\";");
2046                        out.println("\t\t\t}");
2047                        if (event.isAsynchronous()) {
2048                            out.println("\t\t\tvar asr = GXmlHttp.create();");
2049                            out.println("\t\t\tasr.open(\"GET\", \"" + baseURL + "event=" + event.getAction() + "&map=" + id + "&type=\" + typeText, true);");
2050                            out.println("\t\t\tasr.send(null);");
2051                        }
2052                        else {
2053                            if (message != null)
2054                                out.println("\t\t\tshowMessage();");
2055                            out.println("\t\t\tdocument.location = \"" + baseURL + "event=" + event.getAction() + "&map=" + id + "&type=\" + typeText;");
2056                        }
2057                        out.println("\t\t});");
2058                    }
2059                }
2060            }
2061            if (coords != null && version.indexOf("2") == 0) {
2062                out.println("\t\tshowCoordinates(" + coords.getX() + ", " + coords.getY() + ");");
2063                out.println("\t\tGEvent.addListener(" + id + ", 'mousemove', function(point) {");
2064                out.println("\t\t\tupdateCoordinates(point.lng().toFixed(8), point.lat().toFixed(8));");
2065                out.println("\t\t});");
2066            }
2067            if (version.indexOf("2") == 0 && inserts != null) {
2068                out.println("\t\tGEvent.addListener(" + id + ", 'maptypechanged', function() {");
2069                out.println("\t\t\tvar _map;");
2070                out.println("\t\t\tvar mapType;");
2071                for (int i = 0; i < inserts.size(); i++) {
2072                    GoogleMapInsertTag insert = (GoogleMapInsertTag) inserts.elementAt(i);
2073                    if (insert.getMapTypeCount() > 0) {
2074                        out.println("\t\t\t{");
2075                        out.println("\t\t\t\t_map = " + insert.getId() + ".map_;");
2076                        out.println("\t\t\t\tmapType = _map.getCurrentMapType().getName();");
2077                        out.print("\t\t\t\tif (");
2078                        for (int j = 0; j < insert.getMapTypeCount(); j++) {
2079                            String JavaDoc mapType = insert.getMapType(j);
2080                            if (j > 0) {
2081                                out.print(" || ");
2082                            }
2083                            out.print("mapType == '" + mapType + "'");
2084                        }
2085                        out.println(") {");
2086                        out.println("\t\t\t\t\t" + insert.getId() + ".show();");
2087                        out.println("\t\t\t\t}");
2088                        out.println("\t\t\t\telse {");
2089                        out.println("\t\t\t\t\t" + insert.getId() + ".hide();");
2090                        out.println("\t\t\t\t}");
2091                        out.println("\t\t\t}");
2092                    }
2093                }
2094                out.println("\t\t});");
2095            }
2096            if (message != null) {
2097                out.println("\t\thideMessage();");
2098            }
2099            if (overlays != null) {
2100                Enumeration JavaDoc names = overlays.keys();
2101                while (names.hasMoreElements()) {
2102                    GoogleMapImageOverlayTag image = (GoogleMapImageOverlayTag) overlays.get(names.nextElement());
2103                    if (debug && version.indexOf("2") == 0) {
2104                        out.println("\t\tGLog.write('Adding overlay image " + image.getId() + " to map " + id + "');");
2105                    }
2106                    out.println("\t\tshowImageOverlay(\"" + image.getId() + "\"," + image.getX() + "," + image.getY() + ");");
2107                }
2108            }
2109            //Now wrap it up...
2110
out.println("\t}");
2111            out.println("\tlastCenterLat = " + centerLatitude + ";");
2112            out.println("\tlastCenterLon = " + centerLongitude + ";");
2113            out.println("}");
2114            if (mouseWheelSupport && version.indexOf("1") == 0) {
2115                if (debug && version.indexOf("2") == 0) {
2116                    out.println("\t\tGLog.write('Hooking mousewheel to map " + id + "');");
2117                }
2118                out.println("function exO(a){");
2119                out.println("\treturn Math.round(a)+\"px\"");
2120                out.println("}");
2121                out.println("function clamp(i, min, max) ");
2122                out.println("{");
2123                out.println("\tif (i <= min) ");
2124                out.println("\t\treturn min; ");
2125                out.println("\telse if (i >= max) ");
2126                out.println("\t\treturn max; ");
2127                out.println("\treturn i; ");
2128                out.println("");
2129                out.println("}");
2130                out.println("GMap.prototype.applyZoom = function(a) ");
2131                out.println("{");
2132                out.println("\tvar b = this; ");
2133                out.println("\tvar c = Math.floor(Math.log(b.viewSize.width) * Math.LOG2E - 2); ");
2134                out.println("\tvar d = b.zoomLevel - a; ");
2135                out.println("\tif (d > c) ");
2136                out.println("\t{");
2137                out.println("\t\td = c; ");
2138                out.println("\t}");
2139                out.println("\telse if (d < -c) ");
2140                out.println("\t{");
2141                out.println("\t\td = -c; ");
2142                out.println("\t}");
2143                out.println("\tvar e = Math.pow(2, d); ");
2144                out.println("\tb.div.style.zoom = e; ");
2145                out.println("\tvar f = b.viewSize.width * b.centerScreen.x; ");
2146                out.println("\tvar h = b.viewSize.height * b.centerScreen.y; ");
2147                out.println("\tb.div.style.left = exO((this._savedOffset.x - f) * e + f); ");
2148                out.println("\tb.div.style.top = exO((this._savedOffset.y - h) * e + h); ");
2149                out.println("}");
2150                out.println("function zoom(oEvent, scr) ");
2151                out.println("{");
2152                out.println("\tvar zoom_in = true; ");
2153                out.println("\tif (scr >= 120) ");
2154                out.println("\t\tzoom_in = false; ");
2155                out.println("\t" + id + ".smoothZoomTo(zoom_in); ");
2156                out.println("\tif (oEvent.preventDefault) ");
2157                out.println("\t\toEvent.preventDefault(); ");
2158                out.println("}");
2159                out.println("GMap.prototype.smoothZoomTo = function(zoom_in) ");
2160                out.println("{");
2161                out.println("\tvar a = this; ");
2162                out.println("\tif (!a._zoomInterval) ");
2163                out.println("\t\ta._targetZoom = a.getZoomLevel(); ");
2164                out.println("\ta._targetZoom = clamp(a._targetZoom + (zoom_in ? 1 : -1), 0, 17); ");
2165                out.println("\tif (a.div.style.zoom == undefined) ");
2166                out.println("\t{");
2167                out.println("\t\ta.zoomTo(a._targetZoom); ");
2168                out.println("\t\treturn; ");
2169                out.println("\t}");
2170                out.println("\tif (a._zoomInterval) ");
2171                out.println("\t\treturn; ");
2172                out.println("\ta._currentZoom = parseInt(a.getZoomLevel()); ");
2173                out.println("\ta._savedOffset={\"x\" : a.div.offsetLeft, \"y\" : a.div.offsetTop}; ");
2174                out.println("\ta.hideOverlays(); ");
2175                out.println("\tthis._zoomInterval = setInterval(function() { ");
2176                out.println("\t\ta._currentZoom += 0.3 * (a._targetZoom - a._currentZoom); ");
2177                out.println("\t\tif (Math.abs(a._targetZoom - a._currentZoom) < 0.05) ");
2178                out.println("\t\t{");
2179                out.println("\t\t\tif (a._savedOffset) ");
2180                out.println("\t\t\t{");
2181                out.println("\t\t\t\ta.div.style.left=exO(a._savedOffset.x); ");
2182                out.println("\t\t\t\ta.div.style.top=exO(a._savedOffset.y); ");
2183                out.println("\t\t\t}");
2184                out.println("\t\t\ta.div.style.zoom = 1; ");
2185                out.println("\t\t\ta.showOverlays(); ");
2186                out.println("\t\t\ta.zoomTo(a._targetZoom); ");
2187                out.println("\t\t\ta._savedOffset = null; ");
2188                out.println("\t\t\twindow.clearInterval(a._zoomInterval); ");
2189                out.println("\t\t\ta._zoomInterval = null; ");
2190                out.println("\t\t}");
2191                out.println("\t\telse ");
2192                out.println("\t\t{");
2193                out.println("\t\t\ta.applyZoom(a._currentZoom); ");
2194                out.println("\t\t}");
2195                out.println("\t}, 50); ");
2196                out.println("}");
2197                out.println("function hookMouseWheelHandlers(id) ");
2198                out.println("{");
2199                out.println("\tvar d = document.getElementById(id); ");
2200                out.println("\tif (d)");
2201                out.println("\t{");
2202                out.println("\t\ttry");
2203                out.println(" \t\t{");
2204                out.println("\t\t\tif (document.body.addEventListener) ");
2205                out.println("\t\t\t\td.addEventListener('DOMMouseScroll', function(oEvent) { ");
2206                out.println("\t\t\t\tzoom(oEvent, oEvent.detail * -40); }, false); ");
2207                out.println("\t\t\telse ");
2208                out.println("\t\t\t\td.onmousewheel = function() { ");
2209                out.println("\t\t\t\tzoom(event, event.wheelDelta); ");
2210                out.println("\t\t\t\treturn false; ");
2211                out.println("\t\t\t}");
2212                out.println("\t\t}catch (ex) {} ");
2213                out.println("\t}");
2214                out.println("}");
2215            }
2216            out.println("function drawCircle(lng, lat, radius, color, width, opacity) {");
2217            out.println("\tvar d2r = Math.PI/180;");
2218            out.println("\tvar r2d = 180/Math.PI; ");
2219            out.println("\tvar Clat = (radius/3963)*r2d; ");
2220            out.println("\tvar Clng = Clat/Math.cos(lat*d2r); ");
2221            out.println("\tvar Cpoints = []; ");
2222            out.println("\tfor (var i=0; i < 33; i++) { ");
2223            out.println("\t\tvar theta = Math.PI * (i/16); ");
2224            out.println("\t\tCx = lng + (Clng * Math.cos(theta)); ");
2225            out.println("\t\tCy = lat + (Clat * Math.sin(theta)); ");
2226            out.println("\t\tvar P = new GPoint(Cx,Cy);");
2227            out.println("\t\tCpoints.push(P); ");
2228            out.println("\t}; ");
2229            out.println("\treturn new GPolyline(Cpoints, color, width, opacity);");
2230            out.println("}");
2231            out.println("//]]>");
2232            out.println("</script>");
2233        }
2234        catch(Exception JavaDoc ex) {
2235            ex.printStackTrace(System.err);
2236        }
2237    }
2238    /**
2239     * Returns the list of GoogleMapBoxTags that have been added to this map.
2240     *
2241     *
2242     * @return A Hashtable that contains all the GoogleMapBoxTags in this map keyed by id.
2243     */

2244    public Hashtable JavaDoc getBoxes() {
2245        return boxes;
2246    }
2247    /**
2248     * Sets the GoogleMapBoxTag boxes to be rendered by this map.
2249     *
2250     * @param boxes A Hashtable of GoogleMapBoxTags.
2251     */

2252    public void setBoxes(Hashtable JavaDoc boxes) {
2253        this.boxes = boxes;
2254    }
2255    /**
2256     * Returns the list of GoogleMapCircleTags that have been added to this map.
2257     *
2258     *
2259     * @return A Hashtable that contains all the GoogleMapCircleTags in this map keyed by id.
2260     */

2261    public Hashtable JavaDoc getCircles() {
2262        return circles;
2263    }
2264    /**
2265     * Returns the list of GoogleMapImageOverlayTags that have been added to this map.
2266     *
2267     * @return A Hahtable that contains all the GoogleMapImageOverlayTags in this map, keyed by id.
2268     */

2269    public Hashtable JavaDoc getImageOverlays() {
2270        return overlays;
2271    }
2272    /**
2273     * Sets the GoogleMapCircleTags to be rendered by this map.
2274     *
2275     * @param circles A Hashtable of GoogleMapCircleTags keyed by id.
2276     */

2277    public void setCircles(Hashtable JavaDoc circles) {
2278        this.circles = circles;
2279    }
2280    /**
2281     * Sets the GoogleMapImageOverlayTags to be rendered by this map.
2282     *
2283     * @param images A Hahtable of GoogleMapImageOverlayTags keyed by id.
2284     */

2285    public void setImageOverlays(Hashtable JavaDoc images) {
2286        this.overlays = images;
2287    }
2288    /**
2289     * Returns the list of GoogleMapKeyTags that have been added to this map.
2290     *
2291     *
2292     * @return A Hashtable that contains all the GoogleMapKeysTags in this map keyed by domain name.
2293     */

2294    public Hashtable JavaDoc getKeys() {
2295        return keys;
2296    }
2297    /**
2298     * Sets the list of GoogleMapKeyTags for this map.
2299     *
2300     * @param keys A Hashtable of GoogleMapKeyTags keyed by domain name.
2301     */

2302    public void setKeys(Hashtable JavaDoc keys) {
2303        this.keys = keys;
2304    }
2305    /**
2306     * Returns the largest latitude (in decimal form) of all points stored in this map.
2307     *
2308     * @return The largest latitude of all points.
2309     */

2310    public double getLargeLat() {
2311        return largeLat;
2312    }
2313    /**
2314     * Sets the largest latitude (in decimal form) for this map. This is typically set
2315     * automatically when points are added. Developers should not override this method.
2316     */

2317    public void setLargeLat(double largeLat) {
2318        this.largeLat = largeLat;
2319    }
2320    /**
2321     * Returns the largest longitude (in decimal form) of all points located within
2322     * this map.
2323     *
2324     * @return The largest longitude in this map.
2325     */

2326    public double getLargeLon() {
2327        return largeLon;
2328    }
2329    /**
2330     * Sets the largest longitude (in decimal form) for this map. This is typically set
2331     * automatically when points are added. Developers should not override this method.
2332     */

2333    public void setLargeLon(double largeLon) {
2334        this.largeLon = largeLon;
2335    }
2336    /**
2337     * Returns a list of all GoogleMapMarkerTags added to this map, keyed on their
2338     * ids.
2339     *
2340     * @return A Hashtable of GoogleMapMarkerTags.
2341     */

2342    public Hashtable JavaDoc getMarkers() {
2343        return markers;
2344    }
2345    /**
2346     * Sets the list of the GoogleMapMarkerTags to be rendered by this map.
2347     *
2348     * @param markers A Hashtable of GoogleMapMarkerTags keyed on their ids.
2349     */

2350    public void setMarkers(Hashtable JavaDoc markers) {
2351        this.markers = markers;
2352    }
2353    /**
2354     * Denotes whether or not pan control is enabled. If true then users
2355     * can pan the map, if false, they cannot.
2356     *
2357     * @return True if pan enabled, false if not.
2358     */

2359    public boolean isPanEnabled() {
2360        return panEnabled;
2361    }
2362    /**
2363     * Sets whether or not users should be able to pan the map.
2364     *
2365     * @param panEnabled True or false.
2366     */

2367    public void setPanEnabled(boolean panEnabled) {
2368        this.panEnabled = panEnabled;
2369    }
2370    /**
2371     * Returns a list of all the GoogleMapPointTags added to this map.
2372     *
2373     * @return A Hashtable of GoogleMapPointTags keyed on their ids.
2374     */

2375    public Hashtable JavaDoc getPoints() {
2376        return points;
2377    }
2378    /**
2379     * Sets the list of GoogleMapPointTags to be used by overlays in this
2380     * map.
2381     *
2382     * @param points A Hashtable of GoogleMapPointTags keyed on their ids.
2383     */

2384    public void setPoints(Hashtable JavaDoc points) {
2385        this.points = points;
2386    }
2387    /**
2388     * Returns a list of all the GoogleMapPolygonTags to be rendered by this map.
2389     *
2390     * @return A Hashtable of GoogleMapPolygonTags keyed by id.
2391     */

2392    public Hashtable JavaDoc getPolygons() {
2393        return polygons;
2394    }
2395    /**
2396     * Sets the list of GoogleMapPolygonTags to be rendered by this map.
2397     *
2398     * @param polygons A Hashtable of GoogleMapPolygonTags keyed by id.
2399     */

2400    public void setPolygons(Hashtable JavaDoc polygons) {
2401        this.polygons = polygons;
2402    }
2403    /**
2404     * Returns a list of all the GoogleMapMapTypeTags to be rendered by this map.
2405     *
2406     * @return A Hashtable of GoogleMapMapTypeTags keyed by id.
2407     */

2408    public Hashtable JavaDoc getMapTypes() {
2409        return mapTypes;
2410    }
2411    /**
2412     * Sets the list of GoogleMapMapTypeTags to be rendered by this map.
2413     *
2414     * @param mapTypes A Hashtable of GoogleMapMapTypeTags keyed by id.
2415     */

2416    public void setMapTypes(Hashtable JavaDoc mapTypes) {
2417        this.mapTypes = mapTypes;
2418    }
2419    /**
2420     * Returns a list of all the GoogleMapPolylineTags to be rendered by this map.
2421     *
2422     * @return A Hashtable of GoogleMapPolylineTags keyed by id.
2423     */

2424    public Hashtable JavaDoc getPolylines() {
2425        return polylines;
2426    }
2427    /**
2428     * Sets the list of GoogleMapPolylineTags to be rendered by this map.
2429     *
2430     * @param polylines A Hashtable of GoogleMapPolylineTags keyed by id.
2431     */

2432    public void setPolylines(Hashtable JavaDoc polylines) {
2433        this.polylines = polylines;
2434    }
2435    /**
2436     * Denotes whether or not this map displays a scale.
2437     *
2438     * @return True if the scale is visible, false if not.
2439     */

2440    public boolean isShowScaleControl() {
2441        return showScaleControl;
2442    }
2443    /**
2444     * Sets whether or not this map should display a scale control.
2445     *
2446     * @param showScaleControl True to show scale, false if not.
2447     */

2448    public void setShowScaleControl(boolean showScaleControl) {
2449        this.showScaleControl = showScaleControl;
2450    }
2451    /**
2452     * Returns the smalles latitude (in decimal form) of all points in this map.
2453     *
2454     * @return The small latitude in this map.
2455     */

2456    public double getSmallLat() {
2457        return smallLat;
2458    }
2459    /**
2460     * Sets the smallest latitude (in decimal form) of all points in this map. This
2461     * is set automatically as points are added to the map. Developers should not
2462     * override this method.
2463     *
2464     * @param smallLat The smallest latitude in this map.
2465     */

2466    public void setSmallLat(double smallLat) {
2467        this.smallLat = smallLat;
2468    }
2469    /**
2470     * Returns the smalles longitude (in decimal form) of all points in this map.
2471     *
2472     * @return The small longitude in this map.
2473     */

2474    public double getSmallLon() {
2475        return smallLon;
2476    }
2477    /**
2478     * Sets the smallest longitude (in decimal form) of all points in this map. This
2479     * is set automatically as points are added to the map. Developers should not
2480     * override this method.
2481     *
2482     * @param smallLon The smallest longitude in this map.
2483     */

2484    public void setSmallLon(double smallLon) {
2485        this.smallLon = smallLon;
2486    }
2487    /**
2488     * Returns the zoom control size for this map. Equals either
2489     * SMALL_ZOOM_CONTROL or LARGE_ZOOM_CONTROL.
2490     *
2491     * @return The zoom control size for this map.
2492     */

2493    public int getZoomControlSize() {
2494        return zoomControlSize;
2495    }
2496    /**
2497     * Sets the zoom control size. This should equal either
2498     * SMALL_ZOOM_CONTROL or LARGE_ZOOM_CONTROL. If set to
2499     * SMALL_ZOOM_CONTROL, then only zoom in (+) and zoom out (-)
2500     * buttons are shown. If set to LARGE_ZOOM_CONTROL then a slider
2501     * is presented as well.
2502     *
2503     * @param zoomControlSize The desired zoom control size.
2504     */

2505    public void setZoomControlSize(int zoomControlSize) {
2506        this.zoomControlSize = zoomControlSize;
2507    }
2508    /**
2509     * Returns the map's body contents.
2510     *
2511     * @return The current body contents.
2512     */

2513    public String JavaDoc getBody() {
2514        return body;
2515    }
2516    /**
2517     * Returns the latitude (in decimal form) of the map's current centerpoint.
2518     *
2519     * @return The current centerpoint latitude.
2520     */

2521    public double getCenterLatitude() {
2522        return centerLatitude;
2523    }
2524    /**
2525     * Returns the longitude (in decimal form) of the map's current centerpoint.
2526     *
2527     * @return The current centerpoint longitude.
2528     */

2529    public double getCenterLongitude() {
2530        return centerLongitude;
2531    }
2532    /**
2533     * Returns the height of this map in pixels.
2534     *
2535     * @return The map height in pixels.
2536     */

2537    public String JavaDoc getHeight() {
2538        return height;
2539    }
2540    /**
2541     * Denotes whether or not this map supports mouseWheel zoom control.
2542     *
2543     * @return True if this map supports mousewheel control, false if not.
2544     */

2545    public boolean isMouseWheelSupport() {
2546        return mouseWheelSupport;
2547    }
2548    /**
2549     * Returns the scope of this map ("site" | "page").
2550     *
2551     * @return The map scope.
2552     */

2553    public String JavaDoc getScope() {
2554        return scope;
2555    }
2556    /**
2557     * Denotes whether or not this map shows pan controls.
2558     *
2559     * @return True if pan controls are shown, false if not.
2560     */

2561    public boolean isShowPanControl() {
2562        return showPanControl;
2563    }
2564    /**
2565     * Denotes whether or not this map shows type controls.
2566     *
2567     * @return True if type controls are shown, false if not.
2568     */

2569    public boolean isShowTypeControl() {
2570        return showTypeControl;
2571    }
2572    /**
2573     * Denotes whether ot not this map shows zoom controls.
2574     *
2575     * @return True if zoom controls are shown, false if not.
2576     */

2577    public boolean isShowZoomControl() {
2578        return showZoomControl;
2579    }
2580    /**
2581     * Returns the current map type (map | satellite | hybrid).
2582     *
2583     * @return The current map type.
2584     */

2585    public String JavaDoc getType() {
2586        return type;
2587    }
2588    /**
2589     * Returns the version of the Google Maps API used by this map.
2590     *
2591     * @return Google Maps API version.
2592     */

2593    public String JavaDoc getVersion() {
2594        return version;
2595    }
2596    /**
2597     * Returns the width of this map in pixels.
2598     *
2599     * @return The width of the map in pixels.
2600     */

2601    public String JavaDoc getWidth() {
2602        return width;
2603    }
2604    /**
2605     * Returns the current zoom level of this map.
2606     *
2607     * @return The current zoom level.
2608     */

2609    public int getZoom() {
2610        return zoom;
2611    }
2612    /**
2613     * Returns the list of all GoogleMapEventTags supported by this
2614     * map.
2615     *
2616     * @return A Vector of GoogleMapEventTags.
2617     */

2618    public Vector JavaDoc getEvents() {
2619        return events;
2620    }
2621    /**
2622     * Sets the list of GoogleMapEventTags supported by this map.
2623     *
2624     * @param events A Vector of GoogleMapEventTags.
2625     */

2626    public void setEvents(Vector JavaDoc events) {
2627        this.events = events;
2628    }
2629    /**
2630     * Returns the id of this map.
2631     *
2632     * @return The id of this map.
2633     */

2634    public String JavaDoc getId() {
2635        return id;
2636    }
2637    /**
2638     * Returns the current message tag, or null if not defined.
2639     *
2640     * @return A valid GoogleMapMessageTag
2641     */

2642    public GoogleMapMessageTag getMessage() {
2643        return message;
2644    }
2645    /**
2646     * Sets the message tag to display when loading or when actions are fired.
2647     *
2648     * @param message A valid GoogleMapMessageTag
2649     */

2650    public void setMessage(GoogleMapMessageTag message) {
2651        this.message = message;
2652    }
2653    /**
2654     * Returns the URL to the XML file or generator that is to provide map data for points,
2655     * overlays and events for this map.
2656     *
2657     * @return URL to an XML file or generator.
2658     */

2659    public String JavaDoc getXml() {
2660        return xml;
2661    }
2662    /**
2663     * Sets the URL for the XML file or generator that is to provide map data for points,
2664     * overlays and events for this map.
2665     *
2666     * @param xml A valid URL to an XML file or generator that validates against the public DTD http://www.lamatek.com/GoogleMaps/dtds/googlemaps.dtd
2667     */

2668    public void setXml(String JavaDoc xml) {
2669        this.xml = xml;
2670    }
2671    /**
2672     * Returns the currently defined GoogleMapOverviewTag defined for this map.
2673     *
2674     * @return A GoogleMapOverviewTag or null if none defined.
2675     */

2676    public GoogleMapOverviewTag getOverviewControl() {
2677        return overviewControl;
2678    }
2679    /**
2680     * Sets the GoogleMapOverviewTag to use for this map.
2681     *
2682     * @param overviewControl an initialized GoogleMapOverviewTag
2683     */

2684    public void setOverviewControl(GoogleMapOverviewTag overviewControl) {
2685        this.overviewControl = overviewControl;
2686    }
2687    /**
2688     * Returns the current clusterer tag, or null if not defined.
2689     *
2690     * @return A valid GoogleMapClusterTag
2691     */

2692    public GoogleMapClusterTag getClusterer() {
2693        return clusterer;
2694    }
2695    /**
2696     * Sets the cluster tag to used to cluster markers.
2697     *
2698     * @param clusterer A valid GoogleMapClusterTag
2699     */

2700    public void setClusterer(GoogleMapClusterTag clusterer) {
2701        this.clusterer = clusterer;
2702    }
2703    /**
2704     * Adds a wms tag to this map.
2705     *
2706     * @param tag An initialized GoogleMapWMSTag
2707     */

2708    public void addWMSTag(GoogleMapWMSTag tag) {
2709        if (wms == null)
2710            wms = new Hashtable JavaDoc();
2711        wms.put(tag.getId(), tag);
2712    }
2713    /**
2714     * Returns a GoogleMapWMSTag with the given id, or null
2715     * if a tag with that id is not present.
2716     *
2717     * @return A GoogleMapWMSTag or null.
2718     */

2719    public GoogleMapWMSTag getWms(String JavaDoc id) {
2720        if (wms == null)
2721            return null;
2722        else
2723            return (GoogleMapWMSTag) wms.get(id);
2724    }
2725    /**
2726     * Returns a Hashtable of GoogleMapWMSTags, keyed by id, or null
2727     * if none exist in this map.
2728     *
2729     * @return A Hashtable of GoogleMapWMSTags, keyed by id.
2730     */

2731    public Hashtable JavaDoc getWmsTypes() {
2732        return wms;
2733    }
2734    /**
2735     * Denotes whether or not debugging is turned on for this map. Only valid
2736     * on version 2 maps. Version 1 maps return false.
2737     *
2738     * @return The debugging status of this map.
2739     */

2740    public boolean isDebug() {
2741        return debug;
2742    }
2743    /**
2744     * Turns debugging on or off for this map. If turned on, version 2 maps will
2745     * display a small pop-up window with debugging information in it.
2746     *
2747     * @param debug True to turn on debugging, false to turn it off.
2748     *
2749     */

2750    public void setDebug(boolean debug) {
2751        if (version != null && version.indexOf("2") == 0)
2752            this.debug = debug;
2753        else
2754            this.debug = false;
2755    }
2756    /**
2757     * Adds a label to this map.
2758     *
2759     * @param label An initialized GoogleMapLabelTag
2760     */

2761    public void addLabel(GoogleMapLabelTag label) {
2762        if (labels == null)
2763            labels = new Vector JavaDoc();
2764        labels.addElement(label);
2765    }
2766    /**
2767     * Removes aa label from the map.
2768     *
2769     * @param label A label to remove from the map.
2770     */

2771    public void deleteLabel(GoogleMapLabelTag label) {
2772        if (labels != null)
2773            labels.remove(label);
2774    }
2775    /**
2776     * Sets the list of labels to display on the map.
2777     *
2778     * @param labels A Vector containing GoogleMapLabelTag objects.
2779     */

2780    public void setLabels(Vector JavaDoc labels) {
2781        this.labels = labels;
2782    }
2783    /**
2784     * Returns the list of map labels in a Vector.
2785     *
2786     * @return A Vector of GoogleMapLabelTag objects.
2787     */

2788    public Vector JavaDoc getLabels() {
2789        return labels;
2790    }
2791    /**
2792     * Denotes whether or not this map is in headless mode. Headless mode
2793     * hides user controls unless the cursor is inside the map.
2794     *
2795     * @return True or false.
2796     */

2797    public boolean isHeadless() {
2798        return headless;
2799    }
2800    /**
2801     * Sets headless mode for this map. Headless mode will only display user
2802     * controls when the cursor is inside the map. Default is false (headless mode off).
2803     *
2804     * @param headless True or false.
2805     */

2806    public void setHeadless(boolean headless) {
2807        this.headless = headless;
2808    }
2809    /**
2810     * Returns the maximum allowable zoom level for this map. Users will not be able to zoom
2811     * in higher than this number. Default is 17 (all the way in).
2812     *
2813     * @return Maximum zoom level as an int.
2814     */

2815    public int getMaxZoom() {
2816        return maxZoom;
2817    }
2818    /**
2819     * Sets the maximum allowable zoom level for this map. Users will not be able to zoom
2820     * in higher than this number. Default is 17 (all the way in).
2821     *
2822     * @param maxZoom zoom level as an int.
2823     */

2824    public void setMaxZoom(int maxZoom) {
2825        this.maxZoom = maxZoom;
2826    }
2827    /**
2828     * Returns the minimum allowable zoom level for this map. Users will not be able to zoom
2829     * out further than this number. Default is 0 (all the way out).
2830     *
2831     * @return Minimum zoom level as an int.
2832     */

2833    public int getMinZoom() {
2834        return minZoom;
2835    }
2836    /**
2837     * Sets the minimum allowable zoom level for this map. Users will not be able to zoom
2838     * out further than this number. Default is 0 (all the way out).
2839     *
2840     * @param minZoom zoom level as an int.
2841     */

2842    public void setMinZoom(int minZoom) {
2843        this.minZoom = minZoom;
2844    }
2845    /**
2846     * Returns whether or not this map is bound to it's contents. If bound, the map cannot
2847     * be panned outside the defined points. Default is false.
2848     *
2849     * @return True or false denoting if this map is bound.
2850     */

2851    public boolean isBound() {
2852        return bound;
2853    }
2854    /**
2855     * Sets the bound state of this map. If bound, it cannot be panned outside the points that
2856     * have been defined in it (with a little fudge factor for smoother scrolling. Default is
2857     * false.
2858     *
2859     * @param bound Sets the bound state of this map.
2860     */

2861    public void setBound(boolean bound) {
2862        this.bound = bound;
2863    }
2864    /**
2865     * Removes an insert from the map.
2866     *
2867     * @param insert An insert to remove from the map.
2868     */

2869    public void deleteInsert(GoogleMapInsertTag insert) {
2870        if (inserts != null)
2871            inserts.remove(insert);
2872    }
2873    /**
2874     * Adds an insert to this map.
2875     *
2876     * @param insert An initialized GoogleMapInsertTag
2877     */

2878    public void addInsert(GoogleMapInsertTag insert) {
2879        if (inserts == null)
2880            inserts = new Vector JavaDoc();
2881        inserts.addElement(insert);
2882    }
2883    /**
2884     * Sets the list of inserts to display on the map.
2885     *
2886     * @param inserts A Vector containing GoogleMapInsertTag objects.
2887     */

2888    public void setInserts(Vector JavaDoc inserts) {
2889        this.inserts = inserts;
2890    }
2891    /**
2892     * Returns the list of map inserts in a Vector.
2893     *
2894     * @return A Vector of GoogleMapInsertTag objects.
2895     */

2896    public Vector JavaDoc getInserts() {
2897        return inserts;
2898    }
2899    /**
2900     * Adds a GoogleMapCoordinatesTag to the map.
2901     *
2902     * @param coords An initialized GoogleMapCoordinates Tag.
2903     */

2904    public void addCoordinates(GoogleMapCoordinatesTag coords) {
2905        this.coords = coords;
2906    }
2907    /**
2908     * Returns the currently designated default language.
2909     *
2910     * @return The 2 -digit language code.
2911     */

2912    public String JavaDoc getLanguage() {
2913        return language;
2914    }
2915    /**
2916     * Sets the desired default 2-digit language code.
2917     *
2918     * @param language The 2-figit language code to use.
2919     */

2920    public void setLanguage(String JavaDoc language) {
2921        this.language = language;
2922    }
2923    /**
2924     * Denotes whether or not the map is set to display current day and nighttime light
2925     * conditions.
2926     *
2927     * @return True or false.
2928     */

2929    public boolean isShowDaylight() {
2930        return showDaylight;
2931    }
2932    /**
2933     * Allows the map to display where the current day/night conditions are. Set to true
2934     * to see light/dark, false if not. Default is false.
2935     *
2936     * @param showDaylight true to show, false if not.
2937     */

2938    public void setShowDaylight(boolean showDaylight) {
2939        this.showDaylight = showDaylight;
2940    }
2941}
2942
Popular Tags