npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@uiw/react-baidu-map-api-loader

v2.7.1

Published

Baidu Map api-loader Components for React.

Downloads

8,545

Readme

APILoader

Buy me a coffee npm version Downloads

用于加载百度地图 SDK 依赖,加载完成,全局将会有 window.BMap 对象。

  • [x] 自动加载百度地图 SDK 依赖
  • [x] 避免重复加载 SDK 依赖
import { APILoader } from '@uiw/react-baidu-map';
// 或者单独安装使用
import APILoader from '@uiw/react-baidu-map-api-loader';

基本用法

Map 的父组件必须具有宽度和高度;

🚧 注意:如果你不使用 APILoader 组件,需要手动将 SDK 引入到 HTML 中。

<script
  type="text/javascript"
  src="http://api.map.baidu.com/api?v=3.0&ak=eYpCTECSntZmw0WyoQ7zFpCRR9cpgHFG&callback=load_bmap_sdk"
>
</script>
import React from 'react';
import { Map, APILoader } from '@uiw/react-baidu-map';

const Demo = () => (
  <div style={{ width: '100%' }}>
    <APILoader akay="eYpCTECSntZmw0WyoQ7zFpCRR9cpgHFG">
      <Map autoLocalCity style={{ height: 350 }} />
    </APILoader>
  </div>
);

export default Demo;

禁用 SDK 加载

收到一个需求,希望自己在 html 中引入 SDK,不需要自动加载,可以使用 disableScripts 禁用,在 html 中自己手动添加

<APILoader disableScripts>
  <Map style={{ height: 100, marginBottom: 10 }} />
</APILoader>
<script type="text/javascript" src="//api.map.baidu.com/api?v=2.0&ak=您的密钥"></script>

Props

| 参数 | 说明 | 类型 | 默认值 | |--------- |-------- |--------- |-------- | | akay | 必填 disableScripts=true选填 您需先申请密钥(ak)才可使用该服务,接口无使用次数限制,请开发者放心使用。 | string | - | | version | SDK 版本 | string | 3.0 | | protocol | 协议,默认是根据当前网站协议的 | http/https | window.location.protocol | | hostAndPath | 请求 SDK 的前半部分 | string | api.map.baidu.com/api | | type | 可选使用百度的 webgl 地图 | webgl | - | | disableScripts | 禁用 SDK 加载 | boolean | - |