-
Notifications
You must be signed in to change notification settings - Fork 55
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
Ol v6141 #1513
Ol v6141 #1513
Changes from 6 commits
4829f06
eb3c32b
7e2f9ed
5b55973
9c3d1b9
ca0e96f
bcf7808
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -135,31 +135,6 @@ function getAGSIdentifyUrl({ layer, coordinate }, viewer) { | |
}).catch(error => console.error(error)); | ||
} | ||
|
||
function isTainted({ | ||
pixel, | ||
layerFilter, | ||
map | ||
}) { | ||
try { | ||
if (layerFilter) { | ||
map.forEachLayerAtPixel(pixel, (layer) => layerFilter === layer); | ||
} | ||
|
||
return false; | ||
} catch (e) { | ||
console.error(e); | ||
return true; | ||
} | ||
} | ||
|
||
function layerAtPixel({ | ||
pixel, | ||
matchLayer, | ||
map | ||
}) { | ||
map.forEachLayerAtPixel(pixel, (layer) => matchLayer === layer); | ||
} | ||
|
||
function getGetFeatureInfoRequest({ layer, coordinate }, viewer) { | ||
const layerType = layer.get('type'); | ||
const obj = {}; | ||
|
@@ -201,48 +176,17 @@ function getGetFeatureInfoRequest({ layer, coordinate }, viewer) { | |
|
||
function getFeatureInfoRequests({ | ||
coordinate, | ||
layers, | ||
map, | ||
pixel | ||
}, viewer) { | ||
const requests = []; | ||
// Check for support of crossOrigin in image, absent in IE 8 and 9 | ||
if ('crossOrigin' in new (Image)()) { | ||
map.forEachLayerAtPixel(pixel, (layer) => { | ||
if (layer.get('queryable')) { | ||
const item = getGetFeatureInfoRequest({ layer, coordinate }, viewer); | ||
if (item) { | ||
requests.push(item); | ||
} | ||
viewer.getQueryableLayers().forEach(layer => { | ||
if (layer.getData(pixel) instanceof Uint8ClampedArray && layer.getData(pixel)[3] > 0) { | ||
const item = getGetFeatureInfoRequest({ layer, coordinate }, viewer); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Little risky here. getData exists on all layer types, but is only documented on ImageLayer and BaseTileLayer. Calling it on a feature layer is harmless now (it returns null), but as it is not documented it could break. Also calling getData two times is painful on my eyes, but it will not have any greater impact on performance. |
||
if (item) { | ||
requests.push(item); | ||
} | ||
}); | ||
} else if (isTainted({ map, pixel })) { // If canvas is tainted | ||
layers.forEach((layer) => { | ||
if (layer.get('queryable')) { | ||
// If layer is tainted, then create request for layer | ||
if (isTainted({ pixel, layer, map })) { | ||
const item = getGetFeatureInfoRequest({ layer, coordinate }, viewer); | ||
if (item) { | ||
requests.push(item); | ||
} | ||
} else if (layerAtPixel({ pixel, layer, map })) { // If layer is not tainted, test if layer hit at pixel | ||
const item = getGetFeatureInfoRequest({ layer, coordinate }, viewer); | ||
if (item) { | ||
requests.push(item); | ||
} | ||
} | ||
} | ||
}); | ||
} else { // If crossOrigin is not supported and canvas not tainted | ||
map.forEachLayerAtPixel(pixel, (layer) => { | ||
if (layer.get('queryable') === true) { | ||
const item = getGetFeatureInfoRequest({ layer, coordinate }, viewer); | ||
if (item) { | ||
requests.push(item); | ||
} | ||
} | ||
}); | ||
} | ||
} | ||
}); | ||
return requests; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If renderMode is "image" for a WMS layer test will fail. Don't know why anyone would not tile an image layer, but it should test for ImageLayer as well and possibly test for BaseTileLayer instead of TileLayer. Apparently getData actually exists on all layers, but documentation states it only exist on ImageLayer and BaseTileLayer so checking for its existance is useless.