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

@lbh7/react-amap-api-loader

v1.0.7

Published

用于加载高德地图 SDK 依赖,加载完成,全局将会有 **`window.AMap`** 对象。

Downloads

11

Readme

APILoader

Buy me a coffee npm version Downloads

用于加载高德地图 SDK 依赖,加载完成,全局将会有 window.AMap 对象。

import { APILoader } from '@lbh7/react-amap';
// 或者单独安装使用
import { APILoader } from '@lbh7/react-amap-api-loader';

~~v4~~ 升级到 v5APILoader 主要是对 APILoader 做了升级

<APILoader
-  akay
-  protocol
-  hostAndPath
-  callbackName
-  plugin
-  disableScripts
+  akey
+  plugins
+  AMapUI
+  Loca
>
  <Map style={{ height: 100 }} />
</APILoader>

基本用法

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

import React from 'react';
import { Map, APILoader } from '@lbh7/react-amap';

const Demo = () => (
  <APILoader aakey="a7a90e05a37d3f6bf76d4a9032fc9129">
    <Map style={{ height: 300 }}/>
  </APILoader>
);

export default Demo

多个地图

import React from 'react';
import ReactDOM from 'react-dom';
import { Map, APILoader } from '@lbh7/react-amap';

const Demo = () => (
  <APILoader akey="a7a90e05a37d3f6bf76d4a9032fc9129">
    <Map style={{ height: 100, marginBottom: 10 }} />
    <div style={{ border: '1px solid red' }}>
      <Map style={{ height: 100 }} />
    </div>
  </APILoader>
);

export default Demo

Props

| 参数 | 说明 | 类型 | 默认值 | |--------- |-------- |--------- |-------- | | version | SDK 版本 | string | 2.0 | | ~~akay~~ => akey | 必填 disableScripts=true选填 您需先申请密钥(ak)才可使用该服务。⚠️ 注意申请 Web端(JS API) | string | - | | ~~protocol~~ | 协议,默认是根据当前网站协议的 | http/https | window.location.protocol | | ~~hostAndPath~~ | 请求 SDK 的前半部分 | string | webapi.amap.com/maps | | ~~callbackName~~ | 回调函数 | string | load_amap_sdk | | ~~plugin~~ | 加载一个或者多个插件 AMap.ToolBar,AMap.Driving | string | - | | ~~disableScripts~~ | 禁用 SDK 加载 | boolean | - |

import { PropsWithChildren } from 'react';
export type APILoaderConfig = PropsWithChildren<{
  /**
   * key 密钥
   * 您需先[申请密钥(ak)](https://lbs.amap.com/dev/key/app)。开发文档说明地址:https://lbs.amap.com/api/javascript-api/guide/abc/prepare
   *
   * 1. 首先,[注册开发者账号](https://lbs.amap.com/dev/id/newuser),成为高德开放平台开发者
   * 2. 登陆之后,在进入「应用管理」 页面「创建新应用」
   * 3. 为应用[添加 Key](https://lbs.amap.com/dev/key/app),「服务平台」一项请选择「 Web 端 ( JSAPI ) 」
   *
   */
  akey?: string;
  /**
   * SDK 包版本,指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
   * @default 1.4.15
   */
  version?: string;
  /**
   * 加载一个或者多个插件
   * @example `['AMap.ToolBar', 'AMap.Driving']`
   */
  plugins?: string[];
  /** 是否加载 AMapUI,缺省不加载 */
  AMapUI?: {
    /** AMapUI 缺省 1.1 */
    version?: string;
    /** 需要加载的 AMapUI ui插件 */
    plugins?: string[];
  };
  /** 是否加载 Loca, 缺省不加载 */
  Loca?: {
    /** Loca 版本,缺省 1.3.2 */
    version?: string;
  };
}>;
export interface APILoaderProps extends APILoaderConfig { }