I'm not sure who maintains GMap2 (Martin F?) - but I just created a class
that allows me to show an info window when a GMarker is clicked.  This could
actually be abstracted to allow other calls on a GMarker fairly easily.

Two questions:
1 - is there a better way already built in?  (I couldn't find one)
2 - can you use this class or a better method to include this functionality
in GMap2?

Thanks for the GMap2 contribution!!

(Class pasted below)

-- 
Jeremy Thomerson
http://www.wickettraining.com

public class GInfoWindow extends AbstractBehavior {
 private static final long serialVersionUID = 1L;

 private GMap2 mMap;
 private final IModel<String> mHtmlModel;
 private final GMarker mMarker;

 public GInfoWindow(GMarker marker, String html) {
  mMarker = marker;
  mHtmlModel = new Model<String>(html);
 }

 public GInfoWindow(GMarker marker, IModel<String> html) {
  mMarker = marker;
  mHtmlModel = html;
 }

 @Override
 public void bind(Component<?> component) {
  super.bind(component);

  if ((component instanceof GMap2) == false) {
   throw new IllegalStateException("must be added to a gmap2");
  }
  mMap = (GMap2) component;
 }

 @Override
 public void renderHead(IHeaderResponse response) {
  super.renderHead(response);
  CharSequence html = JavascriptUtils.escapeQuotes(mHtmlModel.getObject());
  String call = "overlays[" + mMarker.getId() + "].bindInfoWindowHtml('" +
html + "', null)";
  response.renderOnDomReadyJavascript(mMap.getJSinvoke(call));
 }
}

Reply via email to