001 package com.google.gwt.maps.client.events.fusiontablemouse; 002 003 import com.google.gwt.ajaxloader.client.Properties; 004 import com.google.gwt.ajaxloader.client.Properties.TypeException; 005 import com.google.gwt.core.client.JavaScriptObject; 006 import com.google.gwt.maps.client.base.LatLng; 007 import com.google.gwt.maps.client.base.Size; 008 import com.google.gwt.maps.client.events.MapEvent; 009 010 public class FusionTablesMouseMapEvent extends MapEvent<FusionTablesMouseMapHandler, FusionTablesMouseMapEvent> { 011 012 public static Type<FusionTablesMouseMapHandler> TYPE = new Type<FusionTablesMouseMapHandler>(); 013 014 public FusionTablesMouseMapEvent(Properties properties) { 015 super(properties); 016 } 017 018 @Override 019 public com.google.gwt.event.shared.GwtEvent.Type<FusionTablesMouseMapHandler> getAssociatedType() { 020 return TYPE; 021 } 022 023 @Override 024 protected void dispatch(FusionTablesMouseMapHandler handler) { 025 handler.onEvent(this); 026 } 027 028 /** 029 * Pre-rendered HTML content, as placed in the infowindow by the default UI. 030 */ 031 public String getInfoWindowHtml() { 032 String infoWindowHtml = null; 033 try { 034 infoWindowHtml = properties.getString("infoWindowHtml"); 035 } catch (TypeException e) { 036 e.printStackTrace(); 037 } 038 return infoWindowHtml; 039 } 040 041 /** 042 * The position at which to anchor an infowindow on the clicked feature. 043 * @return {@link LatLng} 044 */ 045 public LatLng getLatLng() { 046 LatLng latLng = null; 047 try { 048 latLng = (LatLng) properties.getObject("latLng"); 049 } catch (TypeException e) { 050 e.printStackTrace(); 051 } 052 return latLng; 053 } 054 055 /** 056 * gets The offset to apply to an infowindow anchored on the clicked feature. 057 */ 058 public Size getPixelOffset() { 059 Size pixelOffset = null; 060 try { 061 pixelOffset = (Size) properties.getObject("pixelOffset"); 062 } catch (TypeException e) { 063 e.printStackTrace(); 064 } 065 return pixelOffset; 066 } 067 068 /** 069 * returns A collection of FusionTablesCell objects, indexed by column name, representing the contents of the table row which included the clicked feature. 070 */ 071 public JavaScriptObject getRow() { 072 return parseRow(); 073 } 074 075 /** 076 * A collection of FusionTablesCell objects, indexed by column name, representing the contents of the table row which included the clicked feature. 077 * @return as JSON string 078 */ 079 public String getRowAsJson() { 080 return getAsJson(parseRow()); 081 } 082 083 /** 084 * returns a jso that would read possibly 085 * like ({station:{columnName:"station", value:"Chicago"}, address:{columnName:"address", value:"800 N. State St., Chicago, IL"}, ridership:{columnName:"ridership", value:"13531"}}) 086 */ 087 private JavaScriptObject parseRow() { 088 JavaScriptObject row = null; 089 try { 090 row = properties.getObject("row"); 091 } catch (TypeException e) { 092 e.printStackTrace(); 093 } 094 return row; 095 } 096 097 }