Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typescript 中 Marker icon 属性无法传入 BMap.Symbol 对象 #262

Open
xyxc0673 opened this issue Apr 2, 2022 · 5 comments
Open

typescript 中 Marker icon 属性无法传入 BMap.Symbol 对象 #262

xyxc0673 opened this issue Apr 2, 2022 · 5 comments

Comments

@xyxc0673
Copy link

xyxc0673 commented Apr 2, 2022

示例代码:

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
Copy link
Member

@xyxc0673 Marker 不接受 Symbol 类型 的图标,下面是官方 api 截图

image

image

@xyxc0673
Copy link
Author

xyxc0673 commented Apr 2, 2022

我在组件的文档里面看到这样的例子:
https://codesandbox.io/s/m9p2nb
然后百度的示例中心有这样的例子:
https://lbsyun.baidu.com/jsdemo.htm#c1_20

如果按照官方 API 的截图就有点奇怪了。

@jaywcjlove
Copy link
Member

@xyxc0673 我看了官方示例确实有,但是是 2.0 的API

如果 3.0 的不知道是否删除,我建议你使用 // @ts-ignore 跳过 typescript 错误,看效果出来了没有

如果出来效果说明 API 还没有删除,那么你可以提交一个 pr 补充这个类型。 并标注过时 API

@xyxc0673
Copy link
Author

@jaywcjlove 通过 // @ts-ignore 的方式确实能够出来效果,说明 3.0 仍然支持传入 Symbol
我有空提交个 PR

@kasimLZ
Copy link
Contributor

kasimLZ commented Jun 15, 2023

参考google的Marker的设计思路,百度应该是支持Symbol的。
按照百度的3.0参考Api的确存在问题。可能百度也没想好如何定义这块。但是功能的确是存在的。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants