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

esri-import

v2.1.7

Published

基于注解的ArcGIS For JavaScript 模块加载器。

Downloads

9

Readme

esri-import

基于注解的ArcGIS For JavaScript 模块加载器。

#安装

$ npm install esri-import --save

使用

Map.js

import React,{Component} from 'react';
import {importEsri, awaitEsri} from 'esri-import';
//指定ArcGIS For JavaScript 的入口,系统中只需指定一次,默认为:https://js.arcgis.com/4.8/。
importEsri.libraryRoot = "http://localhost:8080/arcgis_js_api/library/4.8/init.js";

@importEsri([
    'esri/Map',
    "esri/Color",
    "esri/views/MapView",
    "esri/layers/TileLayer",
    "esri/geometry/Polyline",
    "esri/Graphic",
    "esri/layers/GraphicsLayer",
    "esri/layers/MapImageLayer"])
export default class Map extends Component{
    @awaitEsri
    componentDidMount() {
        
        let esri = Map.esri;
        this.map = new esri.Map({
            basemap:'streets-night-vector'
        });

        let view = new esri.MapView({
            center:[119.297999,26.074068],
            map: this.map,
            zoom: 8,
            popup: {
                dockEnabled: true,
                dockOptions: {
                    position: 'bottom-left'
                }
            },
            container: this.mapContainer
        });
    };

    @awaitEsri
    componentWillReceiveProps(nextProps){
        //这里可以更新地图
    }

    //一般地图组件不要让它重新渲染
    shouldComponentUpdate(){
        return false;
    }
    render(){
        return <div ref={node => this.mapContainer = node}/>
    }
}

首先为importEsri指定了ArcGIS For JavaScript 的入口,也可以不指定,默认为https://js.arcgis.com/4.8/。 importEsri接收一个数组,用来来注解一个类,它会为该类添加一个静态属性esri。该静态属性中包含了你所导入的esri JavaScript模块,支持继承,父类加载的esri模块会植入子类的esri模块。

当要使用这些导入的模块时,最好为相应的方法添加@awaitEsri注解,它可以确保你所注解的方法在模块完全加载完成才执行,但是要知道,添加了该注解后,你的方法的返回值就变成了Promise,如果你的方法有返回值,则须通过promisethen方法来获取。

如果好用,可以star下 :clap: :clap: :clap: