custom property with google marker in type script

本小妞迷上赌 提交于 2020-02-21 03:15:44

问题


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?

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'.

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

回答1:


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);


来源:https://stackoverflow.com/questions/35542083/custom-property-with-google-marker-in-type-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!