类型脚本中带有Google标记的自定义属性 [英] custom property with google marker in type script

查看:100
本文介绍了类型脚本中带有Google标记的自定义属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用类型脚本,并尝试使用Google标记设置自定义属性时出现以下错误. 有人可以建议如何使用Google Map Marker设置自定义属性吗?

I'm using type script and getting below error when trying to set custom property with Google marker. Can anyone please advice how to set custom property with Google Map Marker?

类型'{的参数:position:LatLng;地图:任何;图标:字符串; zIndex:数字; se10:任何; }'不能分配给类型的参数 'MarkerOptions'.对象文字只能指定已知的属性,并且 "se10"在"MarkerOptions"类型中不存在.

Argument of type '{ position: LatLng; map: any; icon: string; zIndex: number; se10: any; }' is not assignable to parameter of type 'MarkerOptions'. Object literal may only specify known properties, and 'se10' does not exist in type 'MarkerOptions'.

以下Javascript代码运行良好.

The following Javascript code is working well.

var marker = new google.maps.Marker({
            position: new google.maps.LatLng(Number(merchant[lat]), Number(merchant[lng])),
            map: map,
            icon: icon,
            zIndex: zIndex ,
            se10: merchant.se
        });

推荐答案

知道了.下面是类型脚本代码-

Got it . below is type script code -

var marker = new google.maps.Marker({
                position: new google.maps.LatLng(Number(merchant[lat]), Number(merchant[lng])),
                map: map,
                icon: icon,
                zIndex: zIndex ,
            });
            marker.set("se10",merchant.se);

这篇关于类型脚本中带有Google标记的自定义属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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