Skip to content

Commit

Permalink
Merge pull request #217 from patrickarlt/master
Browse files Browse the repository at this point in the history
Beta 4
  • Loading branch information
patrickarlt committed Feb 25, 2014
2 parents cd0ca3e + 7792aca commit 75da0e6
Show file tree
Hide file tree
Showing 62 changed files with 2,136 additions and 448 deletions.
11 changes: 9 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ module.exports = function(grunt) {
cluster: {
src: ["src/Layers/ClusteredFeatureLayer.js"],
dest: 'dist/extras/clustered-feature-layer-src.js'
},
heat: {
src: ["src/Layers/HeatMapFeatureLayer.js"],
dest: 'dist/extras/heatmap-feature-layer-src.js'
}
},
uglify: {
Expand All @@ -76,11 +80,14 @@ module.exports = function(grunt) {
'dist/esri-leaflet.js': [
"dist/esri-leaflet-src.js"
],
'dist/extras/esri-basemaps.js': [
'dist/extras/esri-basemaps-src.js'
],
'dist/extras/clustered-feature-layer.js': [
'dist/extras/clustered-feature-layer-src.js'
],
'dist/extras/esri-basemaps.js': [
'dist/extras/esri-basemaps-src.js'
'dist/extras/heatmap-feature-layer.js': [
'dist/extras/heatmap-feature-layer-src.js'
]
}
}
Expand Down
76 changes: 64 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Leaflet plugin for [ArcGIS Services](http://developers.arcgis.com). Currently Esri Leaflet supports loading Esri [basemaps](#basemaplayer) and [feature services](#featurelayer), as well as [tiled](#tiledmaplayer) and [dynamic](#dynamicmaplayer) map services.

The goal of Esri Leaflet is **not** to replace the [ArcGIS API for JavaScript](https://developers.arcgis.com/en/javascript/), but rather to provide small components to allow developers to build mapping applications with Leaflet. It pairs well with [Terraformer](https://github.com/Esri/Terraformer) for converting data and [geoservices-js](https://github.com/Esri/geoservices-js) for making advanced request to [ArcGIS REST services](http://resources.arcgis.com/en/help/arcgis-rest-api/#/The_ArcGIS_REST_API/02r300000054000000/), for example place finding and reverse geocoding.
The goal of Esri Leaflet is **not** to replace the [ArcGIS API for JavaScript](https://developers.arcgis.com/en/javascript/), but rather to provide small components to allow developers to build mapping applications with Leaflet.

**Currently Esri Leaflet is in development and should be thought of as a beta or preview.**

Expand Down Expand Up @@ -88,6 +88,10 @@ Constructor | Description

`L.esri.BasemapLayer`inherits all events from [`L.TileLayer`](http://leafletjs.com/reference.html#tilelayer).

Event | Data | Description
--- | --- | ---
`metadata` | [`Metadata`](#metadata-event) | After creating a new `L.esri.ClusteredFeatureLayer` a request for data describing the service will be made and passed to the metadata event.

#### Example

```js
Expand All @@ -112,6 +116,8 @@ Constructor | Description

Option | Type | Default | Description
--- | --- | --- | ---
`where` | `String` | `"1=1"` | A server side expression that will be evaluated to filter features. By default this will include all features in a service.
`fields` | `Array` | `["*"]` | An array of metadata names to pull from the service. Includes all fields by default.
`token` | `String` | `null` | If you pass a token in your options it will included in all requests to the service. See [working with authenticated services](#working-with-authenticated-services) for more information.

#### Events
Expand Down Expand Up @@ -246,6 +252,8 @@ Option | Type | Default | Description
`cluster` | `L.MarkerClusterGroup` | `new L.MarkerClusterGroup()` | The instance of `L.MarkerClusterGroup` that points will be added to.
`createMarker` | `Function` | `null` | A function that will be called with a GeoJSON representation of the point its latitude and longitude. Should return a `L.Marker` object.
`onEachMarker` | Function | `null` | This function will be called for every marker before it is added to the cluster. It is called with the GeoJSON representation of the point and the marker
`where` | `String` | `"1=1"` | A server side expression that will be evaluated to filter features. By default this will include all features in a service.
`fields` | `Array` | `["*"]` | An array of metadata names to pull from the service. Includes all fields by default.
`token` | `String` | `null` | If you pass a token in your options it will included in all requests to the service. See [working with authenticated services](#working-with-authenticated-services) for more information.

#### Events
Expand Down Expand Up @@ -286,14 +294,65 @@ L.esri.clusteredFeatureLayer("http://services.arcgis.com/rOo16HdIMeOBI4Mb/arcgis
}).addTo(map);
```

### HeatMapFeatureLayer

**Extends** `L.Class`

`L.esri.HeatMapFeatureLayer` provides integration for Feature Layers with the [Leaflet.heat plugin](https://github.com/Leaflet/Leaflet.heat). Because of the extra Dependency on Leaflet.heat we do not include `L.esri.HeatMapFeatureLayer` in the default build of Esri Leaflet. It lives in /dist/extras/heatmap-feature-layer.js. You will also need to include your own copy of the [Leaflet.heat plugin](https://github.com/Leaflet/Leaflet.heat).

#### Constructor

Constructor | Description
--- | ---
`new L.esri.HeatMapFeatureLayer(url, options)`<br>`L.esri.heatMapFeatureLayer(url, options)` | `url` should be the URL of the feature layer to consume. See [service URLs](#service-urls) for more information on how to find these urls.

#### Options

`HeatMapFeatureLayer` will also accept any options that can be passed to [Leaflet.heat](https://github.com/Leaflet/Leaflet.heat#lheatlayerlatlngs-options) to customize the appearance of the heatmap.

Option | Type | Default | Description
--- | --- | --- | ---
`where` | `String` | `"1=1"` | A server side expression that will be evaluated to filter features. By default this will include all features in a service.
`fields` | `Array` | `["*"]` | An array of metadata names to pull from the service. Includes all fields by default.
`token` | `String` | `null` | If you pass a token in your options it will included in all requests to the service. See [working with authenticated services](#working-with-authenticated-services) for more information.

#### Events

Event | Data | Description
--- | --- | ---
`loading` | [`Loading`](#loading-event) | Fires when new features start loading.
`load` | [`Load`](#load-event) | Fires when all features in the current bounds of the map have loaded.
`metadata` | [`Metadata`](#metadata-event) | After creating a new `L.esri.ClusteredFeatureLayer` a request for data describing the service will be made and passed to the metadata event.
`authenticationrequired` | [`Authentication`](#authentication-event) | This will be fired when a request to a service fails and requires authentication. See [working with authenticated services](#working-with-authenticated-services) for more information.

#### Example

```js
var heat = new L.esri.HeatMapFeatureLayer("http://services.arcgis.com/rOo16HdIMeOBI4Mb/arcgis/rest/services/Graffiti_Locations3/FeatureServer/0", {
radius: 12,
gradient: {
0.4: "#ffeda0",
0.65: "#feb24c",
1: "#f03b20"
}
}).addTo(map);
```

### Event Objects

#### Metadata Event

The data included in the `metadata` event will vary depending on type of layer you are adding to the map.

Data | Value | Description
--- | --- | ---
`bounds` | [`LatLngBounds`](http://leafletjs.com/reference.html#latlngbounds) | The bounds that features are currently being loaded.
`metadata` | `Object` | The JSON metadata for the service. See below.

* `DynamicMapLayer` and `TiledMapLayer` will return the [JSON Definition of a Map Service](http://resources.arcgis.com/en/help/arcgis-rest-api/#/Map_Service/02r3000000w2000000/)
* `FeatureLayer` and `ClusteredFeatureLayer` will return the [JSON Definition of a Feature Layer](http://resources.arcgis.com/en/help/arcgis-rest-api/#/Layer/02r3000000w6000000/)
* `FeatureLayer`, `ClusteredFeatureLayer` and `HeatMapFeatureLayer` will return the [JSON Definition of a Feature Layer](http://resources.arcgis.com/en/help/arcgis-rest-api/#/Layer/02r3000000w6000000/)

**Note**: the bounds property will be `false` if the service in a spatial reference other then 4326, 3857 or 102100.

#### Loading Event

Expand Down Expand Up @@ -347,8 +406,8 @@ Esri Leaflet supports access private services on ArcGIS Online and ArcGIS Server

Handing authentication in Esri Leaflet is flexible and lightweight but makes serveral assumptions.

1. You (the developer) will handler obtaining and persisting access tokens.
2. Esri Leaflet will use your tokens so access services.
1. You (the developer) will handle obtaining and persisting tokens.
2. Esri Leaflet will use your tokens to access services.
3. Esri Leaflet will notify you when it recives an error while using your token and prompt you for a new one.

An example of authenticating with a username/password to an ArcGIS Service instance can be found [here](http://esri.github.io/esri-leaflet/privatemapservice.html).
Expand All @@ -359,25 +418,18 @@ An example of using Oauth 2 to access a private feature service on ArcGIS Online

1. [Fork and clone Esri Leaflet](https://help.github.com/articles/fork-a-repo)
2. `cd` into the `esri-leaflet` folder
4. Run `git submodule init` and `git submodule update`
5. Instal the dependancies with `npm install`
5. Install the dependancies with `npm install`
5. The examples in the `/examples` folder should work
6. Make your changes and create a [pull request](https://help.github.com/articles/creating-a-pull-request)

### Dependencies
* [Leaflet](http://leaflet.com) - the core Leaflet library
* [Leaflet.markercluster](http://leaflet.com) - If you want to use `L.esri.ClusteredFeatureLayer` you will need the Leaflet markercluster plugin
* [Terraformer](https://github.com/esri/Terraformer) - base library for other dependencies
* [Terraformer ArcGIS](https://github.com/esri/Terraformer) - for converting geometries
* [Terraformer RTree](https://github.com/esri/Terraformer) - client side RTree index for optimizations

These are currently included in `/vendor` as submodules and are built into the `dist/esri-leaflet.js` file.

## Resources

* [ArcGIS for Developers](http://developers.arcgis.com)
* [ArcGIS REST Services](http://resources.arcgis.com/en/help/arcgis-rest-api/)
* [ArcGIS for JavaScript API Resource Center](http://help.arcgis.com/en/webapi/javascript/arcgis/index.html)
* [twitter@esri](http://twitter.com/esri)

## Issues
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "esri-leaflet",
"version": "0.0.1-rc.2",
"version": "0.0.1-beta.4",
"main": "dist/esri-leaflet.js",
"ignore": [
"**/.*",
Expand Down
Loading

0 comments on commit 75da0e6

Please sign in to comment.