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 🙏

© 2025 – Pkg Stats / Ryan Hefner

jfamap-wrapper

v1.0.11

Published

a wrapper of amapui for react-amap

Downloads

21

Readme

jfamap-wrapper (源自react-amapui-wrapper)

一个令人兴奋的消息,react-amap 可以在内部load amapui 了,这样就可以不用我自己写的apiloader了.

  • 新增自定义图标

简介

react-amapui-wrapper 是一个基于 react-amap 封装的高德地图组件;主要是用于处理 react-amap 的 AMapUI 的部分。


如何使用

import React,{ Component } from 'react'
import ReactDOM from 'react-dom'
import { Map as Amap } from 'react-amap'
import { Wrapper, DistrictExplorer } from 'jfamap-wrapper'

class MapUIComponent extends Component {
  render() {
    const useAMapUI = true
    return (
    <div style={{ width:'600px', height:'400px' }}>
      <Amap useAMapUI = {useAMapUI}>
        <Wrapper>
          <DistrictExplorer
            events = {{}}
            initialAdcode={100000}
            eventSupport = {true}
            instanceName = {'DistrictExplorer'}
          />
        </Wrapper>
      </Amap>
     </div> 
    )
  }
}

ReactDOM.render(
  <MapUIComponent/>,
  document.querySelector('#app')
)

需要注意的是:引入AmapUi需要输入useAmapUi的参数,如上,否则会在控制台中出现import AmapUi plz...的console


如何自定义各个组件的初始化样式

可以使用组件的默认初始,也可以自定义组件的初始化样式


import React,{ Component } from 'react'
import { SimpleMarker } from 'jfamap-wrapper'

class newMarker extends SimpleMarker {

  initPage(InstanceInit) {
    this[this.instanceName] = new InstanceInit({
      //前景文字
      iconLabel: 'circleMar',
      //背景图标样式
      iconStyle: '<div className="circleMar"></div>',
      containerClassNames: 'circleMar',
      //...其他Marker选项...,不包括content
      map: this.map,
      position: [116.405285, 39.904989]
    })
  }

}

其中initPage方法为初始化的方法,InstanceInit为实例的初始化方法,具体初始化方式需要参照官方文档高德地图UI组件库


相关配置项

  1. eventSupport为事件支持,true为支持事件,false为不支持,默认为false

  2. events为事件配置项,事件绑定方式与react-amap中绑定方式相同

  3. instanceName为从高德地图中load的地图元素,具体填入内容参照高德地图AMapUI。


如何自定义AMapUI组件

import React,{ Component } from 'react'
import { Base } from 'jfamap-wrapper'

// 自定义组件, 此为自定义DistrictExplorer的过程
class newCp extends Base {

// initialInstance 用于初始化组件, 可自定义如何初始化组件
  initialInstance() {
    const { eventSupport=false } = this.props
    if (this[this.instanceName]) {
      return new Promise((resolve) => {
        resolve(this[this.instanceName])
      })
    } else {
      return new Promise((resolve) => {
        this.amapui.load(['ui/geo/DistrictExplorer'], (DistrictExplorer) => {

          this[this.instanceName] = new DistrictExplorer({
            eventSupport: eventSupport,
            map: this.map //关联的地图实例
          })
          const events = this.exposeInstance(this.props)
          events && this.bindEvents(events)
          this.initPage()
          resolve(this[this.instanceName])
        })
      })
    }
  }
export default newCp

todo

  • [ ] 1. 将组件的继承方式改成通过hoc继承
  • [ ] 2. 为各个组件添加static props和dynamic props