Google Maps API Tutorial© 2006, 2008, 2009 Mike Williams |
Translate this page: |
GIcon.labelThis feature allows you to build your icon from a background image plus a foreground label. Prior to the introduction of this feature, if you wanted to have markers with different letters and different background colours, you had to create a separate icon image for each combination.
There's an example here. The syntax is a bit weird. The GIcon.label is an object of unnamed class that must have the following properties:
The easiest way to set things up is to have the label be the same size as the icon image and set the anchor to GPoint(0,0), but it's more efficient to make the label smaller and use the size and anchor parameters to position it. You can set the GIcon.label directly, like this var Icon = new GIcon(); Icon.label = {"url":"overlay.png", "anchor":new GPoint(4,4), "size":new GSize(12,12)};or you can use the new additional parameter of the GIcon() constructor, like this var mylabel = {"url":"overlay.png", "anchor":new GPoint(4,4), "size":new GSize(12,12)}; var Icon = new GIcon(G_DEFAULT_ICON, "marker.png", mylabel); Potential Pitfalls
|