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

arc-node

v0.4.5

Published

Node module to work with ArcGIS Online and ArcGIS Server

Downloads

14

Readme

ArcNode

Node module to work with ArcGIS Online and ArcGIS Server.

How to install it

Just write this in your prompt: npm install --save arc-node

And you are ready to go, just instantiate the object like this:

var ArcNode = require('arc-node'),
    service = new ArcNode(<config object>);

Check here the description of the <config object> parameter.

Documentation

When you have instantiate the service you will have available methods to:

Get a new token

Description: Gets a new valid token. Return: a deferred object. When it's resolved: it returns the ArcGIS REST API response. Example: See full example

How to use it

//Get a token valid for 60 minutes
service.getToken({
    expiration: 60
}).then(function(response){
    console.log("response: ", response);
});

Check if a feature service exists

Description: Check if a feature service with a given name exists. Return: a deferred object. When it's resolved: it returns the ArcGIS REST API response. Example: See full example

How to use it

service.checkIfFSExists( { serviceName: "Service name" } ).then(function(response){
  console.log("response = ", response);
}, function(e){
  console.log("Error: ", e);
});

Create an empty feature service

Description: it creates a feature service with no layers in it Return: a deferred object. When it's resolved: it returns the ArcGIS REST API response. Example: See full example

How to use it

service.createFeatureService({name: "My empty feature service"}).then(function(response){
  console.log("response = ", response);
}, function(e){
  console.log("Error: ", e);
});

Add layers to a feature service

Description: it add layers to a service based on the definition of each layer. Return: a deferred object. When it's resolved: it returns the ArcGIS API REST response. Example: See full example

How to use it

service.addLayersToFS({
  service: response.encodedServiceURL,
  layers: [layer]
}).then(function(response){
  console.log("response: ", response);
}, function(e){
  console.log("Error: ", e);
});

Add features to a layer

Description: add features to a feature layer Return: a deferred object. When it's resolved: it return de ArcGIS API REST response. Example: See full example

How to use it

var data = [{
    "attributes":{
        "name": "Feature name"
    },
    "geometry": {
        "x": -3,
        "y": 40,
        "spatialReference": {"wkid" : 4326}
    }
  }
  // Add as many features as you want
];

service.addFeatures({
    serviceName: "Your service name",
    layer: 0, //<layer index, Ex: 0, 1, 2, ...>
    features: data
}).then(function(response){
    console.log("response = ", response);
},function(e){
    console.log("Error: ", e);
});

Find address candidates

Description: find xy locations for an address Return: a deferred object. When it's resolved: it return de ArcGIS API REST response. Example: See full example

How to use it

service.findAddressCandidates({
    address: "Emilio muñoz 35, madrid"
}).then(function(response){
    console.log("response: ", JSON.stringify(response, null, "\t"));
});

Export a webmap

Description: generate a static image from a webmap object Return: a deferred object. When it's resolved: it return de ArcGIS API REST response. Example: See full example

How to use it

var webmap = ArcJSON.exportableWebmap({
    "mapOptions": {
        "extent": {
            "xmin": -422228.3214312691,
            "ymin": 4921137.768125086,
            "xmax": -396125.07627191657,
            "ymax": 4928896.126496022
        }
    },
    "operationalLayers": [
        {
            "opacity": 1,
            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer"
        }
    ],
    "exportOptions": {
        "outputSize": [
            600,
            300
        ],
        "dpi": 192
    }
});

service.ExportWebMapTask({
    webmap: webmap
}).then(function(response){
    console.log("response: ", JSON.stringify(response, null, "\t"));
});