项目作者: EsriUK

项目描述 :
A Nearest widget for finding features around a location. The style can be completely changed to match your own site.
高级语言: JavaScript
项目地址: git://github.com/EsriUK/arcgis-dijit-nearest.git
创建时间: 2014-12-04T09:09:52Z
项目社区:https://github.com/EsriUK/arcgis-dijit-nearest

开源协议:Apache License 2.0

下载


arcgis-dijit-nearest Build Status Coverage Status

Features

The Nearest widget provides a list of the nearest features around a location.

The widget is driven by a webmap. You configure the distance that you want to search and the maximum number of features you want to list.
The widget finds all the features in each layer up to these limits that are in the webmap. The information is presented to the end user as a list view with the details of each feature.
The details shown replicate those that are setup in the popup within your webmap.

Quickstart

  1. myWidget = new Nearest({
  2. webmapId: "987654321123456789",
  3. location: new Point("-0.8055515", "51.8003171", new SpatialReference({ wkid: 4326 })),
  4. searchRadius: 50,
  5. maxResults: 5,
  6. display: "expandable",
  7. showOnMap: true,
  8. showCounters: true,
  9. showDistance: true,
  10. showEmptyLayers: true
  11. }, "NearestWidget");
  12. myWidget.startup();

New to Github? Get started here.

Setup

Set your dojo config to load the module.

  1. var package_path = window.location.pathname.substring(0, window.location.pathname.lastIndexOf('/'));
  2. var dojoConfig = {
  3. // The locationPath logic below may look confusing but all its doing is
  4. // enabling us to load the api from a CDN and load local modules from the correct location.
  5. packages: [{
  6. name: "application",
  7. location: package_path + '/js'
  8. }]
  9. };

Require module

Include the module for the Nearest.

  1. require(["application/Nearest", ... ], function(Nearest, ... ){ ... });

Constructor

Nearest(options, srcNode);

Options (Object)

property required type value description
webmapId x string null The id of the webmap that contains the layers to use for the nearest.
location x Point null The location to use for the query.
searchRadius Integer 10 The radius to search within, in miles.
maxResults Integer 5 The number of features to show.
display string ‘expandable’ How to display the results. Expandable or fixed.
showOnMap Boolean true Display the ‘Show On Map’ link.
showCounters Boolean true Show the feature counts.
showDistance Boolean true Show the distance.
showEmptyLayers Boolean true Show layers with no results
findNearestMode String geodesic Set the mode used by the find nearest task.
layerOptions Object Array null Options for each layer. These override the default options per layer in the web map.
distanceUnits x String ‘miles’ What units to display the distances as.

layerOptions

This is an array of objects that contain overridden options per layer. You can override one or all layers in the webmap. Any layers not overridden will use the default options.
You do not have to include all options, just the options you want to override.

Layer Specific Options (Object)

property required type value description
usage x string ‘query’ Allow the layer to be used either for querying or just for display. Values are ‘query’ or ‘display’
  1. layerOptions: [{
  2. itemId: '1234567'
  3. maxResults: 3
  4. searchRadius: 29,
  5. showOnMap: false
  6. showCounters: false
  7. display: 'fixed',
  8. showDistance: false,
  9. usage: 'query'
  10. }, {
  11. ...
  12. }]

Events

The widget publishes events at various stages of its lifecycle.

data-loaded

  1. topic.subscribe("Nearest::data-loaded", function (widget) {});

query-done

  1. topic.subscribe("Nearest::query-done", function (widget, queryResults) {});

nearest-task-done

  1. topic.subscribe("Nearest::nearest-task-done", function (widget, nearestResults) {});

loaded

  1. topic.subscribe("Nearest::loaded", function (widget) {});

show-layer

  1. topic.subscribe("Nearest::show-layer", function (results, layerInfo, expanded) {});

show-feature

  1. topic.subscribe("Nearest::show-feature", function (feature, renderer) {});

show-feature-detail

  1. topic.subscribe("Nearest::show-feature", function (feature, detailsPanelId) {});

Issues

Find a bug or want to request a new feature? Please let us know by submitting an issue.

Support

Use of this widget is covered by Esri UK Developer Support

Contributing

Anyone and everyone is welcome to contribute.

Licensing

Copyright 2015 ESRI (UK) Limited

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

http://www.apache.org/licenses/LICENSE-2.0

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 Licence.

A copy of the license is available in the repository’s license.txt file.