Git Product home page Git Product logo

react-bmapgl's People

Contributors

cl1107 avatar junior2ran avatar lyh543 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

react-bmapgl's Issues

result 读取报错

Uncaught TypeError: Cannot read properties of undefined (reading 'result')

image

CustomOverlay 会受因为其它 state 修改后发生的 rerender 影响,导致闪动

文字看不出来,图片很明显,一闪一闪的

代码

 const [test, setTest] = React.useState(0);

  React.useEffect(() => {
    setInterval(() => {
      setTest((state) => state + 1);
    }, 500);
  }, []);


  <Map
    ref={mapCallback}
    center={mapCenter}
    zoom={mapZoom.current}
    maxZoom={mapZoom.max}
    minZoom={mapZoom.min}
    enableScrollWheelZoom={true}
    style={{ position: 'fixed', left: 0, top: 0, width: '100%', height: '100%' }}
  >
      <CustomOverlay position={new BMapGL.Point(120.0538590588235, 27.611044541630818)}>
        <img src={require('@/assets/maintain-car.png')} width="63" />
      </CustomOverlay>
   </Map>

使用百度地图组件 开启3D模式 center 不更新

 return (
    <Map
      style={{ height: '100%', width: '100%' }}
      center={{ lng, lat }}
      heading={heading}  // 开启地图转角
      zoom={19} 
      tilt={70} // 开启地图倾斜角度
    ></Map>
  );

连续更新 center 的坐标 地图中心点不更新

default.mov

关闭中心点移动效果

3d.mov

地图类型不更新

这里面zoom和center都是正常的,只有类型无法更新。

const MapsContainer = (props: MapsProps) => {
  const [position, setPosition] = useState(new BMapGL.Point(116.404449, 39.914889));
  const [zoom, setZoom] = useState(12);
  const [mapType, setMapType] = useState<'normal'|'earth'|undefined>('normal');
  const getPos = () =>navigator.geolocation.getCurrentPosition((pos) => {
    setPosition(new BMapGL.Point(pos.coords.longitude, pos.coords.latitude));
    setZoom(15);
  });
  return (
    <div className={styles.maps} data-show={props.show}>
      <div className={styles.appBar}></div>
      <div className={styles.content}>
        <div className={styles.mapBar}>
          <div className={styles.mapBarLeft}>
            <div className={styles.mapBarIconBox} onClick={getPos}>
              <FontAwesomeIcon
                className={styles.mapBarIcon}
                icon={faPaperPlane}
              />
            </div>
            <div
              className={styles.mapBarIconBox}
              onClick={() => setMapType('earth')}
            >
              <FontAwesomeIcon
                className={styles.mapBarIcon}
                icon={faGlobeAsia}
              />
            </div>
          </div>
        </div>
        <div className={styles.mapContainer}>
          <Map
            center={position}
            style={{ width: `100%`, height: `100%` }}
            // 这里更新不了
            mapType={mapType}
            zoom={zoom}
            enableScrollWheelZoom
            enableDoubleClickZoom
            enableDragging
          />
        </div>
      </div>
    </div>
  );
}; 

目前无法在ssr下使用

[1] ----------------服务端报错------------------- ReferenceError: window is not defined
请修复window
将代码放在useEffect中使用

单击显示InfoWindow

您好,请问Marker组件的onClick事件如何设置为单击显示InfoWindow,在js中可以调用openInfoWindow,那在组件中怎么调用这个方法嘛?

严重BUG 官网demo就可以复现 在单页应用中 拖拽和缩放后 其他地方是灰色 API已经获取到数据 但是不绘制

我使用的 浏览器端的 react-bmapgl/Map 库进行开发的 把Map组件放到 一个 antd 的 Modal 弹窗中 当我设置另一个 Modal 弹窗时 也会正常弹出地图界面并初始化 但是拖拽或缩放地图查看其他区域的时候 都是灰色

百度官网的demo居然有这个问题 切换到其他菜单 再切换回来Map的说明文档就能复现
参考截图
参考截图链接
参考截图
参考截图链接

marker map is required

使用typescript时,提示marker的map、icon必填

export interface MapChildrenProps {
/** *地图实例,来自父元素<Map>的继承,无需手动传入 */
map: BMapGL.Map;
}

demo上的Arc动画没出来

"react-bmapgl": "^0.1.3",

`

import { Map, CustomOverlay } from 'csr!react-bmapgl';

import Arc from 'csr!react-bmapgl/Custom/Arc';

<Arc
autoViewport={false}
lineOptions={{
width: 5,
color: 'rgba(250, 50, 20, 0.7)'
}}
arrowOptions={{
styleOptions: {
color: 'rgba(250, 50, 20, 0.7)'
}
}}
pointOptions={{
size: 20,
color: 'rgba(250, 50, 20, 0.7)',
shape: 'square'
}}
textOptions={{
fontFamily: 'Kaiti SC',
color: '#f00',
offset: [0, -20]
}}
animationOptions={{
width: 2,
color: () => 'rgba(250, 250, 20, 0.7)',
interval: 0.1
}}
data={[
{
from: {
city: '北京'
},
to: {
city: '南京'
}
},
{
color: '#392',
from: {
city: '北京',
},
to: {
name: '哈哈',
point: {
lng: 101.45934,
lat: 39.135305
}
}
},
{
from: {
city: '北京'
},
to: {
city: '成都'
}
},
{
from: {
city: '北京'
},
to: {
city: '广州'
}
}
]}
/>`

image

在qiankun里面集成时,会报出一个Failed to execute 'write' on 'Document'

貌似是在请求 //api.map.baidu.com/apixxxx 之后请求//api.map.baidu.com/getscript 返回的脚本里使用了write 我是异步加载的最后报了下面的错误

Failed to execute 'write' on 'Document': It isn't possible to write into a document from an asynchronously-loaded external script unless it is explicitly opened.

Uncaught ReferenceError: BMapGL is not defined

react-bmapgl 下载完后,
html 存放<script type="text/javascript" src="//api.map.baidu.com/api?v=2.0&ak=1XjLLEhZhQNUzd93EjU5nOGQ"></script>
statr后 一直报这个错 请问是什么情况呢
1657011841358
1657011866994
1657011886700

Type 'Point' is not assignable to type 'Point & string'.

Type 'Point' is not assignable to type 'Point & string'.
  Type 'Point' is not assignable to type 'string'.  TS2322

     95 |     return (
     96 |         <Map
  >  97 |             center={new BMapGL.Point(116.3, 39.7)}
        |             ^
     98 |             mapStyleV2={{styleJson: mapStyle as BMapGL.MapStyleItem[]}}
     99 |             style={{height: '100%', width: '100%'}}
    100 |             zoom={17}

看了一下Map下面的index

export interface MapProps {
    /** 中心点坐标 */
    center: BMapGL.Point & string;

我改成BMapGL.Point | string,就没报错了

Marker点击切换icon颜色不生效

{markerList.map((item, index) =>
<>
<Marker position={item.position} icon={ currentId === item.id ? 'loc_red' : 'simple_blue'} autoViewport onClick={() => this.iconClick(item)} id={item.id}
onMouseover={() => this.setState({ hoverPosition: item.position })}
/>
遍历渲染页面上的marker,根据currentId改变当前icon颜色,现在currentId数据更新了,可是页面render没有触发

类型文件路径不对

image

package.json中路径是"types": "dist/types/index.d.ts", 实际应该是 types/bmapgl/index.d.ts

vscode报 找不到命名空间BMapGL

Geolocation获取不到定位信息

const geolocation = new BMapGL.Geolocation()
geolocation.getCurrentPosition(result => {
  console.log(result) // null
})

之前项目用JavaScript API v2.0有获取值,但是在BMapGL API中就无效了。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.