Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add popup options to DynamicMapLayer #1031

Merged
merged 2 commits into from
Dec 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,20 @@ module.exports = function (config) {

// list of files / patterns to load in the browser
// not sure why tests are failing when files are loaded in bulk

files: [
'node_modules/leaflet/dist/leaflet.css',
'node_modules/leaflet/dist/leaflet-src.js',
'dist/esri-leaflet-debug.js',
// these two are the tempermental ones
'spec/Layers/ImageMapLayerSpec.js',
'spec/Layers/DynamicMapLayerSpec.js',
'spec/**/*Spec.js'
'spec/Layers/BasemapLayerSpec.js',
'spec/Layers/TiledMapLayerSpec.js',
'spec/Layers/RasterLayerSpec.js',
// 'spec/Layers/*Spec.js',
'spec/Tasks/*Spec.js',
'spec/Services/*Spec.js',
'spec/*Spec.js'
],

// list of files to exclude
Expand Down
23 changes: 15 additions & 8 deletions src/Layers/DynamicMapLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,26 @@ export var DynamicMapLayer = RasterLayer.extend({
}, this), 300);
}, this);

var identifyRequest = this.identify().on(this._map).at(e.latlng);
var identifyRequest;
if (this.options.popup) {
identifyRequest = this.options.popup.on(this._map).at(e.latlng);
Copy link
Contributor

@jgravois jgravois Dec 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i pushed a small change here to call IdentifyFeatures.on() dynamically even when a custom popup constructor option has been bound to the layer. this is beneficial for two reasons.

  1. it avoids an error when on() wasn't chained prior.
  2. even if the method was chained, it avoids passing a stale extent through in the request if the map was panned or zoomed after the layer was instantiated.

} else {
identifyRequest = this.identify().on(this._map).at(e.latlng);
}

// remove extraneous vertices from response features
identifyRequest.simplify(this._map, 0.5);
// remove extraneous vertices from response features if it has not already been done
identifyRequest.params.maxAllowableOffset ? true : identifyRequest.simplify(this._map, 0.5);

if (this.options.layers) {
identifyRequest.layers('visible:' + this.options.layers.join(','));
} else {
identifyRequest.layers('visible');
if (!(this.options.popup && this.options.popup.params && this.options.popup.params.layers)) {
if (this.options.layers) {
identifyRequest.layers('visible:' + this.options.layers.join(','));
} else {
identifyRequest.layers('visible');
}
}

// if present, pass layer ids and sql filters through to the identify task
if (this.options.layerDefs && typeof this.options.layerDefs !== 'string') {
if (this.options.layerDefs && typeof this.options.layerDefs !== 'string' && !identifyRequest.params.layerDefs) {
for (var id in this.options.layerDefs) {
if (this.options.layerDefs.hasOwnProperty(id)) {
identifyRequest.layerDef(id, this.options.layerDefs[id]);
Expand Down