Esri Leaflet Related Records
Esri Leaflet Related Records is a small API helper to assist querying related tables published in ArcGIS Server or ArcGIS Online
Currently Esri Leaflet Related Records is in development and should be thought of as a beta or preview
Esri Leaflet Related Records relies on the minimal Esri Leaflet Core which handles abstraction for requests and authentication when neccessary. You can find out more about the Esri Leaflet Core on the Esri Leaflet downloads page.
Example
Note that the latest version of this plugin requires changes introduced in esri-leaflet 1.0.0 Release Candidate 5.
Take a look at this sample to see it in action.
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>related table</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<!-- Load Leaflet from CDN-->
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css" />
<script src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script>
<!-- Load Esri Leaflet from CDN -->
<script src="//cdn-geoweb.s3.amazonaws.com/esri-leaflet/1.0.0-rc.5/esri-leaflet.js"></script>
<script src="//cdn-geoweb.s3.amazonaws.com/esri-leaflet-related/0.0.1-beta.1/esri-leaflet-related.min.js"></script>
<style>
body {margin:0;padding:0;}
#map {
position: absolute;
top: 0;
bottom: 0;
right: 0;
left: 0;
}
#info-pane {
position: absolute;
top: 10px;
right: 10px;
z-index: 10;
padding: 1em;
background: white;
}
</style>
</head>
<body>
<div id="map"></div>
<div id="info-pane" class="leaflet-bar">
<label>
click on a bikeshare location <br>to see crowdsourced counts!
</label>
</div>
<script>
var map = L.map('map').setView([34.05873397817502, -117.2031784057617], 14);
L.esri.basemapLayer('Topographic').addTo(map);
var fl = L.esri.featureLayer({
url: '//services.arcgis.com/uCXeTVveQzP4IIcx/ArcGIS/rest/services/stationActivity/FeatureServer/0'
}).addTo(map);
//wire up event listener to fire query when users click on individual features
fl.on("click", queryRelated);
function queryRelated(evt) {
var query = L.esri.Tasks.queryRelated(fl).objectIds([evt.layer.feature.id]).relationshipId("0").run(function(error, response, raw) {
console.log(response.features.length + " related records found.");
})
}
</script>
</body>
</html>
L.esri.Tasks.QueryRelated
Constructor
Extends L.esri.Tasks.Task
Constructor | Options | Description |
---|---|---|
new L.esri.Task.QueryRelated(<FeatureLayer> endpoint) L.esri.Task.queryRelated(<FeatureLayer> endpoint) new L.esri.Task.QueryRelated(<Object> options) L.esri.Task.queryRelated(<Object> options) |
<FeatureLayer> or <Options> |
Accepts either an options object or an instance of FeatureLayer. |
Options
L.esri.Tasks.QueryRelated accepts all L.esri.Tasks.Task options. When used, the url
option is required.
Methods
Method | Returns | Description |
---|---|---|
objectIds(<Array> or <String>) |
this |
The ObjectId(s) of the features to query for related records. |
relationshipId(<String>) |
this |
The Id of the relationship itself. |
fields(<Array> or <String>) |
this |
Determines which fields to include in response. |
returnGeometry(<Boolean>) |
this |
Include geometry in response features (default is true ). |
precision(<Number>) |
this |
Determines decimal precision of response feature geometries. |
definitionExpression(<String>) |
this |
Used to add SQL filter. |
returnZ(<Boolean>) |
this |
Include elevation in response feature geometry (default is true ). |
returnM(<Boolean>) |
this |
Include 4dimensional M value in response feature geometry (default is false ). |
run(<Function> callback) |
this |
Calls the corresponding Geoprocessing service, passing the previously supplied input parameters. |
Result Object
A single result from a call to 'queryRelatedRecords'.
Property | Type | Description |
---|---|---|
features |
[L.geoJson ] |
An array of geoJson features. |
GP Results
Query Related Records results conform to the following format
{ features: [L.geoJson] }
Development Instructions
- Fork and clone Esri Leaflet Related Records
cd
into theesri-leaflet-related
folder- Install the dependencies with
npm install
- The example at
/index.html
should work - Make your changes and create a pull request
Dependencies
Esri Leaflet Related Records relies on the minimal Esri Leaflet Core which handles abstraction for requests and authentication when neccessary. You can fine out more about teh Esri Leaflet Core on the Esri Leaflet downloads page.
Resources
Issues
Find a bug or want to request a new feature? Please let us know by submitting an issue.
Contributing
Esri welcomes contributions from anyone and everyone. Please see our guidelines for contributing.
Terms and Conditions
Signup for an ArcGIS for Developers account or purchase an ArcGIS Online Organizational Subscription.
- Once you have an account you are good to go. Thats it!
- If you use this library in a revenue generating application or for goverment use you must upgrade to a paid account. You are not allowed to generate revenue while on a free plan.
This information is from the ArcGIS for Developers Terms of Use FAQ
Licensing
Copyright 2015 Esri
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
A copy of the license is available in the repository's license.txt file.
[](Esri Tags: ArcGIS Web Mapping Leaflet Geocoding) [](Esri Language: JavaScript)