typescript 中 Marker icon 属性无法传入 BMap.Symbol 对象
xyxc0673 opened this issue · 5 comments
xyxc0673 commented
示例代码:
const CustomMap = () => {
const iconShapePoint = new BMap.Symbol(BMap_Symbol_SHAPE_POINT, {
scale: 2, // 图标缩放大小
fillColor: 'orange', // 填充颜色
fillOpacity: 0.8, // 填充透明度
});
return (
<Map zoom={5}>
<Marker
position={{ lng: 116.397128, lat: 39.916527 }}
icon={iconShapePoint}
/>
</Map>
);
};
提示如下:
Type 'Symbol' is missing the following properties from type 'Icon': setImageSize, setImageOffset, setInfoWindowAnchor, setPrintImageUrl
jaywcjlove commented
xyxc0673 commented
我在组件的文档里面看到这样的例子:
https://codesandbox.io/s/m9p2nb
然后百度的示例中心有这样的例子:
https://lbsyun.baidu.com/jsdemo.htm#c1_20
如果按照官方 API 的截图就有点奇怪了。
jaywcjlove commented
@xyxc0673 我看了官方示例确实有,但是是 2.0 的API
如果 3.0 的不知道是否删除,我建议你使用 // @ts-ignore
跳过 typescript 错误,看效果出来了没有
如果出来效果说明 API 还没有删除,那么你可以提交一个 pr 补充这个类型。 并标注过时 API
xyxc0673 commented
@jaywcjlove 通过 // @ts-ignore 的方式确实能够出来效果,说明 3.0 仍然支持传入 Symbol
我有空提交个 PR