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

后端 未结 2 708
悲哀的现实
悲哀的现实 2020-12-16 14:01

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, wh

相关标签:
2条回答
  • 2020-12-16 14:14

    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.

    0 讨论(0)
  • 2020-12-16 14:28

    Hmm... Now, this answer is just wrong.

    You can't

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

    It's an object literal, which means that you can just use it like this:

    var icon = {
        anchor: new Point(...),
        url: "myurl"
        // etc..
    };
    
    0 讨论(0)
提交回复
热议问题