KickJava   Java API By Example, From Geeks To Geeks.

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


1 package com.lamatek.tags.google;
2
3 import java.io.Serializable JavaDoc;
4 import java.util.Vector JavaDoc;
5
6 import javax.servlet.jsp.tagext.BodyTagSupport JavaDoc;
7 import javax.servlet.jsp.tagext.Tag JavaDoc;
8
9 /**
10  * GoogleMapMarkerTag
11  *
12  * This class represents a <googlemaps:marker> tag. Developers should not subclass or override this
13  * class or it's methods.
14  *
15  * @author Tom Cole
16  * @version 0.40
17  */

18 public class GoogleMapMarkerTag extends BodyTagSupport JavaDoc implements Serializable JavaDoc, GoogleMapEventListener {
19
20     String JavaDoc id = null;
21     String JavaDoc point = null;
22     InfoWindow infoWindow = null;
23     GoogleMapBlowupTag blowup = null;
24     Vector JavaDoc events = null;
25     GoogleMapIconTag icon = null;
26     boolean draggable = false;
27     /**
28      * Overrides doStartTag() from BodytagSupport. Developers should not override this method.
29      */

30     public int doStartTag() {
31         Tag JavaDoc tag = this;
32         while (tag.getParent() != null) {
33             if (tag.getParent() instanceof GoogleMapTag) {
34                 ((GoogleMapTag) tag.getParent()).addMarker(this);
35                 return EVAL_BODY_INCLUDE;
36             }
37             tag = tag.getParent();
38         }
39         return EVAL_BODY_INCLUDE;
40     }
41     /**
42      * Overrides doStartTag() from BodytagSupport. Developers should not override this method.
43      */

44     public int doEndTag() {
45         return EVAL_PAGE;
46     }
47     /**
48      * Adds an event to this marker. Only events of type 'click' or 'dblclick' will actually
49      * register.
50      *
51      * @param event An initializes GoogleMapEventTag
52      */

53     public void addEvent(GoogleMapEventTag event) {
54         if (events == null)
55             events = new Vector JavaDoc();
56         events.add(event);
57     }
58     /**
59      * Sets the info window for this marker. There can only be one info window per marker, so
60      * successive calls to this method will remove the previous info window, replacing it with the
61      * current one.
62      *
63      * @param infoWindow A tag that implements InfoWindow
64      */

65     public void setInfoWindow(InfoWindow infoWindow) {
66         this.infoWindow = infoWindow;
67     }
68     /**
69      * Sets the map blowup window for this marker. There can only be one blowup window per marker, so
70      * successive calls to this method will remove the previous blowup window, replacing it with the
71      * current one.
72      *
73      * @param infoWindow An initialized GoogleMapBlowupTag
74      */

75     public void setBlowup(GoogleMapBlowupTag blowup) {
76         this.blowup = blowup;
77     }
78     /**
79      * Sets a GoogleMapIconTag for this marker, overriding the standard Google Maps marker icon.
80      *
81      * @param icon An initialized GoogleMapIconTag
82      */

83     public void setIcon(GoogleMapIconTag icon) {
84         this.icon = icon;
85     }
86     /**
87      * Returns the currently defined info window for this marker.
88      *
89      * @return A GoogleMapInfoWindowTag
90      */

91     public InfoWindow getInfoWindow() {
92         return infoWindow;
93     }
94     /**
95      * Returns the currently defined blowup window for this marker.
96      *
97      * @return A GoogleMapBlowupTag
98      */

99     public GoogleMapBlowupTag getBlowup() {
100         return blowup;
101     }
102     /**
103      * Returns this marker's id.
104      *
105      * @return A String representing the marker's id.
106      */

107     public String JavaDoc getId() {
108         return id;
109     }
110     /**
111      * Sets the unique id for this marker.
112      *
113      * @param id A unique id for this marker instance.
114      */

115     public void setId(String JavaDoc id) {
116         this.id = id;
117     }
118     /**
119      * Returns the id of the GoogleMapPointTag used as the centerpoint
120      * for this marker.
121      *
122      * @return A GoogleMapPointTag id.
123      */

124     public String JavaDoc getPoint() {
125         return point;
126     }
127     /**
128      * Sets the id for the GoogleMapPointTag used as the centerpoing for
129      * this marker.
130      *
131      * @param point A valid GoogleMapPointTag id.
132      */

133     public void setPoint(String JavaDoc point) {
134         this.point = point;
135     }
136     /**
137      * Returns the list of currently registered event listeners
138      * for this overlay.
139      *
140      * @return A Vector of GoogleMapEventTags
141      */

142     public Vector JavaDoc getEvents() {
143         return events;
144     }
145     /**
146      * Sets a list of registered event listeners.
147      *
148      * @param events A Vector of GoogleMapEventTags.
149      */

150     public void setEvents(Vector JavaDoc events) {
151         this.events = events;
152     }
153     /**
154      * Returns the GoogleMapIconTag that renders this marker, or null if the default
155      * markers are used.
156      *
157      * @return A GoogleMapIconTag or null.
158      */

159     public GoogleMapIconTag getIcon() {
160         return icon;
161     }
162     /**
163      * Denotes whether or not this marker should be draggable.
164      *
165      * @return True if this marker is draggable. False if not.
166      */

167     public boolean isDraggable() {
168         return draggable;
169     }
170     /**
171      * Sets wheter or not this marker should be draggable.
172      * Default is false.
173      *
174      * @param draggable True if this marker is to be draggable, false if not.
175      */

176     public void setDraggable(boolean draggable) {
177         this.draggable = draggable;
178     }
179 }
180
Popular Tags