Skip to content

Commit

Permalink
Merge pull request Esri#921 from jgravois/patch919
Browse files Browse the repository at this point in the history
reverse simplification scale and ensure bindPopup simplifies output geometry
  • Loading branch information
jgravois committed Feb 7, 2017
2 parents 86b77cc + e6a0aa0 commit 03f96d1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions spec/Layers/DynamicMapLayerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ describe('L.esri.DynamicMapLayer', function () {
});

it('should bind a popup to the layer', function () {
server.respondWith('GET', new RegExp(/http:\/\/services.arcgis.com\/mock\/arcgis\/rest\/services\/MockMapService\/MapServer\/identify\?sr=4326&layers=visible&tolerance=3&returnGeometry=true&imageDisplay=500%2C500%2C96&mapExtent=-?\d+\.\d+%2C-?\d+\.\d+%2C-?\d+\.\d+%2C-?\d+\.\d+&geometry=-?\d+\.\d+%2C-?\d+\.\d+&geometryType=esriGeometryPoint&f=json/), JSON.stringify(sampleResponse));
server.respondWith('GET', new RegExp(/http:\/\/services.arcgis.com\/mock\/arcgis\/rest\/services\/MockMapService\/MapServer\/identify\?sr=4326&layers=visible&tolerance=3&returnGeometry=true&imageDisplay=500%2C500%2C96&mapExtent=-?\d+\.\d+%2C-?\d+\.\d+%2C-?\d+\.\d+%2C-?\d+\.\d+&geometry=-?\d+\.\d+%2C-?\d+\.\d+&geometryType=esriGeometryPoint&maxAllowableOffset=0.000171661376953125&f=json/), JSON.stringify(sampleResponse));

layer.bindPopup(function (error, featureCollection) {
return featureCollection.features.length + ' Feature(s)';
Expand All @@ -395,7 +395,7 @@ describe('L.esri.DynamicMapLayer', function () {
});

it('should bind a popup to the layer if the layer is already on a map', function () {
server.respondWith('GET', new RegExp(/http:\/\/services.arcgis.com\/mock\/arcgis\/rest\/services\/MockMapService\/MapServer\/identify\?sr=4326&layers=visible&tolerance=3&returnGeometry=true&imageDisplay=500%2C500%2C96&mapExtent=-?\d+\.\d+%2C-?\d+\.\d+%2C-?\d+\.\d+%2C-?\d+\.\d+&geometry=-?\d+\.\d+%2C-?\d+\.\d+&geometryType=esriGeometryPoint&f=json/), JSON.stringify(sampleResponse));
server.respondWith('GET', new RegExp(/http:\/\/services.arcgis.com\/mock\/arcgis\/rest\/services\/MockMapService\/MapServer\/identify\?sr=4326&layers=visible&tolerance=3&returnGeometry=true&imageDisplay=500%2C500%2C96&mapExtent=-?\d+\.\d+%2C-?\d+\.\d+%2C-?\d+\.\d+%2C-?\d+\.\d+&geometry=-?\d+\.\d+%2C-?\d+\.\d+&geometryType=esriGeometryPoint&maxAllowableOffset=0.000171661376953125&f=json/), JSON.stringify(sampleResponse));

layer.addTo(map);

Expand Down
3 changes: 3 additions & 0 deletions src/Layers/DynamicMapLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ export var DynamicMapLayer = RasterLayer.extend({

var identifyRequest = this.identify().on(this._map).at(e.latlng);

// remove extraneous vertices from response features
identifyRequest.simplify(this._map, 0.5);

if (this.options.layers) {
identifyRequest.layers('visible:' + this.options.layers.join(','));
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/Tasks/IdentifyFeatures.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export var IdentifyFeatures = Identify.extend({

simplify: function (map, factor) {
var mapWidth = Math.abs(map.getBounds().getWest() - map.getBounds().getEast());
this.params.maxAllowableOffset = (mapWidth / map.getSize().y) * (1 - factor);
this.params.maxAllowableOffset = (mapWidth / map.getSize().y) * factor;
return this;
},

Expand Down

0 comments on commit 03f96d1

Please sign in to comment.