001 package com.google.gwt.maps.client.overlays; 002 003 import com.google.gwt.core.client.JavaScriptObject; 004 import com.google.gwt.maps.client.base.Point; 005 import com.google.gwt.maps.client.base.Size; 006 007 /** 008 * A structure representing a Marker icon or shadow image. 009 * <br><br> 010 * See <a href="https://developers.google.com/maps/documentation/javascript/reference#MarkerImage">MarkerImage API Doc</a> 011 */ 012 public class MarkerImage extends JavaScriptObject { 013 014 /** 015 * A structure representing a Marker icon or shadow image. 016 */ 017 protected MarkerImage() {} 018 019 /** 020 * creates A structure representing a Marker icon or shadow image. 021 * @param url The URL of the image or sprite sheet. 022 * @return {@link MarkerImage} 023 */ 024 public final static MarkerImage newInstance(String url) { 025 return createJso(url).cast(); 026 } 027 028 /** 029 * creates A structure representing a Marker icon or shadow image. 030 * @param url The URL of the image or sprite sheet. 031 * @param size The display size of the sprite or image. When using sprites, you must specify the sprite size. If the size is not provided, it will be set when the image loads. 032 * @return {@link MarkerImage} 033 */ 034 public final static MarkerImage newInstance(String url, Size size) { 035 return createJso(url, size).cast(); 036 } 037 038 /** 039 * creates A structure representing a Marker icon or shadow image. 040 * @param url The URL of the image or sprite sheet. 041 * @param size The display size of the sprite or image. When using sprites, you must specify the sprite size. If the size is not provided, it will be set when the image loads. 042 * @param origin The position of the image within a sprite, if any. By default, the origin is located at the top left corner of the image (0, 0). 043 * @return {@link MarkerImage} 044 */ 045 public final static MarkerImage newInstance(String url, Size size, Point origin) { 046 return createJso(url, size, origin).cast(); 047 } 048 049 /** 050 * creates A structure representing a Marker icon or shadow image. 051 * @param url The URL of the image or sprite sheet. 052 * @param size The display size of the sprite or image. When using sprites, you must specify the sprite size. If the size is not provided, it will be set when the image loads. 053 * @param origin The position of the image within a sprite, if any. By default, the origin is located at the top left corner of the image (0, 0). 054 * @param anchor The position at which to anchor an image in correspondance to the location of the marker on the map. By default, the anchor is located along the center point of the bottom of the image. 055 * @return {@link MarkerImage} 056 */ 057 public final static MarkerImage newInstance(String url, Size size, Point origin, Point anchor) { 058 return createJso(url, size, origin, anchor).cast(); 059 } 060 061 /** 062 * creates A structure representing a Marker icon or shadow image. 063 * @param url The URL of the image or sprite sheet. 064 * @param size The display size of the sprite or image. When using sprites, you must specify the sprite size. If the size is not provided, it will be set when the image loads. 065 * @param origin The position of the image within a sprite, if any. By default, the origin is located at the top left corner of the image (0, 0). 066 * @param anchor The position at which to anchor an image in correspondance to the location of the marker on the map. By default, the anchor is located along the center point of the bottom of the image. 067 * @param scaledSize The size of the entire image after scaling, if any. Use this property to stretch/shrink an image or a sprite. 068 * @return {@link MarkerImage} 069 */ 070 public final static MarkerImage newInstance(String url, Size size, Point origin, Point anchor, Size scaledSize) { 071 return createJso(url, size, origin, anchor, scaledSize).cast(); 072 } 073 074 private final static native JavaScriptObject createJso(String url) /*-{ 075 return new $wnd.google.maps.MarkerImage(url); 076 }-*/; 077 078 private final static native JavaScriptObject createJso(String url, Size size) /*-{ 079 return new $wnd.google.maps.MarkerImage(url, size); 080 }-*/; 081 082 private final static native JavaScriptObject createJso(String url, Size size, Point origin) /*-{ 083 return new $wnd.google.maps.MarkerImage(url, size, origin); 084 }-*/; 085 086 private final static native JavaScriptObject createJso(String url, Size size, Point origin, Point anchor) /*-{ 087 return new $wnd.google.maps.MarkerImage(url, size, origin, anchor); 088 }-*/; 089 090 private final static native JavaScriptObject createJso(String url, Size size, Point origin, Point anchor, Size scaledSize) /*-{ 091 return new $wnd.google.maps.MarkerImage(url, size, origin, anchor, scaledSize); 092 }-*/; 093 094 /** 095 * sets The position at which to anchor an image in correspondance to the location of the marker on the map. By default, the anchor is located along the center point of the bottom of the image. 096 * @param anchor 097 */ 098 public final native void setAnchor(Point anchor) /*-{ 099 this.anchor = anchor; 100 }-*/; 101 102 /** 103 * gets The position at which to anchor an image in correspondance to the location of the marker on the map. By default, the anchor is located along the center point of the bottom of the image. 104 */ 105 public final native Point getAnchor() /*-{ 106 return this.anchor; 107 }-*/; 108 109 /** 110 * sets The position of the image within a sprite, if any. By default, the origin is located at the top left corner of the image (0, 0). 111 * @param origin 112 */ 113 public final native void setOrigin(Point origin) /*-{ 114 this.origin = origin; 115 }-*/; 116 117 /** 118 * gets The position of the image within a sprite, if any. By default, the origin is located at the top left corner of the image (0, 0). 119 */ 120 public final native Point getOrigin() /*-{ 121 return this.origin; 122 }-*/; 123 124 /** 125 * sets The size of the entire image after scaling, if any. Use this property to stretch/shrink an image or a sprite. 126 * @param scaledSize 127 */ 128 public final native void setScaledSize(Size scaledSize) /*-{ 129 this.scaledSize = scaledSize; 130 }-*/; 131 132 /** 133 * gets The size of the entire image after scaling, if any. Use this property to stretch/shrink an image or a sprite. 134 */ 135 public final native Size getScaledSize() /*-{ 136 return this.scaledSize; 137 }-*/; 138 139 /** 140 * sets The display size of the sprite or image. When using sprites, you must specify the sprite size. If the size is not provided, it will be set when the image loads. 141 * @param size 142 */ 143 public final native void setSize(Size size) /*-{ 144 this.size = size; 145 }-*/; 146 147 /** 148 * gets The display size of the sprite or image. When using sprites, you must specify the sprite size. If the size is not provided, it will be set when the image loads. 149 */ 150 public final native Size getSize() /*-{ 151 return this.size; 152 }-*/; 153 154 /** 155 * sets The URL of the image or sprite sheet. 156 * @param url 157 */ 158 public final native void setUrl(String url) /*-{ 159 this.url = url; 160 }-*/; 161 162 /** 163 * gets The URL of the image or sprite sheet. 164 */ 165 public final native String getUrl() /*-{ 166 return this.url; 167 }-*/; 168 169 }