【问题标题】:Google maps api setting markers reserved word谷歌地图api设置标记保留字
【发布时间】:2013-06-19 13:35:49
【问题描述】:

我正在使用 google maps api 将地图拉入 phonegap 应用程序。该地图运行良好,但我正在尝试设置自定义标记并遵循以下内容:https://developers.google.com/maps/documentation/javascript/overlays#Icons

在您设置图像的地方,代码使用“锚”设置。这是javascript中的保留字,如果留在代码中,javascript会失败。

我该如何解决这个问题?

var image = {
url: 'images/beachflag.png',
// This marker is 20 pixels wide by 32 pixels tall.
size: new google.maps.Size(20, 32),
// The origin for this image is 0,0.
origin: new google.maps.Point(0,0),
// The anchor for this image is the base of the flagpole at 0,32.
anchor: new google.maps.Point(0, 32)

};

【问题讨论】:

    标签: google-maps google-maps-api-3


    【解决方案1】:

    anchor 什么时候成为保留字了?其次,如果您使用保留字作为对象中的键,只需将它们放在引号中,例如

    {
    'anchor': new google.maps.Point(0,32)
    }
    

    【讨论】:

    猜你喜欢
    • 2016-04-08
    • 1970-01-01
    • 1970-01-01
    • 2014-03-22
    • 1970-01-01
    • 1970-01-01
    • 2017-09-13
    • 1970-01-01
    • 2015-06-02
    相关资源
    最近更新 更多