什么是构造接口`google.maps.Icon` [英] What is the construct interface `google.maps.Icon`

查看:230
本文介绍了什么是构造接口`google.maps.Icon`的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Google地图V3 JS API 的文档似乎没有给出 google.maps.Icon 构造的接口。我发现一个带有 MarkerImage 的例子,现在似乎不推荐使用它。

所以,有可能<$ code> google.maps.Icon 构造参数和它们的顺序是什么?如何定义图标大小,精灵中的图标偏移,图标定位等? $ b

我如何创建图标并将其分配给标记?例如(未测试/不工作):

  var icon = new google.maps.Icon(path,
新的google.maps.Size(32,32),//大小
新的google.maps.Point(0,32),//在精灵中的偏移
null,//定位
) ;

我看到了文档,但是如果该类没有看到示例用法!

解决方案

没有google.maps.Icon的构造函数,它是一个像MapOptions MarkerOptions PolygonOptions 等。



<你可以像这样使用它:

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


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!

解决方案

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..
    };

这篇关于什么是构造接口`google.maps.Icon`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆