Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
303 views
in Technique[技术] by (71.8m points)

javascript - What is the construct interface `google.maps.Icon`

The docs of Google Maps V3 JS API does not seem to give the interface of the construct of google.maps.Icon. I found an example with MarkerImage, which seems to be deprecated now.

So, what are the possible google.maps.Icon construct parameters and what is their order? How to define icon size, icon offset in sprite, icon anchor, etc?

Edit:

How would I create an icon and assign it to a marker? Eg (not tested/does not work):

var icon = new google.maps.Icon(path, 
    new google.maps.Size(32, 32), // size
    new google.maps.Point(0, 32), // offset in sprite
    null, // anchor
);

I do see the docs but I do not see example usage if that class!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

There is no constructor for the google.maps.Icon, it is an anonymous javascript object like MapOptions, MarkerOptions, PolygonOptions, etc.

You use it like this:

var icon = {
    anchor: new Point(...),
    url: "myurl"
    // etc..
    };

From Oliver in a comment: The point is: there is no such class (or function, for that matter) as google.maps.Icon. The API docs refer to it as google.maps.Icon object specification (here), as opposed to e.g. the InfoWindow class.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...