|Language:||English, Spanish, Dutch|
|Genre:||Children & Youth|
|Distribution:||Free* [*Sign up for free]|
First, the Marker object is called Marker instead of GMarker and resides in the google. Second, instead of several parameters, it takes only one, which is a MarkerOptions object. Another difference is that in v2 you first had to create a marker and then add it to the map using the addOverlay method of the Map object.
In v3 you can instantly add the marker to the map by passing a reference to the Map object in the MarkerOptions object. By omitting the map property, you just create the marker and can then add it to the map later by using its setMap method. Alternatively, you could use the setImage method of the Marker object and pass a URL to an image as its parameter. In v3 you have a few more options. You can set the icon directly using the icon property of the MarkerOptions object, or you can set it later using the setIcon method of the Marker object.
In both cases, you can choose whether to use a full-fledged MarkerImage object or simply to use a URL to an image. In v2 the GIcon object included everything about the marker icon, such as its shadow, its printImage, and so on. In v3 this is handled differently.
For example, the icon shadow is handled as a separate property in the MarkerOptions object. All the alternative icons you could define in v2, such as printImage, mozPrintImage, and transparent are dropped, so you only need to worry about providing one image for the icon and one for its shadow.
In its simplest form, changing the marker icon requires that you only provide it with a URL for the icon and one for the shadow. Well, you could actually omit the shadow property if you like.
When changing the default icon, the default shadow is also removed. LatLng 54, 12 , map: map, icon: 'icon. In v3 this is defined by using the shape property of the MarkerOptions object, which takes a MarkerShape object as its value.
This object has two properties, type and coord. The type property defines the kind of shape you would like to use, such as a polygon, circle, or rectangle.
The coord property takes an array of integers defining the points in the shape. Sprites are an excellent way of speeding up your map and web page since it reduces the number of files that need to be downloaded.
How to use them are a bit tricky but is covered in detail in Chapter 6. Marker Locations Each marker descriptor must contain a set of one or more locations defining where to place the marker on the map. These locations are separated using the pipe character. Note: If you choose to specify marker locations using a method that requires geocoding, such as human-readable address strings or polylines, the request is limited to a maximum of 15 markers.
This limit applies only to marker locations that require geocoding. The location parameters define the marker's location on the map. If the location is off the map, that marker will not appear in the constructed image provided that center and zoom parameters are supplied.
However, if these parameters are not supplied, the Maps Static API server will automatically construct an image which contains the supplied markers. See Implicit Positioning below. A sample marker declaration is shown below. This set of markers parameters defines three markers: one blue marker labeled "S" at Custom icons are specified using the icon descriptor in the markers parameter. You may specify an anchor point for the custom icon. The anchor point sets how the icon is placed in relation to the specified markers locations.
By default, the anchor point of a custom icon is the bottom center of the icon image. You can specify a different anchor point using the anchor descriptor in conjunction with your icon. Set the anchor as an x,y point of the icon such as 10,5 , or as a predefined alignment using one of the following values: top, bottom, left, right, center, topleft, topright, bottomleft, or bottomright.
This limitation does not mean that you are limited to only 5 marked locations on your map. Each unique icon may be used with more than one markers location on your map.
Icons may be up to pixels maximum size 64x64 for square images. Custom Icon Examples Example 1 creates custom icons and positions the icons using anchors. Note that both path points are separated from each other using the pipe character.
Because both style information and point information is delimited via the pipe character, style information must appear first in any path descriptor. Once the Maps Static API server encounters a location in the path descriptor, all other path parameters are assumed to be locations as well.
Path Styles The set of path style descriptors is a series of value assignments separated by the pipe character. This style descriptor defines the visual attributes to use when displaying the path. If no weight parameter is set, the path will appear in its default thickness 5 pixels.
When a bit hex value is specified, the last two characters specify the 8-bit alpha transparency value.
This value varies between 00 completely transparent and FF completely opaque. Note that transparencies are supported in paths, though they are not supported for markers.
The set of locations following need not be a "closed" loop; the Maps Static API server will automatically join the first and last points. Note, however, that any stroke on the exterior of the filled area will not be closed unless you specifically provide the same beginning and end location. When false, the path is rendered as a straight line in screen space.
Defaults to false.
If default attributes are desired, you may skip defining the path attributes; in that case, the path descriptor's first "argument" will consist instead of the first declared point location. Path Points In order to draw a path, the path parameter must also be passed two or more points.
Each pathPoint is denoted in the pathDescriptor separated by the pipe character.