Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * 
   * ==============================================================================
   * Licensed under the Apache License, Version 2.0 (the "License"); you may not
   * use this file except in compliance with the License. You may obtain a copy of
   * the License at
   * 
   * http://www.apache.org/licenses/LICENSE-2.0
   * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  * License for the specific language governing permissions and limitations under
  * the License.
  */
 package wicket.contrib.gmap.api;
 
 import java.util.Map;
 
 
Represents an Google Maps API's GOverlay.
 
 public abstract class GOverlay implements Serializable
 {
 	private static final long serialVersionUID = 1L;

id of this object. it is session unique.
 
 	private final String id;
 
 	private GMap2 parent = null;
 
 	private final Map<GEventGEventHandlerevents = new EnumMap<GEventGEventHandler>(
 		GEvent.class);

Construct.
 
 	public GOverlay()
 	{
 		// id is session unique
 		 = String.valueOf(Session.get().nextSequenceValue());
 	}

Returns:
String representing the JavaScript add command for the corresponding JavaScript object.
 
 	public String getJSadd()
 	{
 		StringBuffer js = new StringBuffer(.getJSinvoke("addOverlay('" + getId() + "', " +
 			getJSconstructor() + ")"));
 		// Add the Events
 		for (GEvent event : .keySet())
 		{
 			js.append(event.getJSadd(this));
 		}
 		return js.toString();
 	}

Returns:
String representing the JavaScript remove command for the corresponding JavaScript object.
 
 	public String getJSremove()
 	{
 		StringBuffer js = new StringBuffer();
 		// clear the Events
 		for (GEvent event : .keySet())
 		{
 			js.append(event.getJSclear(this));
 		}
 		js.append(.getJSinvoke("removeOverlay('" + getId() + "')"));
 		return js.toString();
 	}

Returns:
The session unique id of this object as a String.
 
 	public String getId()
 	{
 		return ;
 	}

Implement the needed JavaScript constructor for the corresponding JavaScript object.

Returns:
String representing the JavaScript constructor.
 
	public abstract String getJSconstructor();
	public GMap2 getParent()
	{
		return ;
	}
	public void setParent(GMap2 parent)
	{
		this. = parent;
	}

Add a control.

Parameters:
control control to add
Returns:
This
	public GOverlay addListener(GEvent eventGEventHandler handler)
	{
		.put(eventhandler);
		if (AjaxRequestTarget.get() != null)
		// TODO
		// && getParent().findPage() != null)
		{
			AjaxRequestTarget.get().appendJavaScript(event.getJSadd(this));
		}
		return this;
	}

Return all registered Listeners.

Returns:
registered listeners
	{
		return Collections.unmodifiableMap();
	}

Clear listeners.

Parameters:
event event to be cleared.
Returns:
This
	{
		.remove(event);
		if (AjaxRequestTarget.get() != null)
		// TODO
		// && findPage() != null)
		{
			AjaxRequestTarget.get().appendJavaScript(event.getJSclear(this));
		}
		return this;
	}

Called when an Ajax call occurs.

Parameters:
target
overlayEvent
	public void onEvent(AjaxRequestTarget targetGEvent overlayEvent)
	{
		updateOnAjaxCall(targetoverlayEvent);
		.get(overlayEvent).onEvent(target);
	}

Implement to handle Ajax calls to your needs.

Parameters:
target
overlayEvent
	protected abstract void updateOnAjaxCall(AjaxRequestTarget targetGEvent overlayEvent);
New to GrepCode? Check out our FAQ X