Skip to content

🤔 [QUESTION] 示例代码无法运行 #221

Closed
@crystaldust

Description

@crystaldust

🐛 Question description [Please make everyone to understand it]

使用npx创建ts项目,然后跑示例代码,提示config类型不兼容

💻 Link to minimal reproduction

Please provide a link by forking these links LarkMap or GitHub repo. What is a minimal reproduction, and why is it required?

安装:

$ npx create-react-app antd-l7-test/ --template typescript
$ cd antd-l7-test
$ yarn add @antv/l7 @antv/larkmap
$ yarn

运行:

$ npm run start

src/App.tsx修改为示例代码:

import React from 'react';
import { LarkMap } from '@antv/larkmap';

const config = {
  mapType: 'Gaode',
  mapOptions: {
    style: 'light',
    center: [120.210792, 30.246026],
    zoom: 10,
  },
};

export default () => {
  return <LarkMap {...config} style={{ height: '300px' }}></LarkMap>;
};

报错:

ERROR in src/App.tsx:14:11
TS2322: Type '{ style: { height: string; }; mapType: string; mapOptions: { style: string; center: number[]; zoom: number; }; }' is not assignable to type 'Omit<LarkMapProps & RefAttributes<LarkMapRefAttributes>, "ref">'.
  Types of property 'mapType' are incompatible.
    Type 'string' is not assignable to type '"Gaode" | "GaodeV1" | "GaodeV2" | "Mapbox" | "Map" | "Tencent" | "Baidu" | undefined'.
    12 |
    13 | export default () => {
  > 14 |   return <LarkMap {...config} style={{ height: '300px' }}></LarkMap>;
       |           ^^^^^^^
    15 | };
    16 |

软件版本:

    "@antv/l7": "^2.21.1",
    "@antv/larkmap": "^1.4.13",

🏞 Expected result

🚑 Any additional [like screenshots]

  • LarkMap Version:
  • Platform:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions