Skip to content

奇怪的lable不消失 #328

@jy1989

Description

@jy1989

采用如下写法:

<Map ref={map} widget={['NavigationControl']} enableScrollWheelZoom={true} center={center} >
          //下面的marker和label都正常
          {
            marker && <React.Fragment>
              <Marker

                position={{ lat: marker.lat, lng: marker.lng }}
                onClick={({ type, target }) => {
                  setIsModalOpen(true)
                }}
              />
              <Label style={{ border: 1, padding: '5px' }} position={{ lat: marker.lat, lng: marker.lng }}>
                <p>{marker.name}</p>
              </Label>
            </React.Fragment>
          }
        //marker正常,label不正常
          {deviceHistories.map((item, index) => (
            <React.Fragment key={index + "history"}>
              <Marker
                key={index + "marker"}
                position={{ lat: item.lat, lng: item.lng }}
                icon={icon}
              />
              <Label
                key={index + "label"}
                position={{ lat: item.lat, lng: item.lng }}
              >
                <p>{item.createdAt}</p>
              </Label>
            </React.Fragment>
          ))}
......

deviceHistories数组一开始为空,赋值后也一切正常,但是当我清空deviceHistories的时候,marker会消失,但是label不消失,而且奇怪的是第一段的marker和label都正常, 第二段的label却消失不了。 试过写成两个循环,也是一样的效果

一开始devicehistories为空

image

赋值

image

清空 ,marker消失了,label还在

image

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