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

react-amap-sdk

v1.0.3

Published

>

Downloads

6

Readme

react-amap-sdk

NPM JavaScript Style Guide

安装

npm install --save react-amap-sdk

基础使用

import React, { Component } from 'react'

import { Map, Marker } from 'react-amap-sdk'

class Example extends Component {
  render () {
    return (
      <Map
        mapKey='您的高德地图key'
        version='1.4.8'
        plugin={this.plugin}
        width={300}
        height={300}
        center={center}
      >
        <Marker
          icon={icon}
          position={position}
          onClick={e => {
            console.log('我被点击了', e.target)
          }}
        />
      </Map>
    )
  }
}

Map组件加载

Map组件支持自动创建script去加载高德sdk和直接在网页中引入script脚本。如果在Map中加载组件需要三个参数代码如下:

// 自动加载高德sdk
<Map
  mapKey='您的高德地图key'
  version='1.4.8'
  plugin={this.plugin}
/>

其中mapKeyversion为必选,plugin为可选它是您要加载高德地图的扩展插件。mapKey为您在高德地图中申请的key

手动在html中插入scirpt引入高德sdk,并且在Map组件中使用customeLoad属性即可

<Map
  customeLoad
/>

属性映射

所有的属性都和高德地图的属性一一对应,使用时直接使用高德地图对应的属性即可。除了事件和少数扩展属性和高德地图不同之外。这里拿Marker组件来进行演示代码如下:

<Map
  customeLoad
>
  <Marker
    icon={icon}
    position={markerPosition}
    offset={markerOffset}
    angle={angle}
    title='我是鼠标滑过的提示文字'
    draggable={true}
    clickable={clickable}
    extData={this.extData}
    onClick={e => {
      console.log('我被点击了', e.target.getExtData())
    }}
  />
</Map>

在上面Marker组件的属性中,除了onClick之外,其余的属性都是保持和高德地图一致,目的在于简化使用和记忆。

注:对于事件保持了和react官方一致的命名方法

扩展功能

所有的组件都有两个和扩展相关的事件:onCreateonDestroyonCreate在创建完高德地图的对象时调用,onDestroy在React组件被销毁时调用。

如果需要一些更个性化的定制,可以使用onCreate去获得到高德地图对应的对象实例。然后即可调用高德地图原生sdk的方法从而进行更个性化的定制。

更多演示

暂时请看/example/src/demo/下面的示例文件

组件列表

  • Map

  • Marker

  • Polyline

  • Polygon

  • Rectangle

  • Circle

  • PolyEditor

  • InfoWindow

License

MIT © monsterooo