OpenLayers Interaction - events are returning wrong features Planned maintenance scheduled...
How to ask rejected full-time candidates to apply to teach individual courses?
French equivalents of おしゃれは足元から (Every good outfit starts with the shoes)
How to achieve cat-like agility?
Besides transaction validation, are there any other uses of the Script language in Bitcoin
My mentor says to set image to Fine instead of RAW — how is this different from JPG?
Is a copyright notice with a non-existent name be invalid?
Is the time—manner—place ordering of adverbials an oversimplification?
Inverse square law not accurate for non-point masses?
How do Java 8 default methods hеlp with lambdas?
In musical terms, what properties are varied by the human voice to produce different words / syllables?
Statistical analysis applied to methods coming out of Machine Learning
What was the last profitable war?
What are some likely causes to domain member PC losing contact to domain controller?
When does a function NOT have an antiderivative?
Is there a verb for listening stealthily?
How can I prevent/balance waiting and turtling as a response to cooldown mechanics
Why do C and C++ allow the expression (int) + 4*5;
Can two people see the same photon?
How does TikZ render an arc?
Any stored/leased 737s that could substitute for grounded MAXs?
Diophantine equation 3^a+1=3^b+5^c
Did John Wesley plagiarize Matthew Henry...?
Is this Kuo-toa homebrew race balanced?
Was the pager message from Nick Fury to Captain Marvel unnecessary?
OpenLayers Interaction - events are returning wrong features
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?Where is the drawn feature when the drawend is triggered in OL3How to get the fill value of a style when using a styleFunction?How to get the geometry type of a WFS vector layer in OpenLayers 3?OpenLayers 3: getting rid of 'blue dot' selection iconPolygon not drawn in OpenLayers 3?Use map.on Click for different events (edit Drawing, Popup) on Openlayers mapRefreshing sketch geometry in OpenLayers 4?Openlayers VectorTiles Draw InteractionUncaught TypeError: layer.getLayerStatesArray is not a functionCustomize behaviour of Ol.interaction.draw.createbox() geometryFunction?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
Trying to extract the drawn features on openlayers. I have written the below code and it is working fine when we draw polygon on four objects. But, when we try to draw polygon on three objects it is returning four features instead of three, not sure why the function(evt.feature.getGeometry().getExtent()) is returning four features when polygon drawn on three objects on a map.
draw = new ol.interaction.Draw({
source: sourceMeasure,
type: /** @type {ol.geom.GeometryType} */ ('Polygon')
});
openlayerMap.addInteraction(draw);
draw.on('drawstart',
function(evt) {
// set sketch
}, this);
draw.on('drawend',
function(evt) {
var extent = evt.feature.getGeometry().getExtent();
vectorSource.forEachFeatureIntersectingExtent(extent, function(feature) {
var layer = feature.get('LAYER');
/* here my logic is written and it working fine with four coordinates */
});
}, this);
geoserver openlayers vector-layer
bumped to the homepage by Community♦ 15 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
|
show 3 more comments
Trying to extract the drawn features on openlayers. I have written the below code and it is working fine when we draw polygon on four objects. But, when we try to draw polygon on three objects it is returning four features instead of three, not sure why the function(evt.feature.getGeometry().getExtent()) is returning four features when polygon drawn on three objects on a map.
draw = new ol.interaction.Draw({
source: sourceMeasure,
type: /** @type {ol.geom.GeometryType} */ ('Polygon')
});
openlayerMap.addInteraction(draw);
draw.on('drawstart',
function(evt) {
// set sketch
}, this);
draw.on('drawend',
function(evt) {
var extent = evt.feature.getGeometry().getExtent();
vectorSource.forEachFeatureIntersectingExtent(extent, function(feature) {
var layer = feature.get('LAYER');
/* here my logic is written and it working fine with four coordinates */
});
}, this);
geoserver openlayers vector-layer
bumped to the homepage by Community♦ 15 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
seems like working fine codepen.io/anon/pen/JrvWbW
– Chase Choi
Oct 10 '17 at 5:10
No. It's not working. It is working only with a square box selection but for polygon it's not working. Is there any workaround?
– user3474541
Oct 11 '17 at 16:32
or could you make a fiddle to show the wrong behavior?
– Chase Choi
Oct 12 '17 at 0:28
Chase Choi, I used the same fiddle the one you provided. I have drawn four small squares on the map in two columns, and drawn the polygon intersecting only 3 squares. But it is returning four features instead of three.
– user3474541
Oct 12 '17 at 6:29
the coordinate of extent is always rectangle that's why you get wrong number of features. though you draw polygon, its extent is the maximum boundary rectangle. as you see openlayers.org/en/latest/apidoc/ol.html#.Extent
– Chase Choi
Oct 12 '17 at 6:54
|
show 3 more comments
Trying to extract the drawn features on openlayers. I have written the below code and it is working fine when we draw polygon on four objects. But, when we try to draw polygon on three objects it is returning four features instead of three, not sure why the function(evt.feature.getGeometry().getExtent()) is returning four features when polygon drawn on three objects on a map.
draw = new ol.interaction.Draw({
source: sourceMeasure,
type: /** @type {ol.geom.GeometryType} */ ('Polygon')
});
openlayerMap.addInteraction(draw);
draw.on('drawstart',
function(evt) {
// set sketch
}, this);
draw.on('drawend',
function(evt) {
var extent = evt.feature.getGeometry().getExtent();
vectorSource.forEachFeatureIntersectingExtent(extent, function(feature) {
var layer = feature.get('LAYER');
/* here my logic is written and it working fine with four coordinates */
});
}, this);
geoserver openlayers vector-layer
Trying to extract the drawn features on openlayers. I have written the below code and it is working fine when we draw polygon on four objects. But, when we try to draw polygon on three objects it is returning four features instead of three, not sure why the function(evt.feature.getGeometry().getExtent()) is returning four features when polygon drawn on three objects on a map.
draw = new ol.interaction.Draw({
source: sourceMeasure,
type: /** @type {ol.geom.GeometryType} */ ('Polygon')
});
openlayerMap.addInteraction(draw);
draw.on('drawstart',
function(evt) {
// set sketch
}, this);
draw.on('drawend',
function(evt) {
var extent = evt.feature.getGeometry().getExtent();
vectorSource.forEachFeatureIntersectingExtent(extent, function(feature) {
var layer = feature.get('LAYER');
/* here my logic is written and it working fine with four coordinates */
});
}, this);
geoserver openlayers vector-layer
geoserver openlayers vector-layer
edited Oct 9 '17 at 10:56
Ian Turton♦
50.4k548119
50.4k548119
asked Oct 9 '17 at 10:37
user3474541user3474541
455
455
bumped to the homepage by Community♦ 15 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 15 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
seems like working fine codepen.io/anon/pen/JrvWbW
– Chase Choi
Oct 10 '17 at 5:10
No. It's not working. It is working only with a square box selection but for polygon it's not working. Is there any workaround?
– user3474541
Oct 11 '17 at 16:32
or could you make a fiddle to show the wrong behavior?
– Chase Choi
Oct 12 '17 at 0:28
Chase Choi, I used the same fiddle the one you provided. I have drawn four small squares on the map in two columns, and drawn the polygon intersecting only 3 squares. But it is returning four features instead of three.
– user3474541
Oct 12 '17 at 6:29
the coordinate of extent is always rectangle that's why you get wrong number of features. though you draw polygon, its extent is the maximum boundary rectangle. as you see openlayers.org/en/latest/apidoc/ol.html#.Extent
– Chase Choi
Oct 12 '17 at 6:54
|
show 3 more comments
seems like working fine codepen.io/anon/pen/JrvWbW
– Chase Choi
Oct 10 '17 at 5:10
No. It's not working. It is working only with a square box selection but for polygon it's not working. Is there any workaround?
– user3474541
Oct 11 '17 at 16:32
or could you make a fiddle to show the wrong behavior?
– Chase Choi
Oct 12 '17 at 0:28
Chase Choi, I used the same fiddle the one you provided. I have drawn four small squares on the map in two columns, and drawn the polygon intersecting only 3 squares. But it is returning four features instead of three.
– user3474541
Oct 12 '17 at 6:29
the coordinate of extent is always rectangle that's why you get wrong number of features. though you draw polygon, its extent is the maximum boundary rectangle. as you see openlayers.org/en/latest/apidoc/ol.html#.Extent
– Chase Choi
Oct 12 '17 at 6:54
seems like working fine codepen.io/anon/pen/JrvWbW
– Chase Choi
Oct 10 '17 at 5:10
seems like working fine codepen.io/anon/pen/JrvWbW
– Chase Choi
Oct 10 '17 at 5:10
No. It's not working. It is working only with a square box selection but for polygon it's not working. Is there any workaround?
– user3474541
Oct 11 '17 at 16:32
No. It's not working. It is working only with a square box selection but for polygon it's not working. Is there any workaround?
– user3474541
Oct 11 '17 at 16:32
or could you make a fiddle to show the wrong behavior?
– Chase Choi
Oct 12 '17 at 0:28
or could you make a fiddle to show the wrong behavior?
– Chase Choi
Oct 12 '17 at 0:28
Chase Choi, I used the same fiddle the one you provided. I have drawn four small squares on the map in two columns, and drawn the polygon intersecting only 3 squares. But it is returning four features instead of three.
– user3474541
Oct 12 '17 at 6:29
Chase Choi, I used the same fiddle the one you provided. I have drawn four small squares on the map in two columns, and drawn the polygon intersecting only 3 squares. But it is returning four features instead of three.
– user3474541
Oct 12 '17 at 6:29
the coordinate of extent is always rectangle that's why you get wrong number of features. though you draw polygon, its extent is the maximum boundary rectangle. as you see openlayers.org/en/latest/apidoc/ol.html#.Extent
– Chase Choi
Oct 12 '17 at 6:54
the coordinate of extent is always rectangle that's why you get wrong number of features. though you draw polygon, its extent is the maximum boundary rectangle. as you see openlayers.org/en/latest/apidoc/ol.html#.Extent
– Chase Choi
Oct 12 '17 at 6:54
|
show 3 more comments
1 Answer
1
active
oldest
votes
You can use a third party library like JSTS to solve your issue.
You can find out how to select exactly by polygon instead of extend by looking at this sample
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "79"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f257889%2fopenlayers-interaction-events-are-returning-wrong-features%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can use a third party library like JSTS to solve your issue.
You can find out how to select exactly by polygon instead of extend by looking at this sample
add a comment |
You can use a third party library like JSTS to solve your issue.
You can find out how to select exactly by polygon instead of extend by looking at this sample
add a comment |
You can use a third party library like JSTS to solve your issue.
You can find out how to select exactly by polygon instead of extend by looking at this sample
You can use a third party library like JSTS to solve your issue.
You can find out how to select exactly by polygon instead of extend by looking at this sample
answered Oct 31 '17 at 1:32
ThomasG77ThomasG77
10.8k2347
10.8k2347
add a comment |
add a comment |
Thanks for contributing an answer to Geographic Information Systems Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f257889%2fopenlayers-interaction-events-are-returning-wrong-features%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
seems like working fine codepen.io/anon/pen/JrvWbW
– Chase Choi
Oct 10 '17 at 5:10
No. It's not working. It is working only with a square box selection but for polygon it's not working. Is there any workaround?
– user3474541
Oct 11 '17 at 16:32
or could you make a fiddle to show the wrong behavior?
– Chase Choi
Oct 12 '17 at 0:28
Chase Choi, I used the same fiddle the one you provided. I have drawn four small squares on the map in two columns, and drawn the polygon intersecting only 3 squares. But it is returning four features instead of three.
– user3474541
Oct 12 '17 at 6:29
the coordinate of extent is always rectangle that's why you get wrong number of features. though you draw polygon, its extent is the maximum boundary rectangle. as you see openlayers.org/en/latest/apidoc/ol.html#.Extent
– Chase Choi
Oct 12 '17 at 6:54